Skip to content

spike: Figma token sync pipeline for Android#2704

Draft
peterliu (peterInTown) wants to merge 2 commits into
mainfrom
figma-token-syncing-pipline-spike
Draft

spike: Figma token sync pipeline for Android#2704
peterliu (peterInTown) wants to merge 2 commits into
mainfrom
figma-token-syncing-pipline-spike

Conversation

@peterInTown

Copy link
Copy Markdown
Contributor

Summary

  • Adds token-sync/ pipeline that fetches design tokens directly from Figma's Variables API
  • Removes dependency on @skyscanner/bpk-foundations-android npm package for token source
  • Uses Style Dictionary v5 to transform DTCG JSON → Kotlin Compose .kt + Android XML files
  • DTCG JSON is transient (written to /tmp, never committed) when using npm run tokens:sync

How it works

Figma Variables API
      │
      ▼  token-sync/src/fetch.ts
      │  GET /v1/files/{key}/variables/local
      │  → primitives.json (107 raw colors, spacing, radius)
      │  → backpack.light.json (209 semantic tokens, Day mode)
      │  → backpack.dark.json  (209 semantic tokens, Night mode)
      │
      ▼  token-sync/src/build.ts  (Style Dictionary v5)
      │
      ├── BpkSpacing.kt
      ├── BpkBorderRadius.kt
      ├── BpkBorderSize.kt
      ├── BpkColors.kt  (light + dark resolved from Figma)
      ├── dimensions.spacing.xml
      └── radii.xml

Commands

Command What it does
npm run tokens:fetch Fetch only → saves tokens/*.json locally
npm run tokens:build Build only → reads tokens/*.json, generates output/
npm run tokens:sync Full pipeline → Figma → /tmp → output/ → cleanup

Setup

cd token-sync
cp .env.example .env
# add FIGMA_TOKEN to .env
npm install
npm run tokens:sync

What's not done yet (follow-up work)

  • Internal component colors (BpkButtonColors.kt etc. from Component.* tokens)
  • Typography, elevation, duration tokens
  • GitHub Actions workflow to auto-open PR when Figma changes
  • iOS pipeline

Confluence doc

Figma token syncing pipeline - Android

🤖 Generated with Claude Code

Adds a token-sync/ pipeline that fetches design tokens directly from
Figma's Variables API and generates Kotlin Compose + Android XML files
via Style Dictionary, removing the dependency on @skyscanner/bpk-foundations-android.

Pipeline:
  npm run tokens:sync
    → fetch.ts  : Figma Variables API → DTCG JSON (primitives + light + dark)
    → build.ts  : Style Dictionary → BpkColors.kt, BpkSpacing.kt,
                  BpkBorderRadius.kt, BpkBorderSize.kt, dimensions.spacing.xml, radii.xml

BpkColors.kt updated with values sourced from Figma.
DTCG JSON files are transient (written to /tmp, never committed).

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor
Warnings
⚠️ One or more component files were updated, but the tests weren't updated. If your change is not covered by existing tests please add snapshot tests.
⚠️

One or more component files were updated, but the docs screenshots weren't updated. If the changes are visual or it is a new component please regenerate the screenshots via ./gradlew recordScreenshots.

⚠️

One or more component files were updated, but README.md wasn't updated. If your change contains API changes/additions or a new component please update the relevant component README.

Generated by 🚫 Danger Kotlin against e7fa1d5

@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor
Warnings
⚠️ One or more component files were updated, but the tests weren't updated. If your change is not covered by existing tests please add snapshot tests.
⚠️

One or more component files were updated, but the docs screenshots weren't updated. If the changes are visual or it is a new component please regenerate the screenshots via ./gradlew recordScreenshots.

⚠️

One or more component files were updated, but README.md wasn't updated. If your change contains API changes/additions or a new component please update the relevant component README.

Generated by 🚫 Danger Kotlin against 5bb0bda

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.

1 participant