Skip to content

Commit 5f26ba2

Browse files
authored
Support passing dark threshold for Colors.isDark (#2505)
1 parent 8844c94 commit 5f26ba2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/style/colors.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,10 @@ export class Colors {
273273
return _.inRange(hue, 51, 184);
274274
}
275275

276-
isDark(colorValue: string | OpaqueColorValue) {
276+
isDark(colorValue: string | OpaqueColorValue, darkThreshold = 0.55) {
277277
const color = colorValue === null ? undefined : colorStringValue(colorValue);
278278
const lum = tinycolor(color).getLuminance();
279-
return lum < 0.55;
279+
return lum < darkThreshold;
280280
}
281281
isValidHex(string: string) {
282282
return /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(string);

0 commit comments

Comments
 (0)