Skip to content
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

Global Styles: Add support for default styles #27796

Closed
scruffian opened this issue Dec 18, 2020 · 4 comments
Closed

Global Styles: Add support for default styles #27796

scruffian opened this issue Dec 18, 2020 · 4 comments
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Enhancement A suggestion for improvement.

Comments

@scruffian
Copy link
Contributor

From #27579:

It feels like having a way to set the default padding in the block's supports field instead would make it more convenient for customization purposes. In addition to true it could support an object with default values or anything that the theme.json is using.

As noted on that PR, setting default styles in the way the handbook recommends results in validation errors in the block.

As can be seen in #27582, if we set these values in CSS rather than in the JSON then when the user resets the setting, the CSS takes control, which is confusing for the user.

I agree with @gziolo that we should be able to set this in the block.json somehow.

cc @nosolosw @jorgefilipecosta

@jorgefilipecosta
Copy link
Member

I agree that it makes sense to allow blocks to use the theme.json system to apply styles to themselves.
It could be as simple as having a style property in block.json that allows blocks to use anything from theme.json to style themselves.
This system would make sense per selector the block defines so for example the heading block would be able to apply styles per heading level.
The global styles system would then have an additional element on the hierarchy the block styles e.g: it would be core < block < theme < user instead of core < theme < user.

But regarding showing what is the default at the block level e.g: the padding is 1em, even if we specify styles using block.json it is something very complex. The default can be from the theme or from the user or some pattern and when we have semantic nesting on theme.json, the same verse block may have a padding of 1em, when on single post view and 0.5em when rendered on the post list so what default would we show for padding at the block level?
Currently, styles at the block inspector show a value only if there is one explicitly set as an inline value for that block instance and don't show anything when the default is being used. Reset just removes user customization from that instance and uses the "default" (that may come from multiple places and even change depending on the context).
I guess we should explore trying to show some defaults to the user in the editor, so the user knows that there is a default. But probably after we have a semantic nesting ready because that part is what makes the problem challenging. Regarding the reset, I think even if we show the default somehow, a user pressing reset would not remove a value or remove the default it would just remove the user value and revert things to the default.

@mtias
Copy link
Member

mtias commented May 23, 2022

@scruffian do we have something actionable here or is it mostly covered?

@scruffian
Copy link
Contributor Author

scruffian commented May 23, 2022

I believe the way forward here is outlined in #34180

@annezazu annezazu added [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") and removed [Feature] Full Site Editing labels Jul 24, 2023
@jordesign
Copy link
Contributor

Looking at #34180 it seems this may now be resolved.

@scruffian can you confirm whether this issue can be closed or not?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

5 participants