Skip to content

Commit b3e15c2

Browse files
committed
fix(rgbToHex): transparent is not a valid rgb color ie issue
1 parent 4a568f4 commit b3e15c2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

js/src/utilities/rgb-to-hex.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ const rgbToHex = (color) => {
1010
if (typeof color === 'undefined') {
1111
throw new Error('Hex color is not defined')
1212
}
13+
if (color === 'transparent') {
14+
return '#00000000'
15+
}
1316
const rgb = color.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i)
1417
if (!rgb) {
1518
throw new Error(`${color} is not a valid rgb color`)

0 commit comments

Comments
 (0)