Skip to content

Commit

Permalink
fix: allow ColorGenerator to parse colors with prefix # (#5669)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrewnt219 authored Oct 9, 2021
1 parent 6ed6989 commit 6636210
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion website/src/components/ColorGenerator/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6636210

Please sign in to comment.