-
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
Extending block style variations as a mechanism for styling sections of content #56632
Comments
This could work differently, if that's easier. We could use a full styles object only for block style variation registered via There is precedent for something like this: the first version of This is just thinking out loud, in case it helps uncover more of the solutions space. |
Thanks for sharing your thoughts @oandregal 👍 I'm not sure I'm following, sorry. Could you expand on it at all?
The acceptance of a style object is already pretty much working in the proof of concept.
At the moment, variations aren't really "registered" at all in theme.json only "defined" if that makes sense. Any variation in theme.json that isn't defined on a block type, e.g. via a block's block.json, is ignored. In #56540, it also checks the One of the primary goals of these enhancements was to allow block styles to be registered across multiple blocks. This would prevent the need to repeat theme.json styling for each block's variation. Do you have suggestions on how only using theme.json for registration would work for this? Would it require changing the shape of theme.json to allow a new I'm clearly missing something 🙂 |
Closing this issue as the broader effort, issues and discussions are covered under #57537. |
Proposal
After some explorations into styling sections of content (#55563 & #56234), a consensus was reached that Block Style Variations might be the best mechanism to achieve section styling.
For this to be possible, block style variations would need some enhancements, including:
register_block_style
from which a stylesheet can be generated and enqueuedThis issue will track efforts in achieving the desired enhancements and may evolve as requirements become clearer.
Color and Typeset presets
It is worth noting another current proposal for color and typeset presets. While related, these are still separate in scope.
Enhanced block style variations will provide greater control and opportunity for theme authors to leverage the composable color and typography presets proposed in #56604.
History
This proposal has arisen out of a couple of early attempts to provide styling for page sections that might differ from the overall look and feel of a theme.
The first proof of concept (#55563) looked at implementing section-specific theme.json using a block instance's style object to store that block or section's custom styles. While this was promising and worked, it fell short as these section styles weren't easily shared and reused across multiple sections on a page.
The idea was then to store the section's styles within the Global Styles object which would then also mean it could be initially defined within theme.json.
At this stage, the potential solution began to overlap and resemble potential options for Element Colour Sets, so #56234 attempted to merge this into a single new feature under theme.json called
sections
. This had several shortcomings and as the discussion evolved, it became clearer that the color sets and section styling were still two separate issues and that the latter could be addressed through enhanced block style variations arriving now to this proposal.Links
Tasks
There is a draft proof of concept PR covering a large portion of this proposal up in #56540. Progress can also be followed along with there.
Future Follow-Ups
Eventually, it would be desirable for a section-section (e.g. group block) to be stylable within the editor and then have that collection of style be pushed to global styles as a block style variation. This would include nested block and element styles.
This would require a major change to the inspector controls style panel and as such is out of scope for the time being.
The text was updated successfully, but these errors were encountered: