File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -160,16 +160,17 @@ export class Colors {
160
160
generateColorPalette = _ . memoize ( color => {
161
161
const hsl = Color ( color ) . hsl ( ) ;
162
162
const lightness = Math . round ( hsl . color [ 2 ] ) ;
163
+ const lightColorsThreshold = this . shouldGenerateDarkerPalette ( color ) ? 5 : 0 ;
163
164
164
165
const ls = [ hsl . color [ 2 ] ] ;
165
166
let l = lightness - 10 ;
166
- while ( l >= 20 ) {
167
+ while ( l >= 20 - lightColorsThreshold ) {
167
168
ls . unshift ( l ) ;
168
169
l -= 10 ;
169
170
}
170
171
171
172
l = lightness + 10 ;
172
- while ( l < 100 ) {
173
+ while ( l < 100 - lightColorsThreshold ) {
173
174
ls . push ( l ) ;
174
175
l += 10 ;
175
176
}
@@ -185,6 +186,12 @@ export class Colors {
185
186
return adjusted || sliced ;
186
187
} ) ;
187
188
189
+ shouldGenerateDarkerPalette ( color : string ) {
190
+ const hsl = Color ( color ) . hsl ( ) ;
191
+ const hue = hsl . color [ 0 ] ;
192
+ return _ . inRange ( hue , 51 , 184 ) ;
193
+ }
194
+
188
195
isDark ( color : string ) {
189
196
const lum = tinycolor ( color ) . getLuminance ( ) ;
190
197
return lum < 0.55 ;
You can’t perform that action at this time.
0 commit comments