-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Allow the style property of block.json to be an array and add support for object-based block styles #2853
Allow the style property of block.json to be an array and add support for object-based block styles #2853
Conversation
…assed_register_block_style_handle test
This seems like a blocker. Can we change it to allow for strings as well? |
@scruffian oh it can be a string. I'm saying it can be either of:
Therefore, any code that assumes it's just a string or string[] will break. |
@scruffian I applied all the feedback and refreshed the related Gutenberg PR. This one is ready for another review! |
@adamziel, thank you so much for looking into adding native support for multiple
This will include also existing unit tests for both classes. New functionality requires also unit test coverage. I don't think we consume We should also extend the existing documentation for What is the reason this patch covers only |
We will have to put an empty wordpress-develop/src/wp-includes/deprecated.php Lines 4305 to 4313 in 0abc2b2
|
It looks like we have everything covered so it needs a final review and a round of testing with and without the Gutenberg plugin. |
I think we're good now! GitHub CI seems to be down, though, so might be worth waiting until it's up again before merging. |
All the tests passed! Would you please help get this PR approved? CC @gziolo @aristath @scruffian @getdave |
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.
LGTM
@gziolo do you think you could merge this one? |
cc @mtias for soundness check – does this change seem reasonable to you? |
The example shared in the description looks nice in my opinion as it consolidates several available options. In the future, we could also use the same API borrowed from {
"styles": [
{
"name": "default",
"label": "Default",
"isDefault": true
},
{
"name": "other",
"label": "Other",
"settings": {
"border": {
"color": {
"text": "#000",
"background": "#ccccc"
}
}
}
}
],
"style": [ "wp-block-button", {
"border": {
"color": {
"text": "#fff",
"background": "#32373c"
}
}
} ]
} |
Let's land WordPress/gutenberg#41873 in the Gutenberg plugin first and give it a try before we include it in WordPress core. Code-wise everything is ready, and it had enough reviewers. We mostly need to validate that the extended API for |
I'm closing this in favor of #3108 |
What problem does this PR solve?
In WordPress/gutenberg#34180 we moved block CSS to
blockJson.supports.__experimentalStyle
. This PR moves it underblockJson.style
at the root level. The goal is to only have a single location where styles are defined.Block.json before this PR:
Block.json after this PR:
This PR is an alternative to WordPress/gutenberg#41656
Other considerations
This is a breaking change – any existing code that assumes
style
to be a single item or an array of strings will throw a notice at best.Test plan
npm run build
cc @getdave @scruffian @draganescu
Trac ticket: https://core.trac.wordpress.org/ticket/56094