Skip to content

Commit c0ee369

Browse files
authored
Feat/ update palette generation for bright colors (#1863)
* change colors + fix tests * generate darker palette for hues in range * update tests
1 parent d873fd3 commit c0ee369

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/style/colors.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,16 +160,17 @@ export class Colors {
160160
generateColorPalette = _.memoize(color => {
161161
const hsl = Color(color).hsl();
162162
const lightness = Math.round(hsl.color[2]);
163+
const lightColorsThreshold = this.shouldGenerateDarkerPalette(color) ? 5 : 0;
163164

164165
const ls = [hsl.color[2]];
165166
let l = lightness - 10;
166-
while (l >= 20) {
167+
while (l >= 20 - lightColorsThreshold) {
167168
ls.unshift(l);
168169
l -= 10;
169170
}
170171

171172
l = lightness + 10;
172-
while (l < 100) {
173+
while (l < 100 - lightColorsThreshold) {
173174
ls.push(l);
174175
l += 10;
175176
}
@@ -185,6 +186,12 @@ export class Colors {
185186
return adjusted || sliced;
186187
});
187188

189+
shouldGenerateDarkerPalette(color: string) {
190+
const hsl = Color(color).hsl();
191+
const hue = hsl.color[0];
192+
return _.inRange(hue, 51, 184);
193+
}
194+
188195
isDark(color: string) {
189196
const lum = tinycolor(color).getLuminance();
190197
return lum < 0.55;

0 commit comments

Comments
 (0)