@@ -16,9 +16,9 @@ var color = module.exports = {};
1616
1717var colorAttrs = require ( './attributes' ) ;
1818color . defaults = colorAttrs . defaults ;
19- color . defaultLine = colorAttrs . defaultLine ;
19+ var defaultLine = color . defaultLine = colorAttrs . defaultLine ;
2020color . lightLine = colorAttrs . lightLine ;
21- color . background = colorAttrs . background ;
21+ var background = color . background = colorAttrs . background ;
2222
2323/*
2424 * tinyRGB: turn a tinycolor into an rgb string, but
@@ -47,7 +47,7 @@ color.combine = function(front, back) {
4747 var fc = tinycolor ( front ) . toRgb ( ) ;
4848 if ( fc . a === 1 ) return tinycolor ( front ) . toRgbString ( ) ;
4949
50- var bc = tinycolor ( back || color . background ) . toRgb ( ) ,
50+ var bc = tinycolor ( back || background ) . toRgb ( ) ,
5151 bcflat = bc . a === 1 ? bc : {
5252 r : 255 * ( 1 - bc . a ) + bc . r * bc . a ,
5353 g : 255 * ( 1 - bc . a ) + bc . g * bc . a ,
@@ -68,16 +68,15 @@ color.combine = function(front, back) {
6868 *
6969 * If lightAmount / darkAmount are used, we adjust by these percentages,
7070 * otherwise we go all the way to white or black.
71- * TODO: black is what we've always done for hover, but should it be #444 instead?
7271 */
7372color . contrast = function ( cstr , lightAmount , darkAmount ) {
7473 var tc = tinycolor ( cstr ) ;
7574
76- if ( tc . getAlpha ( ) !== 1 ) tc = tinycolor ( color . combine ( cstr , '#fff' ) ) ;
75+ if ( tc . getAlpha ( ) !== 1 ) tc = tinycolor ( color . combine ( cstr , background ) ) ;
7776
7877 var newColor = tc . isDark ( ) ?
79- ( lightAmount ? tc . lighten ( lightAmount ) : '#fff' ) :
80- ( darkAmount ? tc . darken ( darkAmount ) : '#000' ) ;
78+ ( lightAmount ? tc . lighten ( lightAmount ) : background ) :
79+ ( darkAmount ? tc . darken ( darkAmount ) : defaultLine ) ;
8180
8281 return newColor . toString ( ) ;
8382} ;
0 commit comments