Update design tokens + fix generator for referenced fontWeight#28
Open
hoangnhatdrk wants to merge 2 commits into
Open
Update design tokens + fix generator for referenced fontWeight#28hoangnhatdrk wants to merge 2 commits into
hoangnhatdrk wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refreshes the Figma-exported design-token JSON and updates the Python token generator so typography fontWeight can be resolved when it’s expressed as a token reference chain (rather than a literal weight name). It also regenerates Colors.kt to expose newly introduced theme colors (button states + border).
Changes:
- Updated
generate_design_tokens.pyto resolve referenced typography font weights ({...}) down totypography-font-weight-<name>tokens. - Regenerated
designsystemcolor tokens (Colors.kt) with additional border/button variants. - Refreshed multiple token JSON assets (typography/theme/system/sizing/screen-size) and updated the token
manifest.json(including the newselfridgestheme token file).
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| scripts/generate_tokens/generate_design_tokens.py | Adds resolve_font_weight() and wires it into typography font discovery and Typography.kt emission. |
| designsystem/src/main/java/com/mindera/alfie/designsystem/tokens/Colors.kt | Regenerated color API to include new border.medium and additional button state colors. |
| designsystem/src/main/assets/design_tokens/typography.styles.tokens.json | Updates typography styles so fontWeight values are token references rather than literals; removes documentation-only styles. |
| designsystem/src/main/assets/design_tokens/typography.alfie-theme.tokens.json | Updates typography tokens to the refreshed export format (more explicit fontWeight tokens and additional metadata tokens). |
| designsystem/src/main/assets/design_tokens/theme.selfridges.tokens.json | Adds a new experimental theme token set for selfridges (included in assets/manifest). |
| designsystem/src/main/assets/design_tokens/theme.alfie-theme.tokens.json | Expands theme tokens (border + button variants) and reorders/normalizes exported structure. |
| designsystem/src/main/assets/design_tokens/system.web.tokens.json | Refreshes exported web system tokens (adds os, reorders entries, normalizes dimension objects). |
| designsystem/src/main/assets/design_tokens/system.ios.tokens.json | Refreshes exported iOS system tokens (adds os, reorders entries, normalizes dimension objects). |
| designsystem/src/main/assets/design_tokens/system.android.tokens.json | Refreshes exported Android system tokens (adds os, reorders entries, normalizes dimension objects). |
| designsystem/src/main/assets/design_tokens/sizing.alfie-theme.tokens.json | Refreshes sizing tokens and normalizes export ordering/structure. |
| designsystem/src/main/assets/design_tokens/screen-size.wide-(xl).tokens.json | Refreshes wide screen-size tokens and normalizes export ordering/structure. |
| designsystem/src/main/assets/design_tokens/screen-size.small-(s).tokens.json | Refreshes small screen-size tokens and normalizes export ordering/structure. |
| designsystem/src/main/assets/design_tokens/screen-size.medium-(m).tokens.json | Refreshes medium screen-size tokens and normalizes export ordering/structure. |
| designsystem/src/main/assets/design_tokens/screen-size.large-(l).tokens.json | Refreshes large screen-size tokens and normalizes export ordering/structure. |
| designsystem/src/main/assets/design_tokens/manifest.json | Updates collections/modes listing and includes theme.selfridges.tokens.json under the theme collection. |
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.
What
Refreshes the design-token JSON exported from Figma and makes the Kotlin token generator compatible with the new format.
Why
The new Figma export changed
typography.styles.tokens.jsonso that each style'sfontWeightis now a token reference (e.g."{body-large-font-weight}") instead of a literal weight name ("Regular"). Those references chain down to intentionally value-lesstypography-font-weight-<name>tokens (present only in.broken-ref-allowlist.json), where the weight is meant to be read from the token-name suffix.The old generator read
fontWeightas a literal, which crashed the script (it looked for a nonexistentRoboto-{body-large-font-weight}.ttfand hitsys.exit(1)) and would otherwise have emittedFontWeight.Normalfor every style.Changes
scripts/generate_tokens/generate_design_tokens.py— addedresolve_font_weight()that follows thefontWeightreference chain down totypography-font-weight-<name>and derives the named weight from the suffix; wired it intodiscover_typography_fontsandemit_typography.Colors.kt— purely additive members (new button state variants +border.medium) from the expandedtheme.alfie-theme.tokens.json.Typography.kt,Primitives.kt,Sizing.kt,TypographyTokens.ktregenerate byte-identical.theme.selfridges.tokens.jsonis included in assets but intentionally not parsed/generated — it's a Figma experiment, deferred for later.Verification
python3 scripts/generate_tokens/generate_design_tokens.pycompletes without error; discovers weights[Regular, Medium].Typography.ktregenerates byte-identical (Normal for display/body/label-small, W500 for heading/link/label-small-bold)../gradlew :designsystem:compileDebugKotlin :debug:operational:compileDebugKotlincompiles.🤖 Generated with Claude Code