-
Notifications
You must be signed in to change notification settings - Fork 92
Add negative margins to top-level group and cover blocks #336
Conversation
@@ -99,6 +99,7 @@ a:active { | |||
body > .is-root-container, | |||
.edit-post-visual-editor__post-title-wrapper, | |||
.wp-block-group.alignfull, | |||
.wp-block-group.has-background, |
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.
With this PR active, how is this achievable? While editing the header part itself, I can see it's fullwidth, but within the Site Editor, it's not. Do we perhaps need to target within block template parts as well?And the frontend of the above: |
I wonder if that particular issue (the header being difficult to make fullwidth) is more related to Gutenberg? As it's not possible to set a template part to fullwidth, or even top-level blocks within it. If we could set that Group block as fullwidth, then the left/right negative margin would be applied properly at the top level. Instead, we are required to double-up Group blocks, just to set the group > group (or group > row) with a background color. Can't set a top-level block within a template part to fullwidth:Non top-level blocks can be fullwidth: |
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.
Gave this a pretty thorough shake, and in general I think the change looks good and works well. The CSS impact is minimal / highly targeted, and I don't notice any regressions when going through the patterns and templates.
When checking the pattern previews, I noticed something strange with the "About page with media on the left" pattern (which uses the media & text block, no group or cover). When we manually add the alignfull
class to a block that is not inheriting layout, it will not appear as full width in the preview, but it will appear full width when inserted if it's added at the root because of the theme's alignment CSS:
No alignment controls are present because the block is not inside a group that's inheriting layout. It's a bit weird to not have the ability to change the alignment, since the class is added manually. But maybe something to address / consider separately.
I think the header part needs to be set to inherit default layout, and the nested group block's alignment set to full. |
I think that one is unrelated to this PR. But it sounds like a bug. Would you mind sharing the steps to reproduce?
Yeah, but it's not possible to set a template to inherit default layout anymore. So you'd have to use a group block wrapper in there. In any case, I forgot about template parts initially. 🙃 Pull the new updates and give those a try. Should be better now. template-part.mp4 |
Yeah... We could write in some CSS to fix that, but since |
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.
Yeah, but it's not possible to set a template to inherit default layout anymore. So you'd have to use a group block wrapper in there.
I see. I was testing against the 5.9 RC, not Gutenberg trunk. Adding the template part specific CSS fixes the issue caused by template parts no longer being able to inherit layout, and works fine in 5.9 RC too.
Ah yes — last I saw, the change that removes that feature from template parts is going to be back ported to the next RC. 👍 |
I've done a bit more testing on my end, and it's still seeming solid. I'm going to merge it in. Thanks folks! |
Fixes #330.
I think we overlooked something important in #291: Top level Group blocks (when they have a background color) and Cover blocks should have negative margins applied in both the editor and the front end.
This came up while watching a user struggle with how to make an edge-to-edge header with a solid color background. This should be easy, but it wasn't. Our current rules only apply the negative margins to
alignfull
blocks, so they had to first add a top-level Group block in the site editor, set it toInherit default layout
, and then place a full-width group w/background color inside of that. It was not intuitive, and is the same hack noted in #330 (comment).Group Blocks with a background color, and Cover blocks already come with have their own padding. So when they're on the top level of the site editor, they don't need to use the outer padding. They can just go edge-to-edge.
Doing this doesn't seem to have any negative effect on our existing layouts or patterns.
To Test:
Also, do a sweep of existing templates and patterns to ensure they're still behaving as intended.
Screenshots
All blocks in these screenshots are at the top-level of the site editor: