-
Notifications
You must be signed in to change notification settings - Fork 472
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
Dynamically update block editor layout and styling #1033
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great feature! Super useful. I love it.
The code for this looks good and the build pipeline works great. There are just a couple issues I noticed:
Issue 1
For some reason I get all the templates listed twice when trying to select a template. I'm on WP 5.0.2, and don't see anything immediately obvious that would be causing it. Some digging around determined that one template is e.g. `storefront/template-fullwidth.php` and the other is `template-fullwidth.php`. Can you reproduce this?Issue 2
- If the sidebar is active and you start with a full-width image on the full-width template:
- Then switch to the default template:
- Then switch back to the full-width template, the image is smaller than full-width and doesn't have the full-width attribute applied to it in the block editor or frontend. Same thing happens with the 'wide' image format.
I see now that the second issue I posted is actually a feature. :) In that case, feel free to ignore that one. The double page templates in the list is my main concern. |
@claudiulodro thanks for reviewing! As for your first issue, it looks like you might have ran I decided to spend some more time on this and made the decision to stop updating the block attributes data. Now, it only changes the value in the DOM. This way, if you have a block with To test:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep the double template issue was definitely that I must have run the deploy script at some point and had an extra copy of Storefront in the folder. Good sleuthing. Sorry for the wild goose chase. :)
The latest revision looks good. 👍 I think the latest behavior where it doesn't modify the image attributes when switching the page template is the way to go. It's much less confusing and will not cause issues when switching back-and-forth between the templates.
What does it do
There are two types of types of layout configuration in Storefront: with or without a sidebar.
Storefront is smart enough to automatically adapt its layout. If there are widgets in the main sidebar, then the content will adjust and display the sidebar. Otherwise, when there are no widgets in the sidebar, it will always display the full width layout.
On pages, it's also possible to use the full width template to allow the content to span the full width of the site.
This PR replicates this behaviour in the new blocks editor:
wide
andfull
are made available.wide
andfull
options are dynamically removed and any existing blocks with this alignment set will have it updated to default.How to test
Also:
Other
assets/js/src/editor.js
is written in ES6 and then when building with Grunt converted to ES5 via babel toassets/js/editor.js
. This is a bit confusing but allows us to write modern JavaScript while maintaining the current pipeline in Grunt.