mirror of
https://github.com/storytold/figcraft.git
synced 2026-11-15 23:02:36 +00:00
tailwind: emit @theme static; fix assertion precedence in tests
Tailwind v4 drops theme variables no utility uses, but page code also reads tokens through var() and (--name) utilities, so the export keeps them all. Two test assertions mixed && and || without parentheses.
This commit is contained in:
1 parent
788d1df7be
commit
7a2568fe55
3 files changed
+7
-5
No files matched your search
@@ -80,7 +80,9 @@ fn css(doc: &Document, colls: &[&Collection], tailwind: bool) -> String {
|
||||
let attr = css_var_name(&c.name);
|
||||
for (i, m) in c.modes.iter().enumerate() {
|
||||
let sel = match i {
|
||||
0 if tailwind => "@theme".to_string(),
|
||||
// `static`: Tailwind otherwise drops theme variables no utility uses, and pages also
|
||||
// read them through `var()` and `(--name)` utilities.
|
||||
0 if tailwind => "@theme static".to_string(),
|
||||
0 => ":root".to_string(),
|
||||
_ => format!("[data-{}=\"{}\"]", attr.trim_start_matches('-'), css_safe(&m.name)),
|
||||
};
|
||||
|
||||
@@ -66,7 +66,7 @@ fn per_side_strokes_are_borders_on_those_sides() {
|
||||
let css = ex(&mut s, "inspect.code", json!({"id": f, "language": "css"}))["code"].as_str().unwrap_or_default().to_string();
|
||||
assert!(css.contains("border-bottom: 1px solid") && !css.contains("border:"), "{css}");
|
||||
let tw = code(&mut s, f, json!({}));
|
||||
assert!(tw.contains("border-b ") && tw.contains("border-[#262a31]") || tw.contains("border-[#262A31]"), "{tw}");
|
||||
assert!(tw.contains("border-b ") && (tw.contains("border-[#262a31]") || tw.contains("border-[#262A31]")), "{tw}");
|
||||
// Without per-side weights it is one border.
|
||||
ex(&mut s, "node.set", json!({"id": f, "props": {"strokeSides": null, "strokeWeight": 2}}));
|
||||
let css = ex(&mut s, "inspect.code", json!({"id": f, "language": "css"}))["code"].as_str().unwrap_or_default().to_string();
|
||||
@@ -140,7 +140,7 @@ fn variables_export_with_units_and_as_a_tailwind_theme() {
|
||||
let css = ex(&mut s, "variable.export", json!({"format": "css"}))["text"].as_str().unwrap_or_default().to_string();
|
||||
assert!(css.contains("--card: 12px;") && css.contains("--fade: 0.5;"), "{css}");
|
||||
let tw = ex(&mut s, "variable.export", json!({"format": "tailwind"}))["text"].as_str().unwrap_or_default().to_string();
|
||||
for want in ["@import \"tailwindcss\";", "@theme {", "--color-accent: #3ddc97;", "--radius-card: 12px;", "--fade: 0.5;"] {
|
||||
for want in ["@import \"tailwindcss\";", "@theme static {", "--color-accent: #3ddc97;", "--radius-card: 12px;", "--fade: 0.5;"] {
|
||||
assert!(tw.to_lowercase().contains(&want.to_lowercase()), "{want} in {tw}");
|
||||
}
|
||||
}
|
||||
@@ -192,7 +192,7 @@ fn slashed_layer_names_and_phone_widths_merge_right() {
|
||||
assert!(button.contains("self-stretch") && button.contains("lg:self-auto"), "the slashed name keeps its mobile classes: {out}");
|
||||
assert!(!out.contains("max-w-[342px] ") || out.contains("lg:max-w-[342px]"), "no phone-width cap below lg: {out}");
|
||||
assert!(out.contains("Only in the mobile frame") && out.contains("Tag"), "{out}");
|
||||
let divider = out.lines().filter(|l| l.contains("<div") && l.contains("h-[1px]") || l.contains("h-px")).count();
|
||||
let divider = out.lines().filter(|l| l.contains("<div") && (l.contains("h-[1px]") || l.contains("h-px"))).count();
|
||||
assert!(out.contains("w-full") && divider <= 2, "{out}");
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1338,7 +1338,7 @@ permissions: without it nothing is downloaded); `plugin.directory.publish {path
|
||||
`<Button variant="outline">{"See examples"}</Button>`, with each import once at the top. A design
|
||||
system mapped to shadcn/ui this way exports pages that use the project's own components. Bound variables become theme
|
||||
utilities (`bg-accent`, `rounded-card`, `text-muted`) that `variable.export {format: "tailwind"}`
|
||||
declares: `@import "tailwindcss";` and an `@theme` block named by namespace (`--color-*`,
|
||||
declares: `@import "tailwindcss";` and an `@theme static` block (every token is emitted, also those only read through `var()`) named by namespace (`--color-*`,
|
||||
`--radius-*`, `--text-*`, `--spacing-*`, `--font-*`; a number's namespace and unit come from what
|
||||
layers bind it to), other modes on `[data-<collection>="<mode>"]`. With `mobile: <frame id>` (the
|
||||
same layer names, mobile layout) the code is mobile first: the mobile frame's classes, the
|
||||
|
||||
Reference in new issue
Block a user