Skip to content

feat: multi-theme support via per-token mode values (light/dark)#128

Open
mvanhorn wants to merge 1 commit into
google-labs-code:mainfrom
mvanhorn:fix/13-multi-theme-modes
Open

feat: multi-theme support via per-token mode values (light/dark)#128
mvanhorn wants to merge 1 commit into
google-labs-code:mainfrom
mvanhorn:fix/13-multi-theme-modes

Conversation

@mvanhorn

Copy link
Copy Markdown
Contributor

Summary

Adds multi-theme support to the DESIGN.md spec via inline per-token mode values: a single color/dimension token can carry { light, dark } (and other declared modes) instead of being duplicated across parallel light/dark tokens. This is the maintainer-endorsed modes shape from #13.

Why this matters

The reporter in #13 maintains ~100 role tokens duplicated in parallel for light and dark. @davideast is "very supportive of multi-themes," explicitly endorsed the inline modes approach because "it will be agent friendly when tooling isn't present," and listed it "at the top of the list." This implements that endorsed shape only, additively and backward-compatibly: existing scalar-only DESIGN.md files parse, resolve, and export exactly as before.

Changes

  • Parser (parser/spec.ts, parser/handler.ts): accept a mode-keyed object value ({ light, dark }) alongside the existing scalar form; capture themes / default-theme frontmatter keys (registered in spec-config.ts).
  • Model (model/spec.ts, model/handler.ts): resolve each token per-mode while keeping single-value resolution as the default-theme path.
  • Tailwind v4 emitter (tailwind/v4/serialize.ts): emit the default mode in :root and alternate modes under a prefers-color-scheme / data-attribute selector.

Scope

Covers the inline per-token modes model (parse + resolve + export) only. The extends / multi-file inheritance and external-file token sourcing the maintainer floated separately are intentionally out of scope and need their own spec decision.

Testing

bun test src/linter -> 274 pass, 1 skip, 0 fail (621 assertions across 30 files). New tests cover { light, dark } parse/resolve, default-theme backward compatibility, Tailwind v4 export of default + alternate modes, and malformed-mode-object findings.

Refs #13

AI was used for assistance.

Inline per-token modes (`{ light, dark }`) with per-mode resolution and
Tailwind v4 export. Additive and backward compatible. Refs google-labs-code#13.
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