fix color detection

master
Brad Cornes 2021-10-08 18:24:57 +01:00
parent febded6864
commit ba21a2f1d8
1 changed files with 4 additions and 12 deletions

View File

@ -51,18 +51,10 @@ const colorRegex = new RegExp(
function getColorsInString(str: string): (culori.Color | KeywordColor)[] {
if (/(?:box|drop)-shadow/.test(str)) return []
return (
str
.match(colorRegex)
?.map((color) =>
color
.trim()
.replace(/^[,(]|[,)]$/g, '')
.replace(/var\([^)]+\)/, '1')
)
.map((color) => getKeywordColor(color) ?? culori.parse(color))
.filter(Boolean) ?? []
)
return Array.from(str.matchAll(colorRegex), (match) => {
let color = match[1].replace(/var\([^)]+\)/, '1')
return getKeywordColor(color) ?? culori.parse(color)
}).filter(Boolean)
}
function getColorFromDecls(