-
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
Add: Mechanism to detect if a block instance matches a global styles selector #26945
Add: Mechanism to detect if a block instance matches a global styles selector #26945
Conversation
Size Change: +240 B (0%) Total Size: 1.19 MB
ℹ️ View Unchanged
|
aee8a21
to
77d626a
Compare
82c572e
to
9ce8161
Compare
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 nice!
A few minor things that I'd like us to address are:
- make the title key mandatory for all blocks that use this new mechanism (not having the key is only useful for the heading block)
- add some checkings for those keys (title, selector, attributes) being present
I'm pre-approving because I'm eager to get this in and don't want you to be blocked by my review.
Unsure how this should be advertised, though. Although it's experimental, if there're third-parties testing this already, how do make sure they know about this? Add a note into the block-library changelog, perhaps? |
9ce8161
to
eed7d5f
Compare
Alternative to #24423.
This PR adds a mechanism to detect at run time if global styles selector affects a given block instance.
Basically, the selector defines a set of attributes and we consider a block matches a selector if all the attributes defined in the selector have the same value on the block.
How has this been tested?
I added the following information to the theme.json
I created a new post.
I added a heading block.
I verified that the available colors change depending on if I select heading levels 1 or 2.