Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: block background UI controls #60100
Global styles: block background UI controls #60100
Changes from all commits
3a99461
72ffc2f
a686680
7988ba5
f000836
541ff26
a804a8c
ef149cc
5aba906
47a389a
d040811
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Probably should abstract this logic. There'll be elements and other things later I imagine.
Also add unit tests to cover this.
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.
What did you have in mind for the abstraction? A separate method, or function call to another file? Just curious how this part of the feature might evolve 🙂
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.
Maybe once (if?) we support background images for elements, the whole
foreach
could be a function that takes an array of either blocks or elements so we can run it on both? I don't think it's worth abstracting until that happens though.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.
Good point. Let's cross that bridge when we come to it.
I haven't really thought about it, but the obvious target would be around building the resolved array items. So the if block starting from
wp_check_filetype()
.The future will involve target specific styles — top-level, blocks, elements and, eventually, variations, the latter two requiring possibly further nested loops.
Maybe once elements comes along it'll be clearer how the abstraction should look.
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.
Probably doesn't need to happen any time soon, but might be useful for other block controls I imagine?
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.
So if a variation has been applied to a block, we need to parse it here.
This needs to happen in a follow up. I've added a note to #54336
cc @aaronrobertshaw just in case there are gotchas (TL;DR - I'm trying to pass down the theme styles applied to a block to the controls, so that the controls are aware of any defaults)
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.
Yeah, at a glance, we'd need to detect which, if any, variation has been applied to the block, then merge the variation's data over the block type's data. The resulting set would tell us which value the control should get.
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 the magic that allows the background image preview to display where the image comes from theme.json