-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Block Styles: Extend block style variations as mechanism for achieving section styling #6662
Block Styles: Extend block style variations as mechanism for achieving section styling #6662
Conversation
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
0e6a912
to
bd79a65
Compare
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 Core Committers: Use this line as a base for the props when committing in SVN:
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
FYI this backport has been updated to include a bug fix which landed in Gutenberg via WordPress/gutenberg#62125. |
Hello! Happy Friday. Testing first, and then I’ll look at the code. I followed the testing steps in WordPress/gutenberg#57908 basically to the letter. Thanks for writing them! I am testing this branch and have the Gutenberg plugin disabled. It’s literally my first time looking at this feature so if I’m doing something wrong just tell me. When I put this into my functions.php:
I received this notice:
I worked around this by replacing the I noticed that, with that code above, links within a Group block on the frontend correctly received a #ead196 colour but links within a Group block in the editor remained black. It’s a similar story for the #739072 background on nested Group blocks. I could see that in the frontend but not the editor. I’m not sure what this means:
Do you have an example to test? When I added a variation by creating a |
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.
I'm still testing, thought I'd leave a bunch of annoying syntax feedback first 😄
Thanks for testing @noisysocks and @ramonjd 👍
Sorry, it looks like I missed rebasing this PR after the backport for extending block style registration. I'll get it updated shortly.
By that it meant, if a block style variation specifies margin styles, they don't incorrectly override margin styles set by layout styles e.g. the left/right margins on top level blocks etc. Once I sort out the other feedback, I'll circle back and try and come up with a concrete example. |
Was just coming here to ask for a rebase 😄 |
…g section styling
A couple of function were out of date with Gutenberg and a new bug fix is also due to land.
5167492
to
3598752
Compare
Ok, this has been rebased and the indentation sorted. Well I hope the indentation/linting issues are sorted, I don't trust my local phpcs/phpcbf config right now 😅 |
I've been testing this mainly by registering style variations in PHP, both with classic and block themes, and it's working as expected for both ✅ |
Apologies @noisysocks, I messed up the test instructions. The editor side of this feature requires the JS changes in Gutenberg to function properly there. I'll update the instructions for others that might be testing this one. |
Got it, that makes sense. It think the only issue I'm seeing now then is this one:
Here's a video: Kapture.2024-05-31.at.14.43.42.mp4 |
Appreciate the continued patience here @noisysocks 🙇 The catch with the variation partial used there is that it references css custom properties not present in TwentyTwentyFour. Switching those up to simple hex values might be the best bet for testing. I'll go and update the original PR's snippets so they don't catch anyone else out. |
I'm running through the scenarios from the Gutenberg PR WordPress/gutenberg#57908 So far: ✅ blockTypes blocks are being registered correctly and styles applied on frontend (tested using using theme.json and register_block_style) ✅ existing block style variations on core blocks continue to work ✅ Applying a variation within a block that already has a variation has the correct styles applied ✅ Setting element styles on an individual block instance continues to take precedence |
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.
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.
Code's looking pretty good to me! Thanks for adding comprehensive tests ❤️
Makes sense 👍 thanks! I changed the |
Committed in r58264. |
* | ||
* @param array $variation Theme.json shaped style variation object. | ||
* @param string $scope Scope to check e.g. theme, block etc. | ||
* |
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.
* theme.json partial files by the scope to which they | ||
* can be applied e.g. theme vs block etc. | ||
* | ||
* @param string $scope The scope or type of style variation to retrieve e.g. theme, block etc. | ||
* |
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.
Same here
* The options currently supported are: | ||
* - 'scope' that makes sure all style are scoped to a given selector | ||
* - `root_selector` which overwrites and forces a given selector to be used on the root node | ||
* - `skip_root_layout_styles` which omits root layout styles from the generated stylesheet. |
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.
Need some space to align the document.
@noisysocks ☝️ |
Thanks @mukeshpanchal27, addressed in r58265. Are you interested in fixing |
Provide users with the ability to style entire sections of a page without having to tediously reapply the same sets of styles. This will amplify the site-building potential of pattern overrides, zoomed out mode etc.
A full history of the feature can be found in: WordPress/gutenberg#57537
Syncs the changes from: WordPress/gutenberg#57908 & WordPress/gutenberg#62125
Detailed test instructions can be found on the linked Gutenberg PRs.
Some specific things to test include:
/styles
and theme style variationsTrac ticket: https://core.trac.wordpress.org/ticket/61312
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.