Repository navigation
Design tokens first attempt - #5249
Merged
Merged
Conversation
`npm run design-tokens` reads the Figma exports in assets/design-tokens/ and writes css/design-tokens.css. Every class carries "ds" so it can't collide with a stock Tailwind class: bg-ds-action-primary, p-ds-sm, text-ds-type-body-md. The script warns about any token it has to drop. cn() learns the token classes so tailwind-merge doesn't drop, say, a text style sitting next to a text colour. A test fails when the committed CSS is stale.
Tailwind's text-* utility can't set a font, so each text style gets a same-named @Utility that does. The font tokens now reuse the app's Inter var and Fira Code VF stacks, so they don't load a second set of font files, and Sora falls back to Inter until it is loaded.
Security Review ✅
|
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.
Description
This PR turns the designer's Figma tokens into Tailwind classes, so components can use the design system's colours, spacing, radius, borders and text styles. Nothing in the app looks different yet: the classes only apply where a component uses them.
cd assets && npm run design-tokensreads the Figma exports (Light.tokens.json,Static.tokens.json, unedited) and writesassets/css/design-tokens.css, whichapp.cssimports.ds-:bg-ds-action-primary,p-ds-sm,rounded-ds-md,text-ds-type-body-md.assets/design-tokens/README.mdhas the naming table and how to update the tokens.cn()knows theds-classes. It keeps a text style next to a text colour, and ads-class replaces the stock one it overlaps (cn('p-4', 'p-ds-sm')givesp-ds-sm).Closes CON-327
Validation steps
cd assets && npm run design-tokens. It rewritescss/design-tokens.css, andgit statusshows no change. Any token it had to drop is printed as a warning with the reason.assets/design-tokens/README.mdand check the naming table makes sense.bg-ds-action-primary p-ds-sm rounded-ds-mdto any element in a template. It gets the indigo background, 16px padding and 8px radius. Remove it again.cd assets && npm test -- design-tokens.Additional notes for the reviewer
cn()modification may evolve as tokens change. They are still moving.ds-prefix so a token can never clash with or redefine a stock Tailwind class.bg-ds-*and nottext-ds-*.space/andgap/are different scales in Figma:space/xsis 8px andgap/xsis 4px. The classes keep Figma's names. Tailwind'sgap-*falls back to the spacing scale, sogap-ds-xl(not a gap token) quietly usesspace/xl. This is waiting on the designer: if the scales merge or share step names, it goes away.type,widthandweightin class names are deliberate. They letcn()tell a text style from a text colour, and a border width from a border colour.text-ds-type-codeis Fira Code). Tailwind'stext-*can't set a font, so the build writes a same-named@utilityfor each style. The font tokens reuse the app's Inter var and Fira Code VF stacks so no second set of font files loads. Sora isn't loaded yet, so display styles fall back to Inter.design-tokens.test.tsfails if it doesn't match what the script writes..prettierignoreskips the exports and the CSS so formatting can't break that check.AI Usage
Please disclose whether you've used AI anywhere in this PR (it's cool, we just
want to know!):
You can read more details in our
Responsible AI Policy
Pre-submission checklist
/reviewwith Claude Code)
(e.g.,
:owner,:admin,:editor,:viewer)