From 891eeb428ed87862ac061d82f51636b2104b7ce0 Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Tue, 17 Oct 2023 10:15:01 -0400 Subject: [PATCH] Update hsluv usage to new major version --- client/src/utils/color.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/client/src/utils/color.js b/client/src/utils/color.js index ade8e13b1630..0c27a4511f78 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,19 @@ 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 converter = new Hsluv(); + converter.hsluv_h = hue; + converter.hsluv_s = 100; + converter.hsluv_l = lightness; + converter.hsluvToHex(); + const primary = `rgb(${parseInt(converter.rgb_r * 255)},${parseInt(converter.rgb_g * 255)},${parseInt( + converter.rgb_b * 255 + )})`; + converter.hsluv_l = lightness * 0.9; + converter.hsluvToHex(); + const darker = converter.hex; + converter.hsluv_l = lightness * 0.95; + converter.hsluvToHex(); + const dimmed = converter.hex; return { primary, darker, dimmed }; }