From 0fee024f1e35c85bd1603ab461d640a8a13ac262 Mon Sep 17 00:00:00 2001 From: Shy Date: Wed, 16 Oct 2024 15:39:58 +0200 Subject: [PATCH] properly handle hex string with alpha --- src/Themes/ui/ColorPicker/index.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Themes/ui/ColorPicker/index.tsx b/src/Themes/ui/ColorPicker/index.tsx index 29181deac1..8b0e52c560 100644 --- a/src/Themes/ui/ColorPicker/index.tsx +++ b/src/Themes/ui/ColorPicker/index.tsx @@ -44,7 +44,15 @@ function parseHEXtoRGB(hex: string): RGB { }; } - if (hex.length == 7 || hex.length == 9) { + if (hex.length == 7) { + return { + r: Number.parseInt(`${hex[1]}${hex[2]}`, 16), + g: Number.parseInt(`${hex[3]}${hex[4]}`, 16), + b: Number.parseInt(`${hex[5]}${hex[6]}`, 16), + }; + } + + if (hex.length == 9) { return { r: Number.parseInt(`${hex[1]}${hex[2]}`, 16), g: Number.parseInt(`${hex[3]}${hex[4]}`, 16),