Repository navigation
spec(theme-tokens): name colour tokens by one grammar - #8103
Conversation
Colour token names take five shapes: property then role, the intent's own colour, a variant suffix, on- content on a fill, and domain layers. A name check over the colour and domain defaults verifies it.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewNo new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Visual Regression46 of 494 shot(s) changed. A change here is a question, not a failure: check whether the after is the
and 26 more. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
There was a problem hiding this comment.
INV10's naming grammar is a new invariant in the current architecture:theme-tokens record, so approval waits on an engineering owner's decision: an engineering owner records it by commenting /approve-spec <full head SHA> on this pull request (the author may do so as an engineering owner), or asks for changes. That decision should settle whether INV10 admits the info intent and --color-on-<intent>-muted names that no token has today, and how it relates to #7657, which adds a different INV10 to the same record using the --color-status-foreground-* names this grammar rejects. Independently, please make INV10's scope exact before that decision, since a new commit resets an approval:
- Say that the rule covers portable
--color-*names other than the listed role-less utility names, and give the verification row's failure signal the same exception; as written, "every name takes one of five shapes" contradicts the eight utility names INV10 keeps.
[Automated review]
| - **INV10 — Colour token names follow one grammar.** Every portable colour | ||
| token name takes one of five shapes: |
There was a problem hiding this comment.
This says every portable colour token name takes one of the five shapes, but lines 136-138 keep eight current names that take none, and the INV10 failure signal at line 244 reads the same way; only the test's utilityNames set states the exception. It also leaves "colour token" undefined (--focus-outline-color has a colour default and takes no shape). Suggested wording: "Every portable --color-* token name, other than the role-less utility names below, takes one of five shapes:", with a failure signal of "A colour token name fits none of the five shapes and is not a listed utility name".
The grammar governs Astryx's own colour vocabulary: Core and domain defaults and what first-party themes set. Product, application, theme author, and other design-system variables are outside it.
|
/approve-spec b37c87c |
Colour token names follow one grammar, so a theme author or component author can predict a token's name from its job, and a new role can't invent a new naming style.
Exact decision needed
How portable colour tokens are named. The vocabulary grew a consistent practice (
--color-text-accent,--color-accent-muted,--color-on-accent,--color-icon-green) that no record states, so new roles keep proposing names outside it (foreground, astatusgroup,-textsuffixes).Existing authority searched
architecture:theme-tokensINV1–INV9: INV3 says names describe semantic roles but not how names are formed. No current record owns colour naming.packages/core/src/theme/tokens.stylex.ts(colorDefaults),domainTokens/(--color-data-*,--color-syntax-*),tailwind-theme.css, and the v0.0.6/v0.0.8 rename codemods: every current colour name fits the five shapes below.Decision
architecture:theme-tokensINV10. Every portable colour token takes one of five shapes:--color-<property>-<role>. The property istext,icon,backgroundorborder. The role is an emphasis, an intent, a surface, or a hue.--color-<intent>: the intent's own colour.-muted(pale),-emphasized(strong),-hover/-pressed, or-inverted.--color-on-<fill>: content on a fill.on-<intent>serves the intent's bare and-emphasizedfills; a-mutedfill pairs withon-<intent>-muted.--color-data-*and--color-syntax-*.Six role-less utility names keep their names. New names add no group segment, no other property word, and no property suffix. Tailwind keys may alias a token but never add a CSS variable.
Rejected alternatives
statusgroup orforegroundproperty word (--color-status-foreground-success): this is the only colour name that would put a group before the property, and it gives text a second property word.-textsuffix (--color-success-text): it puts the property last, which contradicts every existing--color-text-*token.Claim scope and non-goals
The grammar governs names only. It does not decide which roles exist, their values, or theme-local (
--astryx-theme-*) names. Existing names are unchanged.Evidence and implementation relationship
tokens.test.tsadds a name check overcolorDefaultsanddomainTokenDefaults. Every current colour token passes it, and names outside the grammar are rejected.Writing rubric results
Scope
tokens.test.tsas the invariant's verification; there is no runtime change and no Changeset.)Validation
pnpm check:knowledgegit diff --checkvitest run packages/core/src/theme/tokens.test.ts(29 passed)