From 66362106facf53a0d8f3ea1c35d69dc4a0f0e986 Mon Sep 17 00:00:00 2001 From: Andrew Nguyen <52666982+Andrewnt219@users.noreply.github.com> Date: Sat, 9 Oct 2021 08:37:17 -0400 Subject: [PATCH] fix: allow ColorGenerator to parse colors with prefix # (#5669) --- website/src/components/ColorGenerator/index.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/website/src/components/ColorGenerator/index.tsx b/website/src/components/ColorGenerator/index.tsx index d972988208dd..9cbb4ef885dc 100644 --- a/website/src/components/ColorGenerator/index.tsx +++ b/website/src/components/ColorGenerator/index.tsx @@ -91,7 +91,10 @@ function ColorGenerator() { className={styles.input} defaultValue={baseColor} onChange={(event) => { - const colorValue = event.target.value; + // Replace all the prefix '#' with an empty string. + // For example, '#ccc' -> 'ccc', '##ccc' -> 'ccc' + const colorValue = event.target.value.replace(/^#+/, ''); + try { Color('#' + colorValue); setBaseColor(colorValue);