mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-28 15:14:12 +00:00
fix(cli): fix add registry item with at-property css rule (#8451)
* Add fixture and test * Handle at-property as regular CSS rules in updateCssPlugin * Add changeset entry --------- Co-authored-by: shadcn <m@shadcn.com>
This commit is contained in:
5
.changeset/lazy-mails-wear.md
Normal file
5
.changeset/lazy-mails-wear.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"shadcn": patch
|
||||
---
|
||||
|
||||
fix adding registry item with CSS at-property
|
||||
@@ -338,6 +338,10 @@ function updateCssPlugin(css: z.infer<typeof registryItemCssSchema>) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Handle at-property as regular CSS rules
|
||||
else if (name === "property") {
|
||||
processRule(root, selector, properties)
|
||||
} else {
|
||||
// Handle other at-rules normally
|
||||
processAtRule(root, name, params, properties)
|
||||
|
||||
12
packages/tests/fixtures/registry/example-at-property.json
vendored
Normal file
12
packages/tests/fixtures/registry/example-at-property.json
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
||||
"name": "example-at-property",
|
||||
"type": "registry:style",
|
||||
"css": {
|
||||
"@property --foo": {
|
||||
"syntax": "'<number>'",
|
||||
"inherits": "false",
|
||||
"initial-value": "0"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -296,4 +296,31 @@ describe("shadcn add", () => {
|
||||
await fs.readFile(path.join(fixturePath, "path/to/foo.txt"), "utf-8")
|
||||
).toBe("Foo Bar")
|
||||
})
|
||||
|
||||
it("should add at-property", async () => {
|
||||
const fixturePath = await createFixtureTestDirectory("next-app-init")
|
||||
await npxShadcn(fixturePath, [
|
||||
"add",
|
||||
"../../fixtures/registry/example-at-property.json",
|
||||
"--yes",
|
||||
])
|
||||
|
||||
const globalCssContent = await fs.readFile(
|
||||
path.join(fixturePath, "app/globals.css"),
|
||||
"utf-8"
|
||||
)
|
||||
|
||||
expect(
|
||||
cssHasProperties(globalCssContent, [
|
||||
{
|
||||
selector: "@property --foo",
|
||||
properties: {
|
||||
syntax: "'<number>'",
|
||||
inherits: "false",
|
||||
"initial-value": "0",
|
||||
},
|
||||
},
|
||||
])
|
||||
).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user