Skip to content

ds-shadcn: emit DTCG aliases for shadcn's own var() references, and put the template back - #15

Merged
visualfart merged 1 commit into
mainfrom
claude/hopeful-ramanujan-7ryi5n
Oct 1, 2026
Merged

visualfart merged 1 commit into
mainfrom
claude/hopeful-ramanujan-7ryi5n

Conversation

@visualfart

Copy link
Copy Markdown
Owner

What

shadcn's default theme points a few of its own variables at others of its own — --code: var(--surface), --code-foreground: var(--surface-foreground), --surface-foreground: var(--foreground). systemTier() in packages/ds-shadcn/scripts/generate.ts only resolved var(--color-*) (the chart ramp's Tailwind blues) and copied everything else through verbatim, so five tokens landed in tokens/system.light.json and tokens/system.dark.json as raw CSS. A consumer reads those as broken aliases, and scan() reported them as broken-alias — which is why "shadcn" was left out of the Studio's TEMPLATE_NAMES.

The fix is in the generator, not the JSON: a var(--x) whose --x is a variable in the same set becomes {shadcn.x}; a var(--x) naming a Tailwind variable still resolves to its value, as before. --radius is excluded because the generator emits it as a shadcn.radius.* group rather than a token.

With the pack clean, "shadcn" goes back into TEMPLATE_NAMES (after fluent, matching the order in MODELLED) and the expected template count in apps/studio/test/templates.test.ts goes 25 → 26.

Regenerated tokens

Exactly the five values named above changed, e.g.:

     "code": {
-      "$value": "var(--surface)"
+      "$value": "{shadcn.surface}"
     },

Verification

  • templateGraph("shadcn") → scan(g) reports no issues at all — not just no broken-alias / circular-alias. 832 tokens, both modes.
  • Resolved every token path in both modes before and after the change: the only differences are the three that previously resolved to undefined and now resolve (shadcn.code, shadcn.code-foreground, shadcn.surface-foreground). Every other value is byte-identical, so nothing rendered changes.
  • apps/studio tests: 86/86 pass, including the per-template assertion that aliases resolve, all 87 roles map exactly, and contrast passes in both modes for shadcn.
  • npm run typecheck passes.
  • packages/ds-shadcn npm run check: "Design system satisfies the semantic token contract."

packages/verifier fails in this container, before and after the change, because Playwright's headless-shell binary isn't present (Executable doesn't exist at /opt/pw-browsers/chromium_headless_shell-1243/…). Unrelated to this diff.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DpBnGsdoAuaeNu6VECKHL3


Generated by Claude Code

shadcn's default theme points a few of its variables at others of its own
(--code: var(--surface), --surface-foreground: var(--foreground)). The
generator only resolved var(--color-*) into Tailwind palette values, so
those five landed in tokens/system.{light,dark}.json as raw CSS, which a
consumer reads as a broken alias — scan() reported them as such, and the
Studio chooser left the pack out for that reason.

Map a var(--x) whose --x is a variable in the same set to {shadcn.x} and
regenerate. Both forms name the same colour, so nothing rendered changes;
the three tokens that previously resolved to nothing now resolve.

With the pack clean, put "shadcn" back in TEMPLATE_NAMES.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DpBnGsdoAuaeNu6VECKHL3
@visualfart
visualfart marked this pull request as ready for review October 1, 2026 04:01
@visualfart
visualfart merged commit 8c70266 into main Oct 1, 2026
1 check 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.

2 participants