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 style variations to the Site Editor #96

Closed
wants to merge 6 commits into from

Conversation

scruffian
Copy link
Contributor

@scruffian scruffian commented Jul 29, 2022

This adds style variation creation to the Site Editor:

Jul-29-2022.17-43-33.mp4

This adds a new JS package that allows us to integrate this tool more deeply into the Gutenberg Site Editor.

The initial step is to add the creation of style variations, but in the future we should move across other tools.

To test you need to use this Gutenberg PR: WordPress/gutenberg#42824

@scruffian
Copy link
Contributor Author

I also added blank theme creation to the site editor:

Screenshot 2022-08-01 at 12 11 10

Copy link
Contributor

@madhusudhand madhusudhand left a comment

Choose a reason for hiding this comment

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

Plugin is crashing on click of the button.

image

image

src/index.js Outdated
return (
<PanelBody>
<MenuGroup label={ __( 'Create style variation' ) }>
<TextControl onChange={ ( value ) => setVariationName( value ) } placeholder={ __( 'Variation name' ) }></TextControl>
Copy link
Contributor

Choose a reason for hiding this comment

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

May be a short description can be added to give the context of the feature.

Save user changes as a new style variation of the current theme

@scruffian
Copy link
Contributor Author

@madhusudhand @pbking sorry I forgot to mention that you also need this associated Gutenberg PR: WordPress/gutenberg#42824

Copy link
Contributor

@jffng jffng left a comment

Choose a reason for hiding this comment

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

This worked well for me in combination with the WordPress/gutenberg#42824.

If Gutenberg is deactivated, the editor crashes when I click on the Create Block Theme panel, so perhaps a check should be added for whether to initialize this panel.

src/index.js Outdated

const StyleVariations = () => {
const [ variationName, setVariationName ] = useState( '' );
const [ canReset, onReset ] = wp.editSite.useGlobalStylesReset();
Copy link
Contributor

Choose a reason for hiding this comment

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

It's nice for demo purposes but I'm wondering from a UX perspective, does it make sense to reset the styles when the variation is created?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's what we do in the PHP side of the tool.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally when in this perspective we could activate the variation (which would leave all of the styles as-set instead of resetting to default).

src/index.js Outdated

return (
<PanelBody>
<MenuGroup label={ __( 'Create style variation' ) }>
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a padding applied to this label that I think looks off, I think it should be just left aligned, if possible. Maybe that's a problem with the component though.

Screen Shot 2022-08-09 at 2 25 04 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I'd rather fix that in the component itself.

@pbking
Copy link
Contributor

pbking commented Aug 9, 2022

If Gutenberg is deactivated, the editor crashes when I click on the Create Block Theme panel, so perhaps a check should be added for whether to initialize this panel.

Yeah, definitely either need a check for capabilities or wait for that change to land in CORE to release this.

@scruffian
Copy link
Contributor Author

Yeah, definitely either need a check for capabilities or wait for that change to land in CORE to release this.

Done in dfbc74f.

Copy link
Contributor

@jffng jffng left a comment

Choose a reason for hiding this comment

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

Would like to see this one land since it makes designing a variation in the site editor so much easier, especially if you are switching around between versions / branches a lot.

@jffng
Copy link
Contributor

jffng commented Aug 11, 2022

Ah just as I green checked, I noticed one bug — when I try to save a variation with a space in its name, it 404s:

Screen Shot 2022-08-11 at 12 29 58 PM

scruffian and others added 5 commits July 20, 2023 18:28
save the variation locally

generate a zip with the variation

shanged wording, added script to toggle between forms

wording and paths

duplicate variations with the same name instead of replacing them

revert disconnected changes
What:
- Move Style Variations to secondary navigation screen
- Remove outdated API

Some of the removed code has to be re-worked using current APIs.i
@vcanales
Copy link
Member

It's been a while, so I took the liberty to bring this up to date removing some code that was breaking due to changes in the App. I also refactored it to reflect how other parts of the Plugin behave within the Site Editor. If @scruffian has no objections, I'd be happy to dedicate a bit of time to this.

@pbking
Copy link
Contributor

pbking commented Jul 21, 2023

I would love to see this wrap up and land. It was the inspiration and reference for other site editor changes but that never included variations! Would be keen to review or assist on wrapping this up.

@scruffian
Copy link
Contributor Author

I'm happy for anyone to take this over.

@madhusudhand
Copy link
Contributor

closing this in favour of #532

@vcanales vcanales deleted the update/add-to-site-editor branch May 23, 2024 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants