feat: Add DTCG tokens synced from Figma - #350
Conversation
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR introduces an automated pipeline to fetch Figma variables/styles and generate DTCG-compliant token JSON files, committing the generated token set into packages/canvas-tokens/dtcg/tokens as part of an initial token infrastructure rework.
Changes:
- Add two Node scripts to fetch Figma variables/styles and generate DTCG token files.
- Add generated DTCG token JSON output (base/system/component/brand token sets).
- Add a GitHub Actions workflow and package scripts to automate syncing tokens from Figma.
Reviewed changes
Copilot reviewed 31 out of 34 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/utils/generate-dtcg-tokens.js | Converts raw Figma exports into structured DTCG token JSON, including modes/themes handling. |
| scripts/utils/fetch-figma-variables.js | Fetches Figma variables + styles + nodes into local JSON payload(s) for token generation. |
| packages/canvas-tokens/dtcg/tokens/system/type.json | Generated system typography tokens (aliases + typography objects). |
| packages/canvas-tokens/dtcg/tokens/system/size.json | Generated system size aliases for component sizing. |
| packages/canvas-tokens/dtcg/tokens/system/shape.json | Generated system corner-radius/shape sizing tokens. |
| packages/canvas-tokens/dtcg/tokens/system/padding.json | Generated system padding scale aliases. |
| packages/canvas-tokens/dtcg/tokens/system/opacity.json | Generated system opacity aliases and state-layer opacity tokens. |
| packages/canvas-tokens/dtcg/tokens/system/motion.json | Generated system motion easing aliases. |
| packages/canvas-tokens/dtcg/tokens/system/gap.json | Generated system spacing/gap aliases. |
| packages/canvas-tokens/dtcg/tokens/system/depth.json | Generated depth shadow tokens derived from Figma effect styles. |
| packages/canvas-tokens/dtcg/tokens/system/color/surface.json | Generated system surface color tokens with dark/brand extensions. |
| packages/canvas-tokens/dtcg/tokens/system/color/shadow.json | Generated shadow paint color tokens with dark/brand extensions. |
| packages/canvas-tokens/dtcg/tokens/system/color/focus.json | Generated focus ring colors + dimension values. |
| packages/canvas-tokens/dtcg/tokens/system/color/fg.json | Generated foreground/text/icon color tokens with dark/brand extensions. |
| packages/canvas-tokens/dtcg/tokens/system/color/chart.json | Generated chart palette tokens with dark mode mappings. |
| packages/canvas-tokens/dtcg/tokens/system/color/border.json | Generated border color tokens with dark/brand extensions. |
| packages/canvas-tokens/dtcg/tokens/system/color/bg.json | Generated background color tokens with dark mode mappings. |
| packages/canvas-tokens/dtcg/tokens/system/color/accent.json | Generated accent color tokens + overlay tokens with extensions. |
| packages/canvas-tokens/dtcg/tokens/system/breakpoint.json | Generated breakpoint dimension tokens. |
| packages/canvas-tokens/dtcg/tokens/component/system-icon.json | Generated component token file for system icon sizing. |
| packages/canvas-tokens/dtcg/tokens/brand.json | Generated brand palette tokens (light/dark) for themeable colors. |
| packages/canvas-tokens/dtcg/tokens/base/type.json | Generated base typography primitives (font-family/weights/letter-spacing). |
| packages/canvas-tokens/dtcg/tokens/base/size.json | Generated base dimension scale (px/rem descriptions, size ramp). |
| packages/canvas-tokens/dtcg/tokens/base/shadow.json | Generated base shadow geometry primitives (y/blur/spread). |
| packages/canvas-tokens/dtcg/tokens/base/opacity.json | Generated base opacity scale primitives. |
| packages/canvas-tokens/dtcg/tokens/base/motion.json | Generated base motion durations and easing primitives. |
| packages/canvas-tokens/dtcg/tokens/base/base.json | Generated base “base” numeric tokens (fontsize/baseline). |
| packages/canvas-tokens-docs/components/ColorGrid.tsx | Adds a clarifying comment for system color mapping used in docs UI. |
| package.json | Adds convenience scripts to fetch and parse tokens. |
| .github/workflows/figma-sync.yml | Adds workflow_dispatch automation to sync tokens from Figma and open a PR. |
| .eslintrc.js | Enables node env and declares fetch as a readonly global for linting. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 25 out of 27 changed files in this pull request and generated 4 comments.
Suppressed comments (1)
scripts/utils/token-parser/file.js:93
writeOutputFilesshallow-merges existing on-disk JSON with newly generated content viaObject.assign(existing, content). If both contain the same top-level key, nested token objects will be replaced wholesale and previously-written siblings can be lost. Prefer a deep merge for plain objects (treat$valuetoken leaves as atomic), or overwrite the file entirely if the generator always produces the complete token set.
fs.writeFileSync(
outputPath,
`${JSON.stringify(Object.assign(existing, content), null, 2)}\n`,
'utf8'
);
| with: | ||
| github-token: ${{ secrets.GH_RW_TOKEN }} | ||
| script: | | ||
| github.rest.pulls.create({ |
| return shadows.length ? shadows : undefined; | ||
| } | ||
|
|
||
| export function generateStyleTokens(payload) { |
Issue
#353
Summary
Add DTCG tokens synced from Figma to setup initial infra rework
Release Category
Tokens
Where Should the Reviewer Start?
Testing Manually
Thank You GIF