-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Register wp-theme design tokens stylesheet #12560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1721,6 +1721,7 @@ function wp_default_styles( $styles ) { | |
|
|
||
| // Only add CONTENT styles here that should be enqueued in the iframe! | ||
| $wp_edit_blocks_dependencies = array( | ||
| 'wp-theme', | ||
| 'wp-base-styles', | ||
| 'wp-components', | ||
| /* | ||
|
|
@@ -1761,8 +1762,9 @@ function wp_default_styles( $styles ) { | |
| 'block-editor' => array( 'wp-components', 'wp-preferences' ), | ||
| 'block-library' => array(), | ||
| 'block-directory' => array(), | ||
| 'theme' => array(), | ||
| 'base-styles' => array(), | ||
| 'components' => array(), | ||
| 'components' => array( 'wp-theme' ), | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technically, any stylesheet that uses design tokens directly should have In real life, I've found that the minimal setup proposed in this PR basically covers everything, given the prevalence of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mhh, that's a true concern, but with a low probability of being an actual issue. In the currently pinned Gutenberg build, Its generated CSS currently includes token fallbacks, and Core enqueues it in the block-editor context where
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like Obviously not something we can do right away, but maybe to consider in the future to mitigate the impact.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
wp-build does have a basic form of style dep inference actually. It won't quite work with wp-theme, mostly because a consumer has no need to declare |
||
| 'commands' => array( 'wp-components' ), | ||
| 'edit-post' => array( | ||
| 'wp-components', | ||
|
|
@@ -1829,6 +1831,10 @@ function wp_default_styles( $styles ) { | |
| $path = "/wp-includes/css/dist/base-styles/admin-schemes$suffix.css"; | ||
| } | ||
|
|
||
| if ( 'theme' === $package ) { | ||
| $path = "/wp-includes/css/dist/theme/design-tokens$suffix.css"; | ||
| } | ||
|
|
||
| $styles->add( $handle, $path, $dependencies ); | ||
| $styles->add_data( $handle, 'path', ABSPATH . $path ); | ||
| } | ||
|
|
@@ -1872,6 +1878,7 @@ function wp_default_styles( $styles ) { | |
| 'wp-reset-editor-styles', | ||
| 'wp-editor-classic-layout-styles', | ||
| 'wp-block-library-theme', | ||
| 'wp-theme', | ||
| 'wp-edit-blocks', | ||
| 'wp-block-editor', | ||
| 'wp-block-library', | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -557,6 +557,55 @@ public function test_block_styles_for_viewing_with_split_styles() { | |||||||||
| ); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * Tests that the design tokens stylesheet is registered in core. | ||||||||||
| * | ||||||||||
| * @ticket 65646 | ||||||||||
| * | ||||||||||
| * @covers ::wp_default_styles | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Add |
||||||||||
| */ | ||||||||||
| public function test_wp_theme_style_is_registered() { | ||||||||||
| wp_default_styles( $GLOBALS['wp_styles'] ); | ||||||||||
|
|
||||||||||
| $this->assertArrayHasKey( 'wp-theme', $GLOBALS['wp_styles']->registered ); | ||||||||||
| $this->assertSame( | ||||||||||
| '/' . WPINC . '/css/dist/theme/design-tokens.css', | ||||||||||
| $GLOBALS['wp_styles']->registered['wp-theme']->src | ||||||||||
| ); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * Tests that wp-components depends on wp-theme so tokens load before component styles. | ||||||||||
| * | ||||||||||
| * @ticket 65646 | ||||||||||
| * | ||||||||||
| * @covers ::wp_default_styles | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| */ | ||||||||||
| public function test_wp_components_depends_on_wp_theme() { | ||||||||||
| wp_default_styles( $GLOBALS['wp_styles'] ); | ||||||||||
|
|
||||||||||
| $this->assertContains( | ||||||||||
| 'wp-theme', | ||||||||||
| $GLOBALS['wp_styles']->registered['wp-components']->deps | ||||||||||
| ); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * Tests that wp-edit-blocks loads design tokens before other editor styles. | ||||||||||
| * | ||||||||||
| * @ticket 65646 | ||||||||||
| * | ||||||||||
| * @covers ::wp_default_styles | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| */ | ||||||||||
| public function test_wp_edit_blocks_depends_on_wp_theme_first() { | ||||||||||
| wp_default_styles( $GLOBALS['wp_styles'] ); | ||||||||||
|
|
||||||||||
| $deps = $GLOBALS['wp_styles']->registered['wp-edit-blocks']->deps; | ||||||||||
|
|
||||||||||
| $this->assertContains( 'wp-theme', $deps ); | ||||||||||
| $this->assertSame( 0, array_search( 'wp-theme', $deps, true ) ); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * @ticket 58394 | ||||||||||
| * @ticket 63887 | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why
theme?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The package name where the stylesheet originates is
@wordpress/theme.