Skip to content

Update design tokens + fix generator for referenced fontWeight#28

Open
hoangnhatdrk wants to merge 2 commits into
mainfrom
update-design-tokens
Open

Update design tokens + fix generator for referenced fontWeight#28
hoangnhatdrk wants to merge 2 commits into
mainfrom
update-design-tokens

Conversation

@hoangnhatdrk

Copy link
Copy Markdown
Contributor

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.json so that each style's fontWeight is now a token reference (e.g. "{body-large-font-weight}") instead of a literal weight name ("Regular"). Those references chain down to intentionally value-less typography-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 fontWeight as a literal, which crashed the script (it looked for a nonexistent Roboto-{body-large-font-weight}.ttf and hit sys.exit(1)) and would otherwise have emitted FontWeight.Normal for every style.

Changes

  • scripts/generate_tokens/generate_design_tokens.py — added resolve_font_weight() that follows the fontWeight reference chain down to typography-font-weight-<name> and derives the named weight from the suffix; wired it into discover_typography_fonts and emit_typography.
  • Regenerated Colors.kt — purely additive members (new button state variants + border.medium) from the expanded theme.alfie-theme.tokens.json. Typography.kt, Primitives.kt, Sizing.kt, TypographyTokens.kt regenerate byte-identical.
  • Design-token JSON — refreshed the Figma export (colors, typography, sizing, screen-size, system, manifest).
  • theme.selfridges.tokens.json is included in assets but intentionally not parsed/generated — it's a Figma experiment, deferred for later.

Verification

  • python3 scripts/generate_tokens/generate_design_tokens.py completes without error; discovers weights [Regular, Medium].
  • Typography.kt regenerates byte-identical (Normal for display/body/label-small, W500 for heading/link/label-small-bold).
  • ./gradlew :designsystem:compileDebugKotlin :debug:operational:compileDebugKotlin compiles.

⚠️ Note: re-running the generator wipes res/font/ and re-copies from assets/font/.../static/, whose TTFs are currently 0-byte placeholders — it will clobber the real committed fonts. Restore with git checkout -- designsystem/src/main/res/font/ after regenerating until real source TTFs are added. Not touched in this PR.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings July 9, 2026 06:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.py to resolve referenced typography font weights ({...}) down to typography-font-weight-<name> tokens.
  • Regenerated designsystem color 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 new selfridges theme 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.

Comment thread scripts/generate_tokens/generate_design_tokens.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants