Skip to content

fix: ensure Figma base scale output includes all tokens for override themes - #1355

Merged
lukasoppermann merged 2 commits into
mainfrom
fix/figma-base-scale-collection-override
Apr 20, 2026
Merged

lukasoppermann merged 2 commits into
mainfrom
fix/figma-base-scale-collection-override

Conversation

@lukasoppermann

Copy link
Copy Markdown
Collaborator

Problem

Override themes (dark-dimmed, dark-high-contrast, light-high-contrast) only define tokens that differ from their parent theme. For example, dark.dimmed.json5 overrides blue, green, red, etc. but does not redefine neutral, black, inset, or transparent since they share the same values as dark.

When building Figma base scale output, inherited tokens retained the parent's collection name (e.g. base/color/dark instead of base/color/dark-dimmed). This meant those tokens were missing from the override theme's Figma collection — they appeared under the parent collection instead.

Affected themes and missing scales

Theme Missing from Figma collection
dark-dimmed neutral, black, inset, transparent, display tokens
dark-high-contrast neutral, white, inset, transparent, display tokens
light-high-contrast neutral, white, inset, transparent, display tokens

Solution

Added collectionOverride support to the figmaAttributes transformer. When a collectionOverride map is provided via platform options, any token whose collection matches a key in the map gets remapped to the corresponding value.

In buildFigma.ts, each override base scale entry now passes a collectionOverride that maps the parent collection to the theme's own collection (e.g. { 'base/color/dark': 'base/color/dark-dimmed' }).

Changes

  • src/transformers/figmaAttributes.ts — Added collectionOverride lookup before returning collection/group attributes
  • scripts/buildFigma.ts — Added collectionOverride to the 3 affected base scale configs and passes it through to the figma platform
  • src/transformers/figmaAttributes.test.ts — New test file covering the override behavior

Validation

  • ✅ Lint passes
  • ✅ All tests pass (including 5 new tests for figmaAttributes)
  • ✅ Full build succeeds

…themes

Override themes (dark-dimmed, dark-high-contrast, light-high-contrast)
inherit tokens from their parent theme. Previously, inherited tokens
retained the parent's Figma collection name (e.g. base/color/dark
instead of base/color/dark-dimmed), causing them to be missing from the
override theme's collection in Figma output.

Add collectionOverride support to the figmaAttributes transformer and
pass collection mappings for each override theme in buildFigma.ts.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 20, 2026 08:03
@lukasoppermann
lukasoppermann requested a review from a team as a code owner April 20, 2026 08:03
@changeset-bot

changeset-bot Bot commented Apr 20, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a642e86

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/primitives Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Apr 20, 2026 •

Copy link
Copy Markdown
Contributor

Design Token Diff (Figma)

The message is too long to be displayed here. For more details, please check the job summary.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 fixes Figma base scale exports for override themes by ensuring inherited tokens are emitted into the override theme’s Figma collection (instead of the parent collection).

Changes:

  • Add collectionOverride support to the figmaAttributes transformer to remap collections based on platform options.
  • Pass collectionOverride for the dark-dimmed, dark-high-contrast, and light-high-contrast base scale builds in buildFigma.ts.
  • Add unit tests covering collectionOverride behavior in figmaAttributes.
Show a summary per file
File Description
src/transformers/figmaAttributes.ts Remaps collection (and default group) via optional collectionOverride map.
src/transformers/figmaAttributes.test.ts Adds coverage for collection remapping + group preservation + mode selection.
scripts/buildFigma.ts Supplies collectionOverride for affected base scale configs and passes it into the figma platform initializer.
package-lock.json Updates package version metadata in the lockfile.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comments suppressed due to low confidence (1)

scripts/buildFigma.ts:44

  • collectionOverride maps to base/color/dark-high-contrast, but this base scale entry is named dark-high-constrast (typo). This yields an inconsistent output filename vs collection name; consider renaming the base scale name/theme to dark-high-contrast.
      collectionOverride: {'base/color/dark': 'base/color/dark-high-contrast'},
  • Files reviewed: 3/4 changed files
  • Comments generated: 1

Comment thread scripts/buildFigma.ts Resolved
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
github-actions Bot temporarily deployed to Preview (Storybook) April 20, 2026 08:18 Inactive
@lukasoppermann
lukasoppermann merged commit 4f52045 into main Apr 20, 2026
27 checks passed
@lukasoppermann
lukasoppermann deleted the fix/figma-base-scale-collection-override branch April 20, 2026 08:21
@primer primer Bot mentioned this pull request Apr 20, 2026

This branch was successfully deployed

1 active and 1 inactive deployments
Preview (Storybook) — a642e86d Deployed Apr 20, 2026 by github-actions[bot]
github-pages — a642e86d Deployed Apr 20, 2026 by lukasoppermann via Build and deploy / Deploy #4055
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