Theme: Repurpose Figma token plugin to extract JSON override files for modes#73860
Theme: Repurpose Figma token plugin to extract JSON override files for modes#73860
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: 0 B Total Size: 2.58 MB ℹ️ View Unchanged
|
|
Flaky tests detected in f9738d9. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/20080110474
|
|
Importing modes works :) |
mirka
left a comment
There was a problem hiding this comment.
I was able to import the dimension files into Figma as expected 👍 I'll note that it didn't work for border though, which Claude suspected was because it wasn't referencing an alias to a primitive token? I didn't investigate because I know we won't be needing a high-DPI mode in Figma, but may resurface as a problem in a future use case.
ab6c2c3 to
eb3aa94
Compare
Good catch! It's possible to do some light troubleshooting in Figma by opening DevTools (Command+Option+I), where I can see this error:
In earlier iterations, my AI coding companion had included some code to manage I'll see about adding that back. |
f9738d9 to
36cd8a6
Compare
|
Updated to include I confirmed this addressed the errors importing border mode overrides in Figma:
|
36cd8a6 to
a8ff486
Compare
| const filePath = fileURLToPath( filename ); | ||
| const outFile = join( | ||
| dirname( filePath ), | ||
| 'modes', | ||
| `${ basename( filePath, '.json' ) }.${ mode }.json` | ||
| ); | ||
| outputFile( outFile, JSON.stringify( output, null, '\t' ) ); |
There was a problem hiding this comment.
Note that this seems to break the CI static analysis checks on Windows; I'm exploring a workaround in #73911


What?
Builds on #73858 and #73859
Updates the theme package to remove the custom "Figma" plugin that generates a proprietary
figma.jsonfile, in favor of a generalized plugin that emits override values for modes (e.g. densities like "compact", etc.).In turn, this can be used within Figma token import workflows to define mode values, in a way which is more generalized, closer to the original DTCG specification, and more future compatible with expected support for DTCG Resolvers.
Why?
How?
modesoverrides from the source files and emits a separate JSON file for each, containing only the values that override the defaults.Testing Instructions
Verify there are no local changes to commit after running
npm run --workspace @wordpress/theme build.Observe that the values in
packages/theme/tokens/modes/dimension.comfortable.jsonaccurately reflect the$extensions.mode.comfortablevalues frompackages/theme/tokens/dimension.json.If you have a Figma subscription, you can also repeat the workflow shown in the screencast below to use these mode values in imported Variables.
Screenshots or screencast
figma-import.mov