-
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
Explore block style variations as packages of style attributes #33232
Comments
Thinking block style variations as packages of style attributesAt the moment, when the user selects a block style variation what ends up happening is that a new class is attached to the block markup: <my-block class="is-my-style-variation" /> Then, the theme needs to provide the styles for the class. For example: .wp-block-my-block.is-my-style-variation {
font-size: 23px;
line-height: 1.2;
color: blue;
} This is what I understand by thinking of style variations as "packages of style attributes": the block markup doesn't get attached the style variation class but the underlying design units: <my-block class="has-blue-color has-font-size-small" style="line-heght: 1.2"/>
We'd provide a mechanism via Question: what if the style variation includes some style property that we don't support? I presume this needs to be answered on a case-by-case basis: there may be style properties we need to support and add UI controls for them, others we may need to support but don't any UI, and there's always the ability to keep using the existing mechanism ( |
How does it look to migrate an existing block style variation to this?The quote block has the Existingblock markup:
CSS: .wp-block-quote.is-large {
margin-bottom: 1em;
padding: 0 1em;
}
.wp-block-quote.is-large p {
font-size: 1.5em;
font-style: italic;
line-height: 1.6;
}
.wp-block-quote.is-large cite,
.wp-block-quote.is-large footer {
font-size: 1.125em;
text-align: right;
} NewBlock markup:
CSS: .style-variation-UUID p { /* same as above */ }
.style-variation-UUID cite,
.style-variation-UUID footer { /* same as above */ } Note: |
How do we define block style variations via
|
I agree with the proposal by @nosolosw to include block style support as part of theme.json. I think the shape proposed makes sense we would only need to include a translatable name property per block style so the block style picker correctly displays the name of the style. |
I don't understand how the proposed schema would support multiple style variations... The current implementation allows users to define as many block-styles as they want, and then users just select one. "settings.styleVariations": {
"large": {
"core/quote": { ... }
}
} And if we allow multiple styles to be defined, then why bother generating a UUID instead of using the key that the user provides for their block-style (in the case above, |
I agree with what @aristath said I don't think we need UUID's and I think block styles should be consistent with presets so I imagine the following schema:
|
I've updated the issue description with the steps a theme such as TT1-blocks has to set up the block variations it wants active. It takes a few steps to do so in three different languages (CSS, PHP, JS) through a number of different files. |
This issue no longer reflects the work of the styles sub-system. A whole lot has been improved since this was initially created, so I'm closing it. |
This stems from #33157 and older threads such as #22208 (comment)
Example: tt1-blocks theme
I've looked at what the TT1-blocks theme needs for styling in CSS. A large part of its styles is block style variations. This is what the theme has to do to set up the block style variations it wants.
Register its own block style variations:
after_setup_theme
) and for the front-end (via hooking intowp_enqueue_scripts
).Unregister existing block styles variations it doesn't want active:
enqueue_block_editor_assets
so it takes effect.The text was updated successfully, but these errors were encountered: