Skip to content

Commit dc0b07a

Browse files
committed
light-dark() color support
1 parent cb506c7 commit dc0b07a

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/utils/color.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ const hslMatch = /^hsla?\([^\(\)]+\)$/;
148148
const hexMatch = /^#[0-9a-f]+$/i;
149149
const colorFnRegex = /^color\([^\(\)]+\)$/;
150150
const colorMixFnRegex = /^color-mix\([^\(\)]+\)$/;
151+
const lightDarkRegex = /^light-dark\([^\(\)]+\)$/;
151152

152153
export function parse($color: string): RGBA | null {
153154
const c = $color.trim().toLowerCase();
@@ -176,7 +177,7 @@ export function parse($color: string): RGBA | null {
176177
return {r: 0, g: 0, b: 0, a: 0};
177178
}
178179

179-
if (c.match(colorFnRegex) || c.match(colorMixFnRegex)) {
180+
if (c.match(colorFnRegex) || c.match(colorMixFnRegex) || c.match(lightDarkRegex)) {
180181
return domParseColor(c);
181182
}
182183

0 commit comments

Comments
 (0)