Conversation
🦋 Changeset detectedLatest commit: 7627b95 The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types 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 |
|
Preview deployments for this pull request: storybook - themebuilder - |
c64020f to
e9d823e
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Collection grouping can fail for inherited object keys, and the new generation script does not reliably await or target its output.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Centralizes Figma collection modeling and simplifies the plugin preview by rendering validated configuration directly.
Changes:
- Adds shared Figma collection and token-model utilities.
- Reworks plugin preview, import state, and color/radius rendering.
- Centralizes color-scale generation with expanded tests.
File summaries
| File | Description |
|---|---|
plugins/designsystemet/src/ui/preview-view.tsx |
Adds config-based preview UI. |
plugins/designsystemet/src/ui/preview-data.tsx |
Removes token-based preview. |
plugins/designsystemet/src/ui/border-radius.ts |
Adds radius formula evaluation. |
plugins/designsystemet/src/ui/app.tsx |
Updates preview and export state. |
plugins/designsystemet/src/ui/app.css |
Uses spacing tokens. |
plugins/designsystemet/src/types.ts |
Updates UI message types. |
plugins/designsystemet/src/plugin/token-export/utils.ts |
Removes obsolete preview utilities. |
plugins/designsystemet/src/plugin/token-export/types.ts |
Introduces export-side token model. |
plugins/designsystemet/src/plugin/token-export/text-styles.ts |
Consumes the token model. |
plugins/designsystemet/src/plugin/token-export/resolver.ts |
Adds lazy token lookup. |
plugins/designsystemet/src/plugin/token-export/preview-model.ts |
Builds grouped export model. |
plugins/designsystemet/src/plugin/token-export/importer.ts |
Imports from the token model. |
plugins/designsystemet/src/plugin/token-export/effect-styles.ts |
Updates effect-style model usage. |
plugins/designsystemet/src/plugin/token-export/color.ts |
Removes preview-only color conversion. |
plugins/designsystemet/src/plugin/token-export/collection-specs.ts |
Uses shared Figma modes. |
plugins/designsystemet/src/plugin/code.ts |
Reworks token generation messaging. |
plugins/designsystemet/README.md |
Adds override example. |
plugins/designsystemet/package.json |
Adjusts watch commands. |
packages/cli/src/tokens/utils.ts |
Reuses centralized severity logic. |
packages/cli/src/tokens/utils.test.ts |
Removes relocated tests. |
packages/cli/src/tokens/create/generators/primitives/color-scheme.ts |
Reuses shared scale generation. |
packages/cli/src/tokens/create/generators/primitives/color-scheme.test.ts |
Removes relocated tests. |
packages/cli/src/tokens/create/figma-collections.ts |
Adds collection transformation API. |
packages/cli/src/tokens/create/figma-collections.test.ts |
Tests grouping and merging. |
packages/cli/src/tokens/create.ts |
Exports collection utilities. |
packages/cli/src/scripts/make-figma-collection.ts |
Adds collection-generation script. |
packages/cli/src/colors/scale.ts |
Centralizes resolved color scales. |
packages/cli/src/colors/scale.test.ts |
Tests color override behavior. |
packages/cli/package.json |
Exposes the new script. |
.changeset/light-cloths-film.md |
Adds an empty changeset marker. |
Review details
Suppressed comments (2)
packages/cli/src/scripts/make-figma-collection.ts:66
- The filesystem is initialized with
tempas its output directory, but this explicit../tempbypasses that configuration and writes underpackages/tempwhen the package script runs. Pass the initialized output directory instead.
'../temp',
packages/cli/src/scripts/make-figma-collection.ts:121
- The top-level async operation is started without being awaited, so generation failures are detached from the script entry point. Top-level await ensures the command completes only after generation and propagates failures reliably.
_toFigmaCollection({ ...validatedConfig, outDir: '' });
- Files reviewed: 30/30 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
c950112 to
304f084
Compare
304f084 to
b01b399
Compare
3136bff to
c5b7912
Compare
c5b7912 to
e333929
Compare
39b22cd to
c4ef374
Compare
10aa26c to
08cbf65
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Token-set precedence and disabled-set handling are incorrect, while preview controls and the new collection script contain functional regressions.
Get a fresh assessment by requesting another Copilot review.
Review details
Suppressed comments (2)
packages/cli/src/scripts/make-figma-collection.ts:59
writeFilesis asynchronous, but its promise is discarded. The script therefore prints its completion message before the output is written, and write failures are detached from this operation. Await the write before reporting success.
dsfs.writeFiles(
plugins/designsystemet/src/plugin/token-export/collection-specs.ts:153
resolveTokenValuereturns the first matching set, but this inserts mode sets in forward order. That reversestoFigmaCollections' documented merge semantics where later selected sets override earlier ones, and disabled sets can also win resolution. Prioritize non-disabled sets from last to first.
for (const selected of mode.tokenSets) {
if (selected.exists) {
prioritized.add(selected.tokenSet);
}
- Files reviewed: 37/37 changed files
- Comments generated: 3
- Review effort level: Balanced
029ced4 to
dd167aa
Compare
rewriting how logic is handeled internally with model used for importing to Figma Variables.
Summary
Reworks how the Figma plugin turns a
designsystemet.config.jsoninto Figma variables. The grouping of$themes.jsoninto Figma collections now lives in the CLI and is shared with the plugin through a new@digdir/designsystemet/internalentry, the plugin's export model is rebuilt around it, and the plugin UI previews straight from the validated config instead of from a separate preview data structure.CLI (
@digdir/designsystemet)src/figma/collections.tswithtoFigmaCollections(), which groups$themesentries into Figma collections and modes and deep-merges each mode's token sets.FIGMA_COLLECTIONholds the collection names (Theme,Color scheme,Semantic,Color,Size,Typography) and is now used by the$themesgenerator too, so the CLI and the plugin can not disagree on them. Comes with unit tests../internalexport (src/internal.ts) for utilities other Designsystemet apps consume. It re-exports the Figma collection helpers and types, plusgetThemeColorScales. These are not part of the publictokens/createorcolorentries.getThemeColorScales()in the color-scheme generator resolves a theme's color scales for one scheme with severity and per-scheme color overrides applied.generateColorSchemeuses it, and the plugin preview uses the same function so it shows exactly the colors the tokens end up with.groupBySchemeandaddSeverityColorsstay where they were.Figma plugin (
@plugin/designsystemet)token-export/preview-model.tsis replaced bytoken-model.ts, which builds aTokenModelfrom token sets and$themesusing the CLI'stoFigmaCollections. The plugin-localconstants.tscollection names are gone in favour ofFIGMA_COLLECTION. Types renamed to say what they are:ModePreview→CollectionMode,CollectionPreview→CollectionVariables.Main color/Support colormigration-state detection. It applies to the current collection set only.ConfigSchema(colors, border radii, fonts) rather than a preview model posted from the plugin side.preview-data.tsxis replaced bypreview-view.tsxplus a smallborder-radius.tsthat evaluates the radius step formulas for display. The paste view is its ownpaste-view.tsx. CSS classes lost thetx-prefix, generic row classes were renamed, redundant backgrounds and a dead rule were removed, and hardcoded values use--ds-*tokens.--watchreaches Vite.overridesblock.Changesets
@plugin/designsystemetjoins the fixed version group so it follows the same version as the published packages.privatePackagesis set to version but not tag, andchangeset publishstill skips it because it is private.Verification
figma/collectionsandgetThemeColorScalestests.pnpm build:cliandpnpm update:themeproduce no changes indesign-tokens/or the built theme CSS.tscstill reports the pre-existingschemas/internal/schema.jsimport that does not exist on this branch.Stack created with GitHub Stacks CLI • Give Feedback 💬