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: Allow saving, importing, exporting, copying from another theme without switching to it #45371

Open
Tracked by #33094
jasmussen opened this issue Oct 28, 2022 · 23 comments
Assignees
Labels
Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json Needs Dev Ready for, and needs developer efforts [Type] Enhancement A suggestion for improvement.

Comments

@jasmussen
Copy link
Contributor

jasmussen commented Oct 28, 2022

In Global Styles > Browse styles, it should be possible to import, export, and save styles. The interface should accommodate all these flows:

  1. Allow saving user variations for each bundled style (i.e. customized “dark” variation) (same as Global Styles: Managing style variations #38333)
  2. Load style variations from a file
  3. Provide access to styles from other themes without switching to them (related to Global Styles: Allow access to style variations from any theme #45452)
  4. Provide an implicit warning about losing style customizations (related to Warn that customisations will be lost on style variation switch #45210, Custom colors are lost when styles are changed #48407, Style Variations: Add warning when custom styles will be lost #40561)
  5. Allow exporting, deleting styles

The following mockups take a stab at the above, and may in some cases replace them. Here's importing a file:

Import styles from file

  • Import file exists in ellipsis menu
  • Plus exists to create a style from scratch (separate future feature)

Styles from other themes can be surfaced:

Styles from other themes you have installed can also be leveraged

  • The "Theme styles" section acts as a ToolsPanel, showing by default the active theme styles, letting you toggle on styles from other installed themes.

Saving customizations:

Saving customizations

  • Activating a style from a theme doesn't automatically save it as a custom style.
  • But making any customizations to the style makes it show up under "Custom styles", with a blue dot. If you save using Multi Entity saving, or using the dropdown, the blue dot disappears.
  • The ellipsis under custom styles allow saving, deleting, exporting.

As a starting point, styles imported or copied from other themes retain their stylenames from those sources. But in the future, we could explore a create from scratch + rename flow, such as this:

Creating from scratch


Issue updated Nov 3.

Initial proposal

This issue has a great deal of overlap with #38333, but takes a slightly different approach in that it is meant to include a flow for importing and exporting from files. The goal is to use the same interface to accomplish three separate flows:

  1. Allow saving user variations for each bundled style (i.e. customized “dark” variation)
  2. Load style variations from a file (import)
  3. Copy global styles from another theme without switching to that theme (import)
  4. Export, to enable items 2 and 3

Incidentally, these flows may also solve #45210, and depending on feedback, we may merge this issue into 38333, or vice versa.

In the first case, a user has picked a style variation that's bundled with a theme, but has made no other customizations to it:

User has no customizations
  • Chosen style shows as active in the list of bundled theme styles
  • An ellipsis menu allows importing, exporting, and saving a style

If customizations are made to a style, or if a style is imported:

User has customizations
  • Customized style shows up in "Unsaved styles" section, clearly delineated as separate from the them bundled styles
  • Ellipsis menu shows uption to save or delete
  • If saved, the style will appear in a new section, called "Custom styles"
  • If further customizations are made, the "Unsaved styles" section appears again

This is a first iteration, let me know your thoughts.

@jasmussen jasmussen added Needs Design Feedback Needs general design feedback. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Oct 28, 2022
@jameskoster

This comment was marked as resolved.

@jasmussen

This comment was marked as resolved.

@jameskoster

This comment was marked as resolved.

@jameskoster

This comment was marked as resolved.

@jasmussen

This comment was marked as resolved.

@jameskoster

This comment was marked as resolved.

@jasmussen

This comment was marked as outdated.

@jameskoster

This comment was marked as resolved.

@scruffian
Copy link
Contributor

I had a slightly different but connected idea in #45452

@jasmussen

This comment was marked as outdated.

@jameskoster

This comment was marked as resolved.

@jasmussen

This comment was marked as resolved.

@jasmussen

This comment was marked as resolved.

@jameskoster

This comment was marked as resolved.

@jasmussen

This comment was marked as resolved.

@jasmussen jasmussen added Needs Dev Ready for, and needs developer efforts and removed Needs Design Feedback Needs general design feedback. labels Nov 3, 2022
@jasmussen
Copy link
Contributor Author

This issue has been updated and labelled "Needs Dev", as we've settled on a design that could likely work for a first iteration.

@carolinan
Copy link
Contributor

carolinan commented Jan 3, 2023

Currently, WP_REST_Global_Styles_Controller is limited to the active theme so it needs to be updated.

I assume that once a style from an installed but not active theme is selected and you save it, the intention is that it gets saved in the active themes global style option in the database.

I also assume that we need both the base theme.json and the style variation from the installed but not active themes.

How do we handle font files that are used in style variations, and are placed in the installed but not active theme?

  • It is possible that a style variation can be saved and the theme that has the font files is deleted.
  • It is also possible that the read/write permissions are not enough to allow copying the font files from that theme and place them in a wp-content/fonts folder or similar.

@jameskoster
Copy link
Contributor

Yes, I suspect both of those are possible albeit rare occurrences. Perhaps we need to update the font selection control so that it displays an error/warning if the selected font cannot be found?

@carolinan
Copy link
Contributor

Also should this include child themes?
I guess there are 3 options,
ignore child themes,
use a possibly partial style variation,
and fetching all 3: parent theme.json, child theme theme.json, child theme variations.

@ribaricplusplus
Copy link
Member

ribaricplusplus commented Jan 6, 2023

I am planning to take care of Save and Delete for user variations in #46952, covering point 1. from the main issue comment. I will probably not work on the other points but I'm assigning this to myself temporarily because working on import / export in parallel would be unfeasible.

@ribaricplusplus ribaricplusplus self-assigned this Jan 9, 2023
@ribaricplusplus ribaricplusplus removed the Needs Dev Ready for, and needs developer efforts label Jan 9, 2023
@annezazu
Copy link
Contributor

annezazu commented Jan 9, 2023

Thanks so much for jumping into this! Please share as you go where you might need help or reviews.

@unprintedch
Copy link

Great work, that is exactly what I was hoping for here #60386.
Is there some PR we can test?

@annezazu
Copy link
Contributor

annezazu commented Sep 9, 2024

@scruffian great job getting #63318 merged to create a new public function to expose variations from other themes. Where does that leave us in terms of what's next? I see some performance issues mentioned in the PR reviews btw.

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 Needs Dev Ready for, and needs developer efforts [Type] Enhancement A suggestion for improvement.
Projects
Status: 💻 Needs development
Development

No branches or pull requests

8 participants