feat(theme): accept a [light, dark] tuple for defineTheme color.accent (#2279) - #4592
Open
jiunshinn wants to merge 1 commit into
Open
feat(theme): accept a [light, dark] tuple for defineTheme color.accent (#2279)#4592jiunshinn wants to merge 1 commit into
jiunshinn wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR No new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
jiunshinn
marked this pull request as ready for review
July 31, 2026 11:54
jiunshinn
requested review from
cixzhang,
ejhammond,
imdreamrunner and
josephfarina
as code owners
July 31, 2026 11:54
jiunshinn
force-pushed
the
feat/2279-tuple-accent
branch
from
August 1, 2026 12:40
1619c86 to
20cdf42
Compare
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.
Fixes #2279
Issue item 1 (make
accentoptional for neutral-only configs) already landed in #3916. This PR resolves the remaining items 2, 3 and 4.Item 2:
accentaccepts a[light, dark]tupleColorScaleConfig.accentis nowstring | [light: string, dark: string], matching theTokenValueshape the rest of the token system uses:Item 3: per-scheme palette derivation
With a tuple,
expandColorScalebuilds two sets of tonal palettes: the light half of every generatedlight-dark()pair derives from the light seed's palettes (primary, neutral, neutral-variant), and the dark half from the dark seed's. So--color-accent,--color-on-accentand the hue-tinted neutrals each follow their scheme's own seed, instead of thetokens['--color-accent']workaround that skips scale generation entirely.A plain string accent normalizes to a same-seed pair whose dark palettes alias the light ones, so single-seed configs produce byte-identical output to the previous implementation. A test pins this equivalence (
expandColorScale({accent: X})deep-equalsexpandColorScale({accent: [X, X]})), and another pins that each tuple half resolves identically to the matching single-accent expansion per mode.Item 4: precedence between
colorandtokensfor accent-derived valuesDocumented in the
DefineThemeInput.colorJSDoc and the CLI theme docs (astryx docs theme, including the dense and zh variants), and pinned by tests:tokensentries win overcolor-generated values, token by token.--color-accent-muted,--color-text-accentand--color-icon-accentare generated asvar(--color-accent)references, so atokens['--color-accent']override re-points them at runtime.--color-on-accentdoes NOT follow: it is baked from thecolor.accentseed (a contrast computation CSS cannot express). Overriding the accent viatokenswithout also overriding--color-on-accentleaves the two out of sync; the docs now say to prefer a tuplecolor.accent, which item 3 makes possible.The tests fix the current behavior rather than change it. If maintainers would rather have
tokens['--color-accent']re-derive--color-on-accent, that is a behavior change I kept out of scope here (see open questions).Scope note (Color Studio)
Per ernestt's comment on the issue, @rubyycheung is exploring an expansion of the color scale config (grey tone and saturation controls) via Color Studio. This PR is intentionally scoped narrowly to tuple accents + per-scheme derivation + precedence documentation so it does not preempt that work: the per-scheme seed split composes with additional palette controls (they would apply to both seeds the way
neutralStyle/contrastalready do).Related open PR: #4354 (WCAG contrast assertions for generated token pairs) also touches
expandColorScale.ts/.test.ts. The changes are orthogonal (this PR does not alter any single-seed output), but whichever lands second will need a small rebase. If #4354's assertions land first, tuple configs give them two seeds to check per pair, which the per-scheme split here already models.Open questions
NL/NDwiring.tokens['--color-accent']re-derive--color-on-accentwhen acolorconfig is present? Left as documented divergence to avoid changing existing themes.Testing
pnpm exec vitest run packages/core/src/theme(555 passed, includes new tuple + precedence tests)pnpm exec vitest run packages/cli(2171 passed, doc structure)pnpm -F @astryxdesign/core typecheck,pnpm -F @astryxdesign/core lint(0 errors)pnpm -F "@astryxdesign/theme-*" build(all 7 theme packages build clean)node scripts/check-changesets.mjspasses; changeset is[feat]patch per pre-1.0 policy