diff --git a/client/src/utils/color.js b/client/src/utils/color.js index ade8e13b1630..842ff9cd2f27 100644 --- a/client/src/utils/color.js +++ b/client/src/utils/color.js @@ -1,4 +1,4 @@ -import { hsluvToHex, hsluvToRgb } from "hsluv"; +import { Hsluv } from "hsluv"; import { hashFnv32a } from "utils/utils"; /** @@ -16,10 +16,17 @@ export function keyedColorScheme(strKey) { lightness += (100 - lightness) * 0.75; } - const [r, g, b] = hsluvToRgb([hue, 100, lightness]); - const primary = `rgb(${parseInt(r * 255)},${parseInt(g * 255)},${parseInt(b * 255)})`; - const darker = hsluvToHex([hue, 100, lightness * 0.9]); - const dimmed = hsluvToHex([hue, 100, lightness * 0.95]); - + const conv = new Hsluv(); + conv.hsluv_h = hue; + conv.hsluv_s = 100; + conv.hsluv_l = lightness; + conv.hsluvToHex(); + const primary = `rgb(${parseInt(conv.rgb_r * 255)},${parseInt(conv.rgb_g * 255)},${parseInt(conv.rgb_b * 255)})`; + conv.hsluv_l = lightness * 0.9; + conv.hsluvToHex(); + const darker = conv.hex; + conv.hsluv_l = lightness * 0.95; + conv.hsluvToHex(); + const dimmed = conv.hex; return { primary, darker, dimmed }; }