Base Styles: Add wpds-var Sass helper for design token fallbacks#78698
Conversation
|
Size Change: +10.5 kB (+0.14%) Total Size: 7.52 MB 📦 View Changed
|
|
Flaky tests detected in ded1182. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/28006845124
|
|
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. |
ciampo
left a comment
There was a problem hiding this comment.
LGTM 🚀
Pre-approving since the approach is solid (and I won't be around for a few days). Feel free to merge once feedback is addressed
…cks (#78698)" (#79429) This reverts commit 5439c7c. Co-authored-by: mirka <[email protected]>
* Reapply "Base Styles: Add wpds-var Sass helper for design token fallbacks (#78698)" (#79429) This reverts commit 3031bb0. * Theme: Add Sass fallback helper root entrypoint (#79471) * Theme: Add Sass fallback helper shim * Theme: Fix Sass fallback helper imports * Theme: Remove fallback Sass export conditions Co-authored-by: mirka <[email protected]> Co-authored-by: ciampo <[email protected]> Co-authored-by: aduth <[email protected]> * Fix focus ring docblock formatting * Update Sass token utility entrypoint * Add changelog --------- Co-authored-by: ciampo <[email protected]> Co-authored-by: aduth <[email protected]> Co-authored-by: mirka <[email protected]> Co-authored-by: simison <[email protected]>
* Reapply "Base Styles: Add wpds-var Sass helper for design token fallbacks (WordPress#78698)" (WordPress#79429) This reverts commit 3031bb0. * Theme: Add Sass fallback helper root entrypoint (WordPress#79471) * Theme: Add Sass fallback helper shim * Theme: Fix Sass fallback helper imports * Theme: Remove fallback Sass export conditions Co-authored-by: mirka <[email protected]> Co-authored-by: ciampo <[email protected]> Co-authored-by: aduth <[email protected]> * Fix focus ring docblock formatting * Update Sass token utility entrypoint * Add changelog --------- Co-authored-by: ciampo <[email protected]> Co-authored-by: aduth <[email protected]> Co-authored-by: mirka <[email protected]> Co-authored-by: simison <[email protected]>
What?
wpds-var()helper from the existing design token fallback map in@wordpress/theme.@wordpress/theme/design-token-fallbacks.outset-ring__focusmixin to@wordpress/base-stylesthat use the helper.Why?
As
@wordpress/base-stylesadopts--wpds-*design tokens, it would be best if third-party Sass consumers didn't need to change their build setup with PostCSS build plugins or a loaded tokens stylesheet. Willing early adopters of design tokens can be expected to change their build setup to support it, but base-styles consumers never asked to use design tokens. So we should try not to disturb their build setup if possible.This is kind of like the JS/CSS build-time fallback injection, but for Sass library code.
How?
ds-token-fallbacksplugin to emitsrc/prebuilt/scss/design-token-fallbacks.scssalongside the existing JS map.wpds-var($token)function that wrapsvar(--wpds-*, <fallback>)using the generated map.@wordpress/themeas a dependency of@wordpress/base-styles._mixins.scssvia@use "@wordpress/theme/src/prebuilt/scss/design-token-fallbacks" as wpds(legacy Sass resolution).NodePackageImportercan also use@use 'pkg:@wordpress/theme/design-token-fallbacks' as wpds.Testing Instructions
Try using the new mixin in a
@wordpress/componentscomponent, and see in dev tools how the fallbacks for the focus styles are present in Storybook.Here's a handy diff for Button: