From 6663b5dff02047c3ad753e5b84be33c1429ebeab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20Klabbers?= Date: Thu, 8 Aug 2024 15:50:09 +0200 Subject: [PATCH] fix: 3 char hex color is incorrectly modified to 6 (#4013) The current logic creates `cdecde` from `cde`, it should be `ccddee`. @dsevillamartin said this is the code to use instead and chat gpt said he's brilliant so.. --- framework/core/js/src/common/utils/isDark.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/core/js/src/common/utils/isDark.ts b/framework/core/js/src/common/utils/isDark.ts index 2f870491f..fd0ea4b61 100644 --- a/framework/core/js/src/common/utils/isDark.ts +++ b/framework/core/js/src/common/utils/isDark.ts @@ -17,7 +17,7 @@ export default function isDark(hexcolor: string | null): boolean { let hexnumbers = hexcolor.replace('#', ''); if (hexnumbers.length === 3) { - hexnumbers += hexnumbers; + hexnumbers = hexnumbers.split('').map(char => char.repeat(2)).join(''); } const r = parseInt(hexnumbers.slice(0, 2), 16);