Skip to content
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

Global styles revisions: ensure that user-defined variation styles CSS is generated #62768

Merged
merged 10 commits into from
Jun 27, 2024

Conversation

ramonjd
Copy link
Member

@ramonjd ramonjd commented Jun 23, 2024

What?

Hi.

Global styles revisions should output block style variations CSS if the revision contains variations styles. This PR does that.

TODO

  • E2E tests

How?

By rendering the editor styles after the block list has rendered, at which the variation overrides are in the state and, therefore, accessible.

Then, using the current revision history config , grabbing the blocks' current style overrides, regenerating them using the current revision config, and re-registering them via useStyleOverride.

Why?

A bit of code quality as it makes room for future, additional properties, but also to fix a bug where the CSS for user-edited style variations in the global styles CPT/revisions aren't generated in the global styles revisions preview.

To generate style variation overrides, the style overrides CSS is generated using the global styles config in the useBlockProps hook.

However, the revision history contains multiple versions of the global styles config that need to be swapped in and out dynamically.

Testing Instructions

  1. Register a custom block style variation, under /styles e.g., /styles/white-fang.json
{
	"$schema": "https://schemas.wp.org/trunk/theme.json",
	"version": 3,
	"title": "White fang",
	"blockTypes": [
		"core/group",
		"core/image",
		"core/columns"
	],
	"styles": {
		"color": {
			"background": "yellow"
		},
		"border": {
			"radius": "1111px",
			"width": "10px",
			"color": "red",
			"style": "solid"
		},
		"blocks": {
			"core/paragraph": {
				"border": {
					"width": "0"
				},
				"color": {
					"background": "aliceblue",
					"text": "purple"
				}
			}
		}
	}
}
  1. In the Site Editor, add a Group block and apply the White fang block style variation.
  2. Then open the global styles panel for Group blocks and make a few edits to the White fang block style variation, saving each time.
  3. Open the Styles revisions panel and preview your revisions. The changes to your style variation should be reflected for each revision are reflected on your Group block.
  4. Check that there are no regressions to Global Styles: Prevent duplicate block style variations CSS #62465 (no duplicate CSS declarations for style variations in the editor)
  5. Also please check that the variations appear correctly in the post editor and frontend.

Thank you!

Screenshots or screencast

Kapture.2024-06-24.at.15.39.10.mp4

@ramonjd ramonjd added [Type] Bug An existing feature does not function as intended [Feature] Theme Style Variations Related to style variations provided by block themes Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Jun 23, 2024
@ramonjd ramonjd requested a review from ellatrix as a code owner June 23, 2024 01:36
Copy link

github-actions bot commented Jun 23, 2024

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.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>

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

@@ -56,7 +56,9 @@ function Revisions( { userConfig, blocks } ) {
[ originalSettings ]
);

