feat: multi-theme support via per-token mode values (light/dark)#128
Open
mvanhorn wants to merge 1 commit into
Open
feat: multi-theme support via per-token mode values (light/dark)#128mvanhorn wants to merge 1 commit into
mvanhorn wants to merge 1 commit into
Conversation
Inline per-token modes (`{ light, dark }`) with per-mode resolution and
Tailwind v4 export. Additive and backward compatible. Refs google-labs-code#13.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-endorsedmodesshape 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
modesapproach 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/spec.ts,parser/handler.ts): accept a mode-keyed object value ({ light, dark }) alongside the existing scalar form; capturethemes/default-themefrontmatter keys (registered inspec-config.ts).model/spec.ts,model/handler.ts): resolve each token per-mode while keeping single-value resolution as the default-theme path.tailwind/v4/serialize.ts): emit the default mode in:rootand alternate modes under aprefers-color-scheme/ data-attribute selector.Scope
Covers the inline per-token
modesmodel (parse + resolve + export) only. Theextends/ 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.