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

Style variations should be another layer in the theme.json hierarchy rather than stored in the database #62661

Open
justintadlock opened this issue Jun 18, 2024 · 7 comments
Labels
Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Enhancement A suggestion for improvement.

Comments

@justintadlock
Copy link
Contributor

What problem does this address?

Currently, when selecting a style variation via the Appearance > Editor > Styles screen, the settings and styles from the corresponding /styles/*.json file are imported into the database and saved as the user customizations as the final layer in the theme.json hierarchy. This is problematic for a number of reasons, but primarily:

  • Users don't benefit from updates to those style variations. For example, they may want to customize colors to their liking but not touch typography (regardless, all of the variation data and their customizations are stored in the database at the same level).
  • Theme authors cannot easily test changes to their variations without selecting, saving, resetting, making their changes, and repeating the process. (Note: I had to build a script to test variations via Composer.)

The current behavior also had to be patched in order to port custom CSS when users switched variations: #61752

What is your proposed solution?

I propose that style variations simply become another layer in the overall theme.json hierarchy, like so:

  • WordPress default theme.json.
  • Theme's theme.json.
  • Variation /styles/*.json.
  • User customizations.

This would solve the primary issues. A change should also not negatively impact already-saved customizations.

@justintadlock justintadlock added [Type] Enhancement A suggestion for improvement. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Jun 18, 2024
@justintadlock
Copy link
Contributor Author

CC: @WordPress/outreach

@markhowellsmead
Copy link

markhowellsmead commented Jun 18, 2024

Is there a reason why the variations can't be part of theme.json itself?

@justintadlock
Copy link
Contributor Author

Is there a reason why the variations can't be part of theme.json itself?

It's technically possible to go that route, adding a new property in theme.json, but style variations can be 100s or 1,000s of lines of JSON. If your theme has more than a few of them, that would make for some very large theme.json files.

For my own sanity, I prefer the separation that's offered currently. :)

@markhowellsmead
Copy link

Hm; I see your point and I already see a lot of people complaining on social media, that theme.json is already too complex. Are the variation styles not already part of the cascade you mention? Are they simply read in and saved as a user customisation at the moment? If so, then there should be the option to “discard changes”, as there is for templates and template parts.

@justintadlock
Copy link
Contributor Author

Are they simply read in and saved as a user customisation at the moment?

Yes.

If so, then there should be the option to “discard changes”, as there is for templates and template parts.

We already have that feature of "reset styles," which does the same thing. There's no separation between what are true user styles vs. variation styles, so everything is reset/discarded.

It doesn't solve either of the two primary issues.

@markhowellsmead
Copy link

Then I agree with your suggestion, that the hierarchy should be extended in order to read in any /styles/*.json. files directly, instead of these being copied (unmodified) to the database.

@oandregal
Copy link
Member

Related #62686

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] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

3 participants