@@ -16,9 +16,9 @@ var color = module.exports = {};
16
16
17
17
var colorAttrs = require ( './attributes' ) ;
18
18
color . defaults = colorAttrs . defaults ;
19
- color . defaultLine = colorAttrs . defaultLine ;
19
+ var defaultLine = color . defaultLine = colorAttrs . defaultLine ;
20
20
color . lightLine = colorAttrs . lightLine ;
21
- color . background = colorAttrs . background ;
21
+ var background = color . background = colorAttrs . background ;
22
22
23
23
/*
24
24
* tinyRGB: turn a tinycolor into an rgb string, but
@@ -47,7 +47,7 @@ color.combine = function(front, back) {
47
47
var fc = tinycolor ( front ) . toRgb ( ) ;
48
48
if ( fc . a === 1 ) return tinycolor ( front ) . toRgbString ( ) ;
49
49
50
- var bc = tinycolor ( back || color . background ) . toRgb ( ) ,
50
+ var bc = tinycolor ( back || background ) . toRgb ( ) ,
51
51
bcflat = bc . a === 1 ? bc : {
52
52
r : 255 * ( 1 - bc . a ) + bc . r * bc . a ,
53
53
g : 255 * ( 1 - bc . a ) + bc . g * bc . a ,
@@ -68,16 +68,15 @@ color.combine = function(front, back) {
68
68
*
69
69
* If lightAmount / darkAmount are used, we adjust by these percentages,
70
70
* 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?
72
71
*/
73
72
color . contrast = function ( cstr , lightAmount , darkAmount ) {
74
73
var tc = tinycolor ( cstr ) ;
75
74
76
- if ( tc . getAlpha ( ) !== 1 ) tc = tinycolor ( color . combine ( cstr , '#fff' ) ) ;
75
+ if ( tc . getAlpha ( ) !== 1 ) tc = tinycolor ( color . combine ( cstr , background ) ) ;
77
76
78
77
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 ) ;
81
80
82
81
return newColor . toString ( ) ;
83
82
} ;
0 commit comments