Skip to content

fix(sheet): reject theme tokens of different kinds sharing a variable - #908

Merged
owjs3901 merged 1 commit into
mainfrom
fix/theme-variable-clashes
Nov 14, 2026
Merged

owjs3901 merged 1 commit into
mainfrom
fix/theme-variable-clashes

Conversation

@owjs3901

Copy link
Copy Markdown
Contributor

Summary

NEW-04: token names were checked for clashes only within one kind (check_token_names / flatten_color_value). A color card and a shadow card therefore both declared --card, and whichever came last in :root silently replaced the other.

  • Theme now uses serde's remote = "Self" pattern. The derived field-by-field deserialization stays as it was, and the trait Deserialize impl then runs check_token_kinds over the whole theme. Every path that reads a theme gets the check: the wasm and napi registerTheme decode, and serde_json.
  • check_token_kinds compares the CSS variables of colors (every variant, css_key), length and shadow (css_key_from, so gray.100 and gray-100 are the same variable). The same name in two variants of one kind is still allowed, because it is the same variable on purpose.
  • The atom identity fixture first_value.rs gave a length and a shadow the same name space, which is exactly this clash. The shadow is now called lift. The assertions still check that a shadow token's first value resolves on its own.
  • Docs: the colors page notes that colors, length and shadow share one namespace.

New build error:

  • theme: color token 'card' and shadow token 'card' both become the CSS variable --card: rename one

Refs #685

Test plan

  • cargo test -p sheet --lib (234 passed)
  • cargo clippy -p sheet --all-targets -- -D warnings, cargo fmt --all -- --check
  • apps/landing/devup.json checked for cross-kind clashes (none)
  • CI: full test suite + tarpaulin 100%

🤖 Generated with Claude Code

Token names were checked for clashes only within one kind, so a color
`card` and a shadow `card` both declared `--card` and one silently
replaced the other in `:root`. Deserializing the theme now checks colors,
`length` and `shadow` together and reports the two tokens and the
variable. The atom identity fixture that gave a length and a shadow the
same name now names the shadow `lift`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
libs/sheet/src/theme.rs 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@owjs3901
owjs3901 merged commit 1160bf6 into main Nov 14, 2026
52 of 53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant