-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Background block supports: move size defaults to hooks and block.json #60008
Background block supports: move size defaults to hooks and block.json #60008
Conversation
…erty values from the style engine to a useBlockProps hook. The style engine can now generate "pure" styles, with return values reflecting input values, and not be opinionated or return feature-specific mutations.
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. |
Size Change: +180 B (0%) Total Size: 1.71 MB
ℹ️ View Unchanged
|
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.
This is testing nicely for me, thanks for including the quick test markup!
Because it's removing the style engine logic, this PR also affects the default behaviour of theme.json site-wide background images. It won't fill in defaults. Given that #59889 is removing these defaults anyway, then it's a known and expected outcome.
That sounds reasonable to me. Also, if we do want to reuse the defaults here in the future for any reason, we could always split out parts of the innards of this useBlockProps
hook and put it in a utility function that global styles can use. We might want to end up doing something like that when it comes to enabling at the block-level within global styles, but that'd be for another PR when it comes to that 🙂
LGTM! ✨
Thank you for testing! 🍺
Yes, great idea. I think another big cleanup and test opportunity will be when we return to: |
…ender_background_support and revert gutenberg_get_background_support_styles (#59889) * Move block support defaults to gutenberg_render_background_support and revert gutenberg_get_background_support_styles * Revert JS changes, moving them to a new PR #60008 * background-size auto is the same as no background-size * Using style engine in theme json class to generate background styles because background image can be a string or an object. Co-authored-by: ramonjd <ramonopoly@git.wordpress.org> Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
…erty values from the style engine to a useBlockProps hook. (WordPress#60008) The style engine can now generate "pure" styles, with return values reflecting input values, and not be opinionated or return feature-specific mutations. Co-authored-by: ramonjd <ramonopoly@git.wordpress.org> Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
…ender_background_support and revert gutenberg_get_background_support_styles (WordPress#59889) * Move block support defaults to gutenberg_render_background_support and revert gutenberg_get_background_support_styles * Revert JS changes, moving them to a new PR WordPress#60008 * background-size auto is the same as no background-size * Using style engine in theme json class to generate background styles because background image can be a string or an object. Co-authored-by: ramonjd <ramonopoly@git.wordpress.org> Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
What? Why? How?
Split from #59889
This commit moves the logic that sets the default background CSS property values from the style engine to a
useBlockProps
hook.The style engine can now generate "pure" styles, with output values reflecting input values, and not be opinionated or return feature-specific mutations. This might be handy for global styles, where background defaults aren't required for body tag background images.
Important
Because it's removing the style engine logic, this PR also affects the default behaviour of theme.json site-wide background images. It won't fill in defaults. Given that #59889 is removing these defaults anyway, then it's a known and expected outcome.
Testing Instructions
There should be no regressions in the way background images work in the editor.
When adding a background image to a group block, the default background size should be "cover". Example HTML:
When the background size is set to "contain", the default background position should be "center":
Screenshots or screencast
2024-03-20.10.32.18.mp4