const [ globalStyles ] = useGlobalStylesOutputWithConfig( mergedConfig );
const [ globalStyles ] = useGlobalStylesOutputWithConfig( mergedConfig, {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing the Style Book should also render these variations styles:

const [ globalStyles ] = useGlobalStylesOutputWithConfig( mergedConfig );

I tried it quickly, but I'm not yet sure it's enough - the preview doesn't render the style variation CSS, or update it when editing the global block styles.

Could be missing something. I'll look next week. Might be a different PR.

Copy link

github-actions bot commented Jun 23, 2024

Size Change: +430 B (+0.02%)

Total Size: 1.76 MB

Filename Size Change
build/block-editor/index.min.js 265 kB +380 B (+0.14%)
build/edit-site/index.min.js 208 kB +50 B (+0.02%)
ℹ️ View Unchanged
Filename Size
build/a11y/index.min.js 951 B
build/annotations/index.min.js 2.26 kB
build/api-fetch/index.min.js 2.31 kB
build/autop/index.min.js 2.12 kB
build/blob/index.min.js 579 B
build/block-directory/index.min.js 7.31 kB
build/block-directory/style-rtl.css 1.01 kB
build/block-directory/style.css 1.01 kB
build/block-editor/content-rtl.css 4.57 kB
build/block-editor/content.css 4.57 kB
build/block-editor/default-editor-styles-rtl.css 394 B
build/block-editor/default-editor-styles.css 394 B
build/block-editor/style-rtl.css 15.7 kB
build/block-editor/style.css 15.7 kB
build/block-library/blocks/archives/editor-rtl.css 61 B
build/block-library/blocks/archives/editor.css 60 B
build/block-library/blocks/archives/style-rtl.css 90 B
build/block-library/blocks/archives/style.css 90 B
build/block-library/blocks/audio/editor-rtl.css 149 B
build/block-library/blocks/audio/editor.css 151 B
build/block-library/blocks/audio/style-rtl.css 132 B
build/block-library/blocks/audio/style.css 132 B
build/block-library/blocks/audio/theme-rtl.css 134 B
build/block-library/blocks/audio/theme.css 134 B
build/block-library/blocks/avatar/editor-rtl.css 115 B
build/block-library/blocks/avatar/editor.css 115 B
build/block-library/blocks/avatar/style-rtl.css 104 B
build/block-library/blocks/avatar/style.css 104 B
build/block-library/blocks/button/editor-rtl.css 310 B
build/block-library/blocks/button/editor.css 310 B
build/block-library/blocks/button/style-rtl.css 538 B
build/block-library/blocks/button/style.css 538 B
build/block-library/blocks/buttons/editor-rtl.css 336 B
build/block-library/blocks/buttons/editor.css 336 B
build/block-library/blocks/buttons/style-rtl.css 328 B
build/block-library/blocks/buttons/style.css 328 B
build/block-library/blocks/calendar/style-rtl.css 240 B
build/block-library/blocks/calendar/style.css 240 B
build/block-library/blocks/categories/editor-rtl.css 113 B
build/block-library/blocks/categories/editor.css 112 B
build/block-library/blocks/categories/style-rtl.css 124 B
build/block-library/blocks/categories/style.css 124 B
build/block-library/blocks/code/editor-rtl.css 53 B
build/block-library/blocks/code/editor.css 53 B
build/block-library/blocks/code/style-rtl.css 121 B
build/block-library/blocks/code/style.css 121 B
build/block-library/blocks/code/theme-rtl.css 122 B
build/block-library/blocks/code/theme.css 122 B
build/block-library/blocks/columns/editor-rtl.css 108 B
build/block-library/blocks/columns/editor.css 108 B
build/block-library/blocks/columns/style-rtl.css 420 B
build/block-library/blocks/columns/style.css 420 B
build/block-library/blocks/comment-author-avatar/editor-rtl.css 124 B
build/block-library/blocks/comment-author-avatar/editor.css 124 B
build/block-library/blocks/comment-content/style-rtl.css 90 B
build/block-library/blocks/comment-content/style.css 90 B
build/block-library/blocks/comment-template/style-rtl.css 200 B
build/block-library/blocks/comment-template/style.css 199 B
build/block-library/blocks/comments-pagination-numbers/editor-rtl.css 122 B
build/block-library/blocks/comments-pagination-numbers/editor.css 121 B
build/block-library/blocks/comments-pagination/editor-rtl.css 221 B
build/block-library/blocks/comments-pagination/editor.css 211 B
build/block-library/blocks/comments-pagination/style-rtl.css 234 B
build/block-library/blocks/comments-pagination/style.css 231 B
build/block-library/blocks/comments-title/editor-rtl.css 75 B
build/block-library/blocks/comments-title/editor.css 75 B
build/block-library/blocks/comments/editor-rtl.css 832 B
build/block-library/blocks/comments/editor.css 832 B
build/block-library/blocks/comments/style-rtl.css 632 B
build/block-library/blocks/comments/style.css 631 B
build/block-library/blocks/cover/editor-rtl.css 668 B
build/block-library/blocks/cover/editor.css 669 B
build/block-library/blocks/cover/style-rtl.css 1.62 kB
build/block-library/blocks/cover/style.css 1.6 kB
build/block-library/blocks/details/editor-rtl.css 65 B
build/block-library/blocks/details/editor.css 65 B
build/block-library/blocks/details/style-rtl.css 86 B
build/block-library/blocks/details/style.css 86 B
build/block-library/blocks/embed/editor-rtl.css 314 B
build/block-library/blocks/embed/editor.css 314 B
build/block-library/blocks/embed/style-rtl.css 419 B
build/block-library/blocks/embed/style.css 419 B
build/block-library/blocks/embed/theme-rtl.css 133 B
build/block-library/blocks/embed/theme.css 133 B
build/block-library/blocks/file/editor-rtl.css 326 B
build/block-library/blocks/file/editor.css 326 B
build/block-library/blocks/file/style-rtl.css 278 B
build/block-library/blocks/file/style.css 279 B
build/block-library/blocks/file/view.min.js 324 B
build/block-library/blocks/footnotes/style-rtl.css 198 B
build/block-library/blocks/footnotes/style.css 197 B
build/block-library/blocks/form-input/editor-rtl.css 229 B
build/block-library/blocks/form-input/editor.css 229 B
build/block-library/blocks/form-input/style-rtl.css 342 B
build/block-library/blocks/form-input/style.css 342 B
build/block-library/blocks/form-submission-notification/editor-rtl.css 344 B
build/block-library/blocks/form-submission-notification/editor.css 341 B
build/block-library/blocks/form-submit-button/style-rtl.css 69 B
build/block-library/blocks/form-submit-button/style.css 69 B
build/block-library/blocks/form/view.min.js 470 B
build/block-library/blocks/freeform/editor-rtl.css 2.6 kB
build/block-library/blocks/freeform/editor.css 2.6 kB
build/block-library/blocks/gallery/editor-rtl.css 958 B
build/block-library/blocks/gallery/editor.css 962 B
build/block-library/blocks/gallery/style-rtl.css 1.71 kB
build/block-library/blocks/gallery/style.css 1.71 kB
build/block-library/blocks/gallery/theme-rtl.css 108 B
build/block-library/blocks/gallery/theme.css 108 B
build/block-library/blocks/group/editor-rtl.css 402 B
build/block-library/blocks/group/editor.css 402 B
build/block-library/blocks/group/style-rtl.css 103 B
build/block-library/blocks/group/style.css 103 B
build/block-library/blocks/group/theme-rtl.css 79 B
build/block-library/blocks/group/theme.css 79 B
build/block-library/blocks/heading/style-rtl.css 188 B
build/block-library/blocks/heading/style.css 188 B
build/block-library/blocks/html/editor-rtl.css 346 B
build/block-library/blocks/html/editor.css 347 B
build/block-library/blocks/image/editor-rtl.css 845 B
build/block-library/blocks/image/editor.css 843 B
build/block-library/blocks/image/style-rtl.css 1.54 kB
build/block-library/blocks/image/style.css 1.54 kB
build/block-library/blocks/image/theme-rtl.css 137 B
build/block-library/blocks/image/theme.css 137 B
build/block-library/blocks/image/view.min.js 1.54 kB
build/block-library/blocks/latest-comments/style-rtl.css 355 B
build/block-library/blocks/latest-comments/style.css 354 B
build/block-library/blocks/latest-posts/editor-rtl.css 204 B
build/block-library/blocks/latest-posts/editor.css 204 B
build/block-library/blocks/latest-posts/style-rtl.css 509 B
build/block-library/blocks/latest-posts/style.css 510 B
build/block-library/blocks/list/style-rtl.css 104 B
build/block-library/blocks/list/style.css 104 B
build/block-library/blocks/media-text/editor-rtl.css 304 B
build/block-library/blocks/media-text/editor.css 303 B
build/block-library/blocks/media-text/style-rtl.css 516 B
build/block-library/blocks/media-text/style.css 515 B
build/block-library/blocks/more/editor-rtl.css 427 B
build/block-library/blocks/more/editor.css 427 B
build/block-library/blocks/navigation-link/editor-rtl.css 663 B
build/block-library/blocks/navigation-link/editor.css 664 B
build/block-library/blocks/navigation-link/style-rtl.css 192 B
build/block-library/blocks/navigation-link/style.css 191 B
build/block-library/blocks/navigation-submenu/editor-rtl.css 295 B
build/block-library/blocks/navigation-submenu/editor.css 294 B
build/block-library/blocks/navigation/editor-rtl.css 2.2 kB
build/block-library/blocks/navigation/editor.css 2.21 kB
build/block-library/blocks/navigation/style-rtl.css 2.26 kB
build/block-library/blocks/navigation/style.css 2.25 kB
build/block-library/blocks/navigation/view.min.js 1.03 kB
build/block-library/blocks/nextpage/editor-rtl.css 392 B
build/block-library/blocks/nextpage/editor.css 392 B
build/block-library/blocks/page-list/editor-rtl.css 378 B
build/block-library/blocks/page-list/editor.css 378 B
build/block-library/blocks/page-list/style-rtl.css 175 B
build/block-library/blocks/page-list/style.css 175 B
build/block-library/blocks/paragraph/editor-rtl.css 236 B
build/block-library/blocks/paragraph/editor.css 236 B
build/block-library/blocks/paragraph/style-rtl.css 341 B
build/block-library/blocks/paragraph/style.css 340 B
build/block-library/blocks/post-author/style-rtl.css 175 B
build/block-library/blocks/post-author/style.css 176 B
build/block-library/blocks/post-comments-form/editor-rtl.css 96 B
build/block-library/blocks/post-comments-form/editor.css 96 B
build/block-library/blocks/post-comments-form/style-rtl.css 506 B
build/block-library/blocks/post-comments-form/style.css 506 B
build/block-library/blocks/post-content/editor-rtl.css 74 B
build/block-library/blocks/post-content/editor.css 74 B
build/block-library/blocks/post-date/style-rtl.css 62 B
build/block-library/blocks/post-date/style.css 62 B
build/block-library/blocks/post-excerpt/editor-rtl.css 71 B
build/block-library/blocks/post-excerpt/editor.css 71 B
build/block-library/blocks/post-excerpt/style-rtl.css 141 B
build/block-library/blocks/post-excerpt/style.css 141 B
build/block-library/blocks/post-featured-image/editor-rtl.css 729 B
build/block-library/blocks/post-featured-image/editor.css 726 B
build/block-library/blocks/post-featured-image/style-rtl.css 341 B
build/block-library/blocks/post-featured-image/style.css 341 B
build/block-library/blocks/post-navigation-link/style-rtl.css 215 B
build/block-library/blocks/post-navigation-link/style.css 214 B
build/block-library/blocks/post-template/editor-rtl.css 99 B
build/block-library/blocks/post-template/editor.css 98 B
build/block-library/blocks/post-template/style-rtl.css 399 B
build/block-library/blocks/post-template/style.css 398 B
build/block-library/blocks/post-terms/style-rtl.css 96 B
build/block-library/blocks/post-terms/style.css 96 B
build/block-library/blocks/post-time-to-read/style-rtl.css 70 B
build/block-library/blocks/post-time-to-read/style.css 70 B
build/block-library/blocks/post-title/style-rtl.css 100 B
build/block-library/blocks/post-title/style.css 100 B
build/block-library/blocks/preformatted/style-rtl.css 125 B
build/block-library/blocks/preformatted/style.css 125 B
build/block-library/blocks/pullquote/editor-rtl.css 134 B
build/block-library/blocks/pullquote/editor.css 134 B
build/block-library/blocks/pullquote/style-rtl.css 342 B
build/block-library/blocks/pullquote/style.css 342 B
build/block-library/blocks/pullquote/theme-rtl.css 167 B
build/block-library/blocks/pullquote/theme.css 167 B
build/block-library/blocks/query-pagination-numbers/editor-rtl.css 121 B
build/block-library/blocks/query-pagination-numbers/editor.css 118 B
build/block-library/blocks/query-pagination/editor-rtl.css 220 B
build/block-library/blocks/query-pagination/editor.css 208 B
build/block-library/blocks/query-pagination/style-rtl.css 287 B
build/block-library/blocks/query-pagination/style.css 283 B
build/block-library/blocks/query-title/style-rtl.css 64 B
build/block-library/blocks/query-title/style.css 64 B
build/block-library/blocks/query/editor-rtl.css 502 B
build/block-library/blocks/query/editor.css 502 B
build/block-library/blocks/query/view.min.js 958 B
build/block-library/blocks/quote/style-rtl.css 238 B
build/block-library/blocks/quote/style.css 238 B
build/block-library/blocks/quote/theme-rtl.css 221 B
build/block-library/blocks/quote/theme.css 225 B
build/block-library/blocks/read-more/style-rtl.css 138 B
build/block-library/blocks/read-more/style.css 138 B
build/block-library/blocks/rss/editor-rtl.css 101 B
build/block-library/blocks/rss/editor.css 101 B
build/block-library/blocks/rss/style-rtl.css 288 B
build/block-library/blocks/rss/style.css 287 B
build/block-library/blocks/search/editor-rtl.css 183 B
build/block-library/blocks/search/editor.css 183 B
build/block-library/blocks/search/style-rtl.css 672 B
build/block-library/blocks/search/style.css 671 B
build/block-library/blocks/search/theme-rtl.css 113 B
build/block-library/blocks/search/theme.css 113 B
build/block-library/blocks/search/view.min.js 475 B
build/block-library/blocks/separator/editor-rtl.css 100 B
build/block-library/blocks/separator/editor.css 100 B
build/block-library/blocks/separator/style-rtl.css 248 B
build/block-library/blocks/separator/style.css 248 B
build/block-library/blocks/separator/theme-rtl.css 195 B
build/block-library/blocks/separator/theme.css 195 B
build/block-library/blocks/shortcode/editor-rtl.css 286 B
build/block-library/blocks/shortcode/editor.css 286 B
build/block-library/blocks/site-logo/editor-rtl.css 806 B
build/block-library/blocks/site-logo/editor.css 803 B
build/block-library/blocks/site-logo/style-rtl.css 218 B
build/block-library/blocks/site-logo/style.css 218 B
build/block-library/blocks/site-tagline/editor-rtl.css 87 B
build/block-library/blocks/site-tagline/editor.css 87 B
build/block-library/blocks/site-title/editor-rtl.css 123 B
build/block-library/blocks/site-title/editor.css 123 B
build/block-library/blocks/site-title/style-rtl.css 71 B
build/block-library/blocks/site-title/style.css 71 B
build/block-library/blocks/social-link/editor-rtl.css 338 B
build/block-library/blocks/social-link/editor.css 338 B
build/block-library/blocks/social-links/editor-rtl.css 676 B
build/block-library/blocks/social-links/editor.css 675 B
build/block-library/blocks/social-links/style-rtl.css 1.5 kB
build/block-library/blocks/social-links/style.css 1.5 kB
build/block-library/blocks/spacer/editor-rtl.css 346 B
build/block-library/blocks/spacer/editor.css 346 B
build/block-library/blocks/spacer/style-rtl.css 48 B
build/block-library/blocks/spacer/style.css 48 B
build/block-library/blocks/table/editor-rtl.css 394 B
build/block-library/blocks/table/editor.css 394 B
build/block-library/blocks/table/style-rtl.css 640 B
build/block-library/blocks/table/style.css 639 B
build/block-library/blocks/table/theme-rtl.css 152 B
build/block-library/blocks/table/theme.css 152 B
build/block-library/blocks/tag-cloud/style-rtl.css 266 B
build/block-library/blocks/tag-cloud/style.css 265 B
build/block-library/blocks/template-part/editor-rtl.css 393 B
build/block-library/blocks/template-part/editor.css 393 B
build/block-library/blocks/template-part/theme-rtl.css 113 B
build/block-library/blocks/template-part/theme.css 113 B
build/block-library/blocks/term-description/style-rtl.css 108 B
build/block-library/blocks/term-description/style.css 108 B
build/block-library/blocks/text-columns/editor-rtl.css 95 B
build/block-library/blocks/text-columns/editor.css 95 B
build/block-library/blocks/text-columns/style-rtl.css 165 B
build/block-library/blocks/text-columns/style.css 165 B
build/block-library/blocks/verse/style-rtl.css 98 B
build/block-library/blocks/verse/style.css 98 B
build/block-library/blocks/video/editor-rtl.css 553 B
build/block-library/blocks/video/editor.css 554 B
build/block-library/blocks/video/style-rtl.css 192 B
build/block-library/blocks/video/style.css 192 B
build/block-library/blocks/video/theme-rtl.css 134 B
build/block-library/blocks/video/theme.css 134 B
build/block-library/classic-rtl.css 179 B
build/block-library/classic.css 179 B
build/block-library/common-rtl.css 1.1 kB
build/block-library/common.css 1.1 kB
build/block-library/editor-elements-rtl.css 75 B
build/block-library/editor-elements.css 75 B
build/block-library/editor-rtl.css 11.9 kB
build/block-library/editor.css 11.9 kB
build/block-library/elements-rtl.css 54 B
build/block-library/elements.css 54 B
build/block-library/index.min.js 219 kB
build/block-library/reset-rtl.css 472 B
build/block-library/reset.css 472 B
build/block-library/style-rtl.css 14.6 kB
build/block-library/style.css 14.6 kB
build/block-library/theme-rtl.css 702 B
build/block-library/theme.css 707 B
build/block-serialization-default-parser/index.min.js 1.12 kB
build/block-serialization-spec-parser/index.min.js 2.87 kB
build/blocks/index.min.js 52.2 kB
build/commands/index.min.js 15.2 kB
build/commands/style-rtl.css 955 B
build/commands/style.css 952 B
build/components/index.min.js 223 kB
build/components/style-rtl.css 12.1 kB
build/components/style.css 12.1 kB
build/compose/index.min.js 12.9 kB
build/core-commands/index.min.js 2.75 kB
build/core-data/index.min.js 72.6 kB
build/customize-widgets/index.min.js 10.9 kB
build/customize-widgets/style-rtl.css 1.35 kB
build/customize-widgets/style.css 1.35 kB
build/data-controls/index.min.js 641 B
build/data/index.min.js 8.99 kB
build/date/index.min.js 18 kB
build/deprecated/index.min.js 458 B
build/dom-ready/index.min.js 325 B
build/dom/index.min.js 4.65 kB
build/edit-post/classic-rtl.css 578 B
build/edit-post/classic.css 580 B
build/edit-post/index.min.js 12.5 kB
build/edit-post/style-rtl.css 2.31 kB
build/edit-post/style.css 2.31 kB
build/edit-site/posts-rtl.css 6.35 kB
build/edit-site/posts.css 6.35 kB
build/edit-site/style-rtl.css 11.8 kB
build/edit-site/style.css 11.8 kB
build/edit-widgets/index.min.js 17.6 kB
build/edit-widgets/style-rtl.css 4.18 kB
build/edit-widgets/style.css 4.18 kB
build/editor/index.min.js 98.1 kB
build/editor/style-rtl.css 9.24 kB
build/editor/style.css 9.24 kB
build/element/index.min.js 4.83 kB
build/escape-html/index.min.js 537 B
build/format-library/index.min.js 8.1 kB
build/format-library/style-rtl.css 494 B
build/format-library/style.css 493 B
build/hooks/index.min.js 1.54 kB
build/html-entities/index.min.js 445 B
build/i18n/index.min.js 3.58 kB
build/interactivity/debug.min.js 16.5 kB
build/interactivity/file.min.js 447 B
build/interactivity/image.min.js 1.68 kB
build/interactivity/index.min.js 13.4 kB
build/interactivity/navigation.min.js 1.16 kB
build/interactivity/query.min.js 742 B
build/interactivity/router.min.js 2.8 kB
build/interactivity/search.min.js 615 B
build/is-shallow-equal/index.min.js 526 B
build/keyboard-shortcuts/index.min.js 1.31 kB
build/keycodes/index.min.js 1.46 kB
build/list-reusable-blocks/index.min.js 2.17 kB
build/list-reusable-blocks/style-rtl.css 846 B
build/list-reusable-blocks/style.css 846 B
build/media-utils/index.min.js 2.92 kB
build/modules/importmap-polyfill.min.js 12.3 kB
build/notices/index.min.js 946 B
build/nux/index.min.js 1.58 kB
build/nux/style-rtl.css 749 B
build/nux/style.css 745 B
build/patterns/index.min.js 7.34 kB
build/patterns/style-rtl.css 687 B
build/patterns/style.css 685 B
build/plugins/index.min.js 1.81 kB
build/preferences-persistence/index.min.js 2.06 kB
build/preferences/index.min.js 2.9 kB
build/preferences/style-rtl.css 715 B
build/preferences/style.css 715 B
build/primitives/index.min.js 829 B
build/priority-queue/index.min.js 1.54 kB
build/private-apis/index.min.js 1.01 kB
build/react-i18n/index.min.js 630 B
build/react-refresh-entry/index.min.js 9.47 kB
build/react-refresh-runtime/index.min.js 6.76 kB
build/redux-routine/index.min.js 2.69 kB
build/reusable-blocks/index.min.js 2.73 kB
build/reusable-blocks/style-rtl.css 256 B
build/reusable-blocks/style.css 256 B
build/rich-text/index.min.js 10.1 kB
build/router/index.min.js 1.96 kB
build/server-side-render/index.min.js 1.94 kB
build/shortcode/index.min.js 1.4 kB
build/style-engine/index.min.js 2.01 kB
build/token-list/index.min.js 581 B
build/url/index.min.js 3.85 kB
build/vendors/react-dom.min.js 42.8 kB
build/vendors/react-jsx-runtime.min.js 560 B
build/vendors/react.min.js 2.65 kB
build/viewport/index.min.js 965 B
build/warning/index.min.js 250 B
build/widgets/index.min.js 7.19 kB
build/widgets/style-rtl.css 1.16 kB
build/widgets/style.css 1.16 kB
build/wordcount/index.min.js 1.03 kB

compressed-size-action

@@ -1369,7 +1376,10 @@ export function useGlobalStylesOutputWithConfig(
hasBlockGapSupport,
hasFallbackGapSupport,
disableLayoutStyles,
disableRootPadding
options?.disableRootPadding,
{
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: I think toStyles is also ripe for a small refactor. Moving the following arguments

	hasBlockGapSupport,
	hasFallbackGapSupport,
	disableLayoutStyles = false,
	disableRootPadding = false,

into styleOptions

Copy link
Contributor

@aaronrobertshaw aaronrobertshaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for getting the ball rolling on this one @ramonjd 💪

While this does appear to solve the issue for simple applications of block style variations, I can confirm there is still an issue when it comes to nested variations that define inner block type or element styles.

Here's a rough demo video showing incorrect styles when variations define styles for inner group blocks.

Screen.Recording.2024-06-23.at.2.48.07.PM.mp4

With the current approach in this PR the styles get generated once only which causes the last defined variation style to target the inner block to take precedence incorrectly.

This nesting use case was the driving force behind applying styles in a per-application or instance way. To solve it here we'll probably need something similar to the block-style-variation.js hook.

@aaronrobertshaw
Copy link
Contributor

In case it helps, here's some sample block markup and a few very simple section styles that can be used to replicate the issue. They aren't exactly what was in the video in my last comment but close enough.

Example block markup
<!-- wp:group {"className":"is-style-section-c","style":{"spacing":{"padding":{"right":"var:preset|spacing|30","left":"var:preset|spacing|30","top":"var:preset|spacing|30","bottom":"var:preset|spacing|30"}}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group is-style-section-c" style="padding-top:var(--wp--preset--spacing--30);padding-right:var(--wp--preset--spacing--30);padding-bottom:var(--wp--preset--spacing--30);padding-left:var(--wp--preset--spacing--30)"><!-- wp:paragraph -->
<p>Parent</p>
<!-- /wp:paragraph -->

<!-- wp:group {"className":"is-style-section-b","style":{"spacing":{"padding":{"top":"var:preset|spacing|30","bottom":"var:preset|spacing|30","left":"var:preset|spacing|30","right":"var:preset|spacing|30"}}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group is-style-section-b" style="padding-top:var(--wp--preset--spacing--30);padding-right:var(--wp--preset--spacing--30);padding-bottom:var(--wp--preset--spacing--30);padding-left:var(--wp--preset--spacing--30)"><!-- wp:paragraph -->
<p>Group</p>
<!-- /wp:paragraph -->

<!-- wp:group {"className":"is-style-section-a","style":{"spacing":{"padding":{"top":"var:preset|spacing|30","bottom":"var:preset|spacing|30","left":"var:preset|spacing|30","right":"var:preset|spacing|30"}}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group is-style-section-a" style="padding-top:var(--wp--preset--spacing--30);padding-right:var(--wp--preset--spacing--30);padding-bottom:var(--wp--preset--spacing--30);padding-left:var(--wp--preset--spacing--30)"><!-- wp:paragraph -->
<p>Child</p>
<!-- /wp:paragraph -->

<!-- wp:group {"className":"is-style-default","style":{"spacing":{"padding":{"top":"var:preset|spacing|30","bottom":"var:preset|spacing|30","left":"var:preset|spacing|30","right":"var:preset|spacing|30"}}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group is-style-default" style="padding-top:var(--wp--preset--spacing--30);padding-right:var(--wp--preset--spacing--30);padding-bottom:var(--wp--preset--spacing--30);padding-left:var(--wp--preset--spacing--30)"><!-- wp:paragraph -->
<p>Grandchild</p>
<!-- /wp:paragraph --></div>
<!-- /wp:group --></div>
<!-- /wp:group --></div>
<!-- /wp:group --></div>
<!-- /wp:group -->
Section style partial theme.json files
{
	"$schema": "https://schemas.wp.org/trunk/theme.json",
	"version": 3,
	"title": "Section A",
	"slug": "section-a",
	"blockTypes": [ "core/group" ],
	"styles": {
		"color": {
			"background": "slategrey",
			"text": "snow"
		},
		"blocks": {
			"core/group": {
				"color": {
					"background": "darkslategrey",
					"text": "whitesmoke"
				}
			}
		}
	}
}
{
	"$schema": "https://schemas.wp.org/trunk/theme.json",
	"version": 3,
	"title": "Section B",
	"slug": "section-b",
	"blockTypes": [ "core/group" ],
	"styles": {
		"color": {
			"background": "teal",
			"text": "seashell"
		},
		"blocks": {
			"core/group": {
				"color": {
					"background": "mediumturquoise",
					"text": "white"
				}
			}
		}
	}
}
{
	"$schema": "https://schemas.wp.org/trunk/theme.json",
	"version": 3,
	"title": "Section C",
	"slug": "section-c",
	"blockTypes": [ "core/group" ],
	"styles": {
		"color": {
			"background": "darkslateblue",
			"text": "aliceblue"
		},
		"blocks": {
			"core/group": {
				"color": {
					"background": "slateblue",
					"text": "linen"
				}
			}
		}
	}
}

@ramonjd
Copy link
Member Author

ramonjd commented Jun 23, 2024

Thanks for explaining all that. I haven't delved too deeply yet, but it looks tricky.

This nesting use case was the driving force behind applying styles in a per-application or instance way. To solve it here we'll probably need something similar to the block-style-variation.js hook.

Interesting. So I see the editor is generating styles under "variation classname + clientId" selectors to target nested elements. And it's happening in the useBlocks hook.

Revisions prints a block list, but template level blocks, e.g., post-content block. useBlockProps doesn't run when switching between revision styles, and, even if it did, we'd have to make sure it uses the styles config merged with the currently-selected revision.

I still have a superficial overview, so I don't completely understand what needs to be done yet, but how right am I in assuming that we'd have to:

  1. Somehow check each block to tell whether it's a variation from it's classname. (Maybe there's a hook?)
  2. Rewrite the style object to include a ${ variation }-${ clientId } for each eligible block, à la useBlockStyleVariation
  3. Generate the styles using the rewritten style object

And all that every time a user switches between revisions.

For point one, I'll check if there's a hook. I don't like the sound of iterating through a tree of blocks and checking for variations.

@aaronrobertshaw
Copy link
Contributor

how right am I in assuming that we'd have to:

That aligns with my initial impressions once this issue had been uncovered.

  1. Somehow check each block to tell whether it's a variation from it's classname. (Maybe there's a hook?)

There was a hook specific to this smaller task however there was a recent refactor that improved the useBlockProps hook to only run when a variation class matched the class name rather than when a block had a class name. Perhaps that could be reused but I might have another idea.

  1. Rewrite the style object to include a ${ variation }-${ clientId } for each eligible block, à la useBlockStyleVariation
  2. Generate the styles using the rewritten style object

Something like this will be needed.

I don't like the sound of iterating through a tree of blocks and checking for variations.

There might be a shortcut we can take to determine the blocks that have variations applied.

The styles in the editor are generated and applied as style overrides. To achieve nested section styling we needed to ensure these overrides were stored with the blocks clientId so the overrides could be sorted in order of the blocks on the page.

My understanding (which is very limited) of the revisions UI is that the existing blocks on the page you are viewing are passed to a new iframed editor. Will those blocks' clientIds change? If not, we could leverage the style overrides to know which blocks need the section styles generated rather than iterating the block tree.

@ramonjd
Copy link
Member Author

ramonjd commented Jun 23, 2024

My understanding (which is very limited) of the revisions UI is that the existing blocks on the page you are viewing are passed to a new iframed editor. Will those blocks' clientIds change?

No, the block list is static once open 👍🏻

To achieve nested section styling we needed to ensure these overrides were stored with the blocks clientId so the overrides could be sorted in order of the blocks on the page.
we could leverage the style overrides to know which blocks need the section styles generated rather than iterating the block tree.

Ah, I didn't realize the style overrides were stored and we could access them. That opens another door, thanks!

@ramonjd
Copy link
Member Author

ramonjd commented Jun 24, 2024

My understanding (which is very limited) of the revisions UI is that the existing blocks on the page you are viewing are passed to a new iframed editor. Will those blocks' clientIds change?

No, the block list is static once open 👍🏻

I think understand the question better now: yes the client ids change because the block list is rendered again in the revisions view. Between applying style revisions, the client ids don't change again.

So this, I think, throws doubts on using the getStyleOverrides

@aaronrobertshaw
Copy link
Contributor

So this, I think, throws doubts on using the getStyleOverrides

That's a shame 🤔

If we set the variation class on the blocks that have variations applied before passing them to revisions perhaps that gives us something to rely on.

Without having had a chance to dig into the code yet, it seems to me like we need a few things:

  1. A reliable means to target blocks with styles e.g. setting the variation class rather than rely on clientId in revisions
  2. A way to know which variation is applied to which blocks. This could be extracted from the class when they are set/collected above
  3. Recreate the variation styles with each revision's merged style data using the class and variation name from above

@ramonjd ramonjd force-pushed the try/style-revisions-build-style-variations branch from 7f7128e to ad91fbe Compare June 24, 2024 02:04
@ramonjd ramonjd marked this pull request as draft June 24, 2024 04:33
const overrides = useSelect(
( select ) => unlock( select( blockEditorStore ) ).getStyleOverrides(),
[]
function EditorStyles( { styles, scope, overrides } ) {
Copy link
Member Author

@ramonjd ramonjd Jun 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converted to draft while I refactor and question life choices.

This is the main thrust of things: passing overrides to EditorStyles, which can override the overrides. 🙃

I'm overriding them all. Maybe better to merge them?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm only passing EditorStyles the overrides that need to override the overrides 😄

And now, merging them with the store overrides.

@@ -59,6 +59,72 @@ function getVariationNameFromClass( className, registeredStyles = [] ) {
return null;
}

export function useGetBlockVariationStylesWithConfig(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a first draft, but the basic logic is to grab the current overrides and update their CSS values with any incoming config. In our case, the user config from a styles revisions.

Ignore the naming. Maybe useUpdateBlockVariationOverridesWithConfig

I'm also looking for opportunities to reuse some of the logic within the block style variation hook, but that's a later thing.


const mergedOverrides = useGetBlockVariationStylesWithConfig(
config,
cloneObject( variationOverrides )
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise we're mutating the overrides object it seems. If we don't clone, we can just run the hook and not pass the result to Editor Styles.

This seems like a bug in the store, because mutating shouldn't be possible? That is, the result from useSelect should always be a unique reference.

I don't know yet. Too hungry. I'll check.

packages/edit-site/src/components/revisions/index.js Outdated Show resolved Hide resolved
@aaronrobertshaw aaronrobertshaw added the Backport to WP 6.6 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Jun 24, 2024
@ramonjd ramonjd marked this pull request as ready for review June 24, 2024 06:52
*/
export function useUpdateBlockVariationOverridesWithConfig(
config,
variationOverrides = []
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are probably opportunities to abstract this and share some love with useBlockStyleVariation. Perhaps return an override object instead. I'll look into it later - first on the agenda is to see if this PR flies at all.

* @param {Object} config A global styles object, containing settings and styles.
* @return {Array} An array of new block variation overrides.
*/
export function useUpdateBlockVariationOverridesWithConfig( config ) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, what I'm thinking would be better than all this is for useBlockStyleVariation() to have access to a mergedConfig that contains the current revision.

function useBlockStyleVariation( name, variation, clientId ) {
// Prefer global styles data in GlobalStylesContext, which are available
// if in the site editor. Otherwise fall back to whatever is in the
// editor settings and available in the post editor.
const { merged: mergedConfig } = useContext( GlobalStylesContext );
const { globalSettings, globalStyles } = useSelect( ( select ) => {
const settings = select( blockEditorStore ).getSettings();
return {
globalSettings: settings.__experimentalFeatures,
globalStyles: settings[ globalStylesDataKey ],
};
}, [] );

Maybe it could be return value from useContext( GlobalStylesContext );, e.g.,

const { merged: mergedConfig, currentRevisionConfig } = useContext( GlobalStylesContext );

I'm just riffing here. Not certain if it'd work.

However, I think this scenario should be taken into account for:

One of the suggestions is to have the site editor recognise global styles as a valid entity, as it does for templates, pages and so on. Global styles could not only be the current mergedConfig, but a revision config.

If I get time I'll start looking at that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both options sound worth exploring post 6.6>

Suggested change
export function useUpdateBlockVariationOverridesWithConfig( config ) {
export function useUpdateBlockStyleVariationOverridesWithConfig( config ) {

I know the name is getting pretty long but I think it helps to be clear this is to do with block style variations, not block variations.

@ellatrix
Copy link
Member

I'm having a hard time understanding what the problem is. Is it the order of rendering the style overrides? This could also be fixed by passing the clientId, and then rendering the styles in the right block order?

@ramonjd
Copy link
Member Author

ramonjd commented Jun 24, 2024

I'm having a hard time understanding what the problem is. Is it the order of rendering the style overrides?

Good question. Sorry, the PR is young and dynamic and I haven't updated the description properly.

No, it's the content of the style overrides.

Initially, the overrides are set using the global styles config in the useBlockProps hook.

However, the revision history contains multiple versions of the global styles config that need to be swapped in and out dynamically.

This could also be fixed by passing the clientId, and then rendering the styles in the right block order?

Could you elaborate? Passing the clientId to where? I'm interested to see if this helps.

Copy link
Member Author

@ramonjd ramonjd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for taking the time to review this PR, folks.

As mentioned, the fact that confusion exists surrounding this change tells me:

  • I need to explain the problems we're trying to solve more clearly (admittedly it took me a while to get my head around style variations in the last few days!), and
  • I need to look at my other idea of setting a "currentRevision" config or something that can be fetched in useBlockStyleVariation. This would, if it works like I think it would, mean far less code, but potentially require a "currentRevision" record somewhere in the core data store.

Are there e2e tests for this?

I'll work on that tomorrow.

}

function EditorStyles( { styles, scope, overrides } ) {
const styleOverrides = useSelect(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useUpdateBlockStyleVariationOverridesWithConfig fetches the overrides only as a reference to check if a block has a block style variation applied.

If so, and a matching path in the currently-selected revision user config exists, then it will return a new array containing a set of overrides specific to the current revision.

The merge here in EditorStyles is a merge of CSS only, basically, "hey, I have these other overrides I'd like to output."

packages/block-editor/src/hooks/block-style-variation.js Outdated Show resolved Hide resolved
packages/edit-site/src/components/revisions/index.js Outdated Show resolved Hide resolved
* @param {Object} config A global styles object, containing settings and styles.
* @return {Array} An array of new block variation overrides.
*/
export function useUpdateBlockStyleVariationOverridesWithConfig( config ) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The style overrides in the store are generated using the current user global config.

We have to be able to recreate/create style variation overrides using any config, such as a global styles revision CPT.

With this PR I found the following constraints:

  • The revision preview recreates the block list, which creates new clientIds
  • useStyleOverride() runs for these ideas, but it uses the current user global styles config
  • The quickest way to tell if a style variation override existed for the blocks rendered in the revision preview was to check the overrides store.
  • I wanted to call useStyleOverride() again to overwrite the overrides in the store using the revision config, but I had to do so by looping over a collection

It was a all bit of a rush job.

That it's causing some confusion informs me that I should pursue the other idea of setting a "currentRevision" config or something that can be fetched in useBlockStyleVariation

@ramonjd ramonjd force-pushed the try/style-revisions-build-style-variations branch from d7078b5 to 323a990 Compare June 26, 2024 02:22
Copy link

github-actions bot commented Jun 26, 2024

Flaky tests detected in 55cc60c.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9691349709
📝 Reported issues:

},
} );

test.describe( 'Block Style Variations', () => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit of a monster. It checks:

  • Applying block style variations in the site editor to blocks and nested blocks
  • Checking that those styles are applied correctly
  • Updating block style variations in global styles, and checking that those styles are applied correctly.
  • Checking that the revisions preview matches the editor canvas

Copy link
Contributor

@aaronrobertshaw aaronrobertshaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @ramonjd 👍

I like that we're not touching the public EditorStyles component now. Bonus points for the e2e test as well!

Another round of testing the latest approach shows everything still working as expected.

✅ Existing section styles functionality is working
✅ Revisions containing block style variations display correctly
✅ Applying revisions still works and correct variation styles are in effect
✅ Tweaks to custom block style variations work as expected
✅ Revisions containing style variation changes are reflected in post editor and frontend after applying

I left a few minor questions about the e2e as inline comments but all in all this is looking pretty good to me. ✨

packages/block-editor/src/hooks/block-style-variation.js Outdated Show resolved Hide resolved
test/e2e/specs/site-editor/block-style-variations.spec.js Outdated Show resolved Hide resolved
test/e2e/specs/site-editor/block-style-variations.spec.js Outdated Show resolved Hide resolved
Comment on lines 83 to 84
// Check nested grandchild group block inherited styles.
await expect( thirdGroup ).toHaveCSS( 'border-style', 'groove' );
await expect( thirdGroup ).toHaveCSS( 'border-width', '22px' );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this test is a beast already but I was wondering if we should also apply the first variation to the grandchild here at the end?

Something to ensure that earlier defined style variations don't have their styles overridden by a later definition's inner block type styles.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking I understand - so the test is to apply a block style variation (A) to the nested grandchild block to ensure that A's styles overwrite any inherited styles from parent blocks.

I'll add it and you can tell me if I got it right 😄

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I believe we're on the same page.

If only a simple stylesheet was being generated and there was a single set of CSS for each variation, including inner block type styles, for example:

:root :where(.is-style-variation-a .wp-block-group) {...}
:root :where(.is-style-variation-b .wp-block-group) {...}

Then checking that variation B gets applied when selecting it on the child covers whether that variation then overcomes the inner block type styles for variation A applied to the parent. So far, so good 👍

Given the same specificity in the example above, the variation B inner block type styles would override the selection of variation A on the grandchild due to being loaded later.

Adding this extra test for the application of variation A again on the grandchild will cover that we're not relying on the load order of the CSS. In other words, it ensures we're creating the per-instance styles appropriately so that the most immediate variation's styles are in effect.

I hope that makes it clearer 🤞

…stage.

Getting closer. But the overrides in state need to be merged with incoming revision styles.
Destructure in hook so the consumer doesn't have to clone
Only send the override overrides to EditorStyles that need to be overridden.
add overrides to dep array in Editor Styles
rename hook
Register revision overrides with useStyleOverride
Add rudimentary E2E test covering block style partials, applying them, updating them and viewing styles revisions.
@ramonjd ramonjd force-pushed the try/style-revisions-build-style-variations branch from 52133da to 55cc60c Compare June 27, 2024 05:46
Copy link
Contributor

@aaronrobertshaw aaronrobertshaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the hard work and patience here @ramonjd 👍

I've given this PR another test and it continues to work nicely.

I'm happy to give this an approval again but if you do feel it warrants a second opinion after my false start, that's fine too 😁

@ramonjd ramonjd merged commit 49b9692 into trunk Jun 27, 2024
65 checks passed
@ramonjd ramonjd deleted the try/style-revisions-build-style-variations branch June 27, 2024 06:34
@github-actions github-actions bot added this to the Gutenberg 18.8 milestone Jun 27, 2024
Copy link

There was a conflict while trying to cherry-pick the commit to the wp/6.6 branch. Please resolve the conflict manually and create a PR to the wp/6.6 branch.

PRs to wp/6.6 are similar to PRs to trunk, but you should base your PR on the wp/6.6 branch instead of trunk.

# Checkout the wp/6.6 branch instead of trunk.
git checkout wp/6.6
# Create a new branch for your PR.
git checkout -b my-branch
# Cherry-pick the commit.
git cherry-pick 49b9692a793a6d5cbc2eb23e5fd93a2f31091de0
# Check which files have conflicts.
git status
# Resolve the conflict...
# Add the resolved files to the staging area.
git status
git add .
git cherry-pick --continue
# Push the branch to the repository
git push origin my-branch
# Create a PR and set the base to the wp/6.6 branch.
# See https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-base-branch-of-a-pull-request.

ramonjd added a commit that referenced this pull request Jun 27, 2024
…S is generated (#62768)

* Render styles after the variation style overrides have been saved to stage.
Getting closer. But the overrides in state need to be merged with incoming revision styles.

* For every current override, update the variation CSS with the incoming config from the revision.

* Rename hook
Destructure in hook so the consumer doesn't have to clone
Only send the override overrides to EditorStyles that need to be overridden.

* Fetching overrides in the hook

* Feedback suggestions from review:
add overrides to dep array in Editor Styles
rename hook

* Return getBlockStyles from the useSelect callback

* Refactor so we don't have to change the EditorStyles props
Register revision overrides with useStyleOverride

* Adding some explanatory comments
Add rudimentary E2E test covering block style partials, applying them, updating them and viewing styles revisions.

* Removed unused style fixture

Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
@ramonjd
Copy link
Member Author

ramonjd commented Jun 27, 2024

Cherry pick PR to wp/6.6 here:

ramonjd added a commit that referenced this pull request Jun 27, 2024
* Render styles after the variation style overrides have been saved to stage.
Getting closer. But the overrides in state need to be merged with incoming revision styles.

* For every current override, update the variation CSS with the incoming config from the revision.

* Rename hook
Destructure in hook so the consumer doesn't have to clone
Only send the override overrides to EditorStyles that need to be overridden.

* Fetching overrides in the hook

* Feedback suggestions from review:
add overrides to dep array in Editor Styles
rename hook

* Return getBlockStyles from the useSelect callback

* Refactor so we don't have to change the EditorStyles props
Register revision overrides with useStyleOverride

* Adding some explanatory comments
Add rudimentary E2E test covering block style partials, applying them, updating them and viewing styles revisions.

* Removed unused style fixture

Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
@ellatrix
Copy link
Member

ellatrix commented Jul 2, 2024

This was manually cherry-picked in #62905.

@ellatrix ellatrix added Backported to WP Core Pull request that has been successfully merged into WP Core and removed Backport to WP 6.6 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta labels Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backported to WP Core Pull request that has been successfully merged into WP Core [Feature] Theme Style Variations Related to style variations provided by block themes Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants