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

Add docs for variations key in theme.json #49826

Merged
merged 3 commits into from
Apr 17, 2023

Conversation

oandregal
Copy link
Member

@oandregal oandregal commented Apr 14, 2023

Follow-up to #46343

What?

This PR adds docs for the variations key added to theme.json in WordPress 6.2.

Why?

We should aim to document every aspect of the theme.json specification, so it's clear to extenders.

How?

By adding the respective section to the theme.json how-to docs.

Testing

Inspect the new section and proofread.

Read it as part of the whole document.

@oandregal oandregal self-assigned this Apr 14, 2023
@oandregal oandregal added [Type] Developer Documentation Documentation for developers Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Apr 14, 2023
@oandregal oandregal requested a review from andrewserong April 14, 2023 11:44
@carolinan

This comment was marked as resolved.

Copy link
Contributor

@andrewserong andrewserong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reads well to me, just left a tiny grammatical nit, but feel free to ignore it.

Thanks for updating the docs! ✨

docs/how-to-guides/themes/theme-json.md Outdated Show resolved Hide resolved
@carolinan
Copy link
Contributor

carolinan commented Apr 17, 2023

Today I have had more time to test whether it works with block style variations added from themes and plugins.
I found this reply from @tellthemachines:
#49550 (comment)

Thanks for bringing this up!

it only works for CORE styles (for example, the "rounded" style in the image block), not custom styles registered via register_block_style

Correct, the initial implementation only included core style variations, with the standard design tools. Because existing custom style variations are styled via a classic stylesheet, which depending on specificity might not be overridable with the core design tools such as color, typography etc.., custom styles were excluded then.

I'm thinking that the custom CSS field could be leveraged to solve that problem, and also that it should be possible to add new custom variations from theme.json. I opened an issue in #49602 suggesting some next steps.

When testing variations in theme.json with the theme-registered custom styles, I even get PHP warnings. The PHP warnings and the limitation is not relevant for this PR other than making sure that the documentation explains that only core block style variations work.

@oandregal
Copy link
Member Author

Thanks @carolinan for the context. I pushed 1f2098d for clarification and tested that block variations defined via block.json work.

@oandregal
Copy link
Member Author

@carolinan I almost forgot to mention that #49807 will fix the error for Gutenberg when an unregistered style variation is used in the theme.json.

@oandregal oandregal merged commit de2c80d into trunk Apr 17, 2023
@oandregal oandregal deleted the add/docs-for-theme-json-variations branch April 17, 2023 14:15
@github-actions github-actions bot added this to the Gutenberg 15.7 milestone Apr 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Developer Documentation Documentation for developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants