Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/base-styles/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

@use "sass:color";
@use "sass:math";
@use "@wordpress/theme/src/prebuilt/scss/design-token-fallbacks" as wpds;
@use "@wordpress/theme/design-token-fallbacks" as wpds;
@use "./variables";
@use "./colors";
@use "./breakpoints";
Expand Down
10 changes: 3 additions & 7 deletions packages/theme/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,13 @@ An alternative to loading the [design tokens stylesheet](#outside-wordpress), us

You do not need this helper if you already load the design tokens stylesheet or use fallback injection via the build plugins or `@wordpress/build`. In those cases, write bare `var(--wpds-*)` references in your source.

The `@wordpress/theme/design-token-fallbacks` export provides a generated `wpds-var()` function that wraps token references with the same fallback map used by the build plugins — for example, `wpds.wpds-var('--wpds-color-fg-content-neutral')` compiles to `var(--wpds-color-fg-content-neutral, #1e1e1e)`.
The `@wordpress/theme/design-token-fallbacks` export provides a generated `wpds-var()` function that wraps token references with the same fallback map used by the build plugins. For example, `wpds.wpds-var('--wpds-color-foreground-content-neutral')` compiles to `var(--wpds-color-foreground-content-neutral, #1e1e1e)`.

```scss
@use '@wordpress/theme/design-token-fallbacks' as wpds;

.example {
color: wpds.wpds-var( '--wpds-color-fg-content-neutral' );
color: wpds.wpds-var( '--wpds-color-foreground-content-neutral' );
}
```

Expand All @@ -330,11 +330,7 @@ When using Sass with [`NodePackageImporter`](https://sass-lang.com/documentation
@use 'pkg:@wordpress/theme/design-token-fallbacks' as wpds;
```

For Sass setups that resolve packages from `node_modules` with a load path, use:

```scss
@use '@wordpress/theme/src/prebuilt/scss/design-token-fallbacks' as wpds;
```
The same `@wordpress/theme/design-token-fallbacks` import also supports Sass setups that resolve packages from `node_modules` with a load path.

## Contributing to this package

Expand Down
1 change: 1 addition & 0 deletions packages/theme/design-token-fallbacks.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@forward "./src/prebuilt/scss/design-token-fallbacks";

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.

TIL @forward

5 changes: 4 additions & 1 deletion packages/theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"build",
"build-module",
"build-types",
"design-token-fallbacks.scss",
"*.md"
],
"main": "build/index.cjs",
Expand All @@ -38,7 +39,9 @@
"default": "./build/index.cjs"
},
"./design-tokens.css": "./src/prebuilt/css/design-tokens.css",
"./design-token-fallbacks": "./src/prebuilt/scss/design-token-fallbacks.scss",
"./design-token-fallbacks": {
"sass": "./design-token-fallbacks.scss"
},
"./design-tokens.js": {
"types": "./build-types/prebuilt/js/design-tokens.d.ts",
"import": "./build-module/prebuilt/js/design-tokens.mjs",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ $fallbacks: (
'--wpds-color-stroke-surface-warning': '#e1bc7c',
'--wpds-color-stroke-surface-warning-strong': '#926300',
'--wpds-cursor-control': 'pointer',
'--wpds-dimension-base': '4px',
'--wpds-dimension-gap-2xl': '32px',
'--wpds-dimension-gap-3xl': '40px',
'--wpds-dimension-gap-lg': '16px',
Expand Down
Loading