Skip to content

Register wp-theme design tokens stylesheet#12564

Open
roshniahuja wants to merge 1 commit into
WordPress:trunkfrom
roshniahuja:65646-register-wp-theme-design-tokens-stylesheet
Open

Register wp-theme design tokens stylesheet#12564
roshniahuja wants to merge 1 commit into
WordPress:trunkfrom
roshniahuja:65646-register-wp-theme-design-tokens-stylesheet

Conversation

@roshniahuja

Copy link
Copy Markdown

Trac ticket

Fixes https://core.trac.wordpress.org/ticket/65646

Summary

The wp-theme JS package is registered in Core, but its accompanying design tokens stylesheet was only registered in the Gutenberg plugin. Without the stylesheet, token-consuming styles may see undefined values. Although first-party usage injects fallback values at build time, the intended behaviour is that the design tokens stylesheet is actually loaded wherever design tokens are used.

Changes

In wp_default_styles():

  • Register a theme package style pointing to /wp-includes/css/dist/theme/design-tokens$suffix.css (special-cased like base-styles, since the filename is not the default style.css).
  • Add wp-theme as a dependency of wp-components so token values are defined before the consuming styles reference them.
  • Load wp-theme first among the editor (wp-edit-blocks) dependencies, and add it to the RTL styles list for consistency with the other package styles.

This mirrors the Gutenberg plugin setup.

Unit tests were added to tests/phpunit/tests/dependencies/styles.php covering registration of the handle/src, the wp-components dependency, and the editor style ordering.

Note for reviewers

The registered file css/dist/theme/design-tokens.css is synced from the Gutenberg build (like all other css/dist/* assets), so a Gutenberg version bump that outputs the theme/ styles directory must precede or accompany this change. Until then the handle resolves to a file that is not yet present in Core.

Testing instructions

  1. Run the dependency tests: phpunit tests/phpunit/tests/dependencies/styles.php.
  2. Confirm the wp-theme handle is registered and that wp-components and wp-edit-blocks depend on it.

The `wp-theme` JS package is registered in Core, but its accompanying
design tokens stylesheet was only registered in the Gutenberg plugin.
Without it, token-consuming styles could see undefined values.

Register a `theme` package style in `wp_default_styles()` pointing to
`/wp-includes/css/dist/theme/design-tokens.css`, add it as a dependency
of `wp-components`, and load it first among the editor styles so token
values resolve before consuming rules. Mirrors the Gutenberg setup.

Add unit tests covering registration, the `wp-components` dependency,
and the editor style ordering.

Fixes #65646.
@github-actions

Copy link
Copy Markdown

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props roshniahuja14.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

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.

1 participant