Skip to content

Commit 62218c1

Browse files
authored
feat: update color value detection for cssVars (#8901)
1 parent dd1563d commit 62218c1

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

.changeset/weak-planets-smell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"shadcn": patch
3+
---
4+
5+
update color value detection for cssVars

packages/shadcn/src/utils/updaters/update-css-vars.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,6 @@ export function isColorValue(value: string) {
898898
value.startsWith("rgb") ||
899899
value.startsWith("#") ||
900900
value.startsWith("oklch") ||
901-
value.startsWith("var(--color-")
901+
value.includes("--color-")
902902
)
903903
}

packages/shadcn/test/utils/updaters/update-css-vars.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,6 +1417,8 @@ describe("isColorValue", () => {
14171417
["oklch(0.5 0.2 180)", true],
14181418
["var(--color-background)", true],
14191419
["var(--color-blue-500)", true],
1420+
["--alpha(var(--color-black) / 10%)", true],
1421+
["--alpha(var(--color-black) / 4%)", true],
14201422
["var(--radius)", false],
14211423
["var(--spacing)", false],
14221424
["0.5rem", false],

0 commit comments

Comments
 (0)