-
Notifications
You must be signed in to change notification settings - Fork 92
Try: add padding CSS rules instead of in the templates #291
Conversation
In general, this is looking promising. I know this is in progress, but leaving a few notes here: Many of our full-width patterns provide their own padding to ensure their inner content doesn't bump up against the edges. But currently, they are bumping up against the edges even so: Also, I think we need to be more specific about these rules. Here's an example of the post content placed inside of a column. As you can see, the left/right negative margin is being applied when it shouldn't be: |
Thanks @kjellr! Generally, I've found in most cases the only problem is that we are applying full width where we really don't need to do so. Such is the case of the first pattern that you mention (I've just fixed that). I'll have a look at the other case, but I think we could use as many eyes on this as possible so we cover all the possible cases. I'll clean up this PR so that it's ready for review. |
Could be. But we also need to ensure there are fallbacks in place because we can't control what weird stuff other people do. This is exactly why the layout rules tend to get so complicated. 😅 |
@kjellr how did you manage to get that full width item inside the two column layout? it doesn't let me: |
I set the Query block there to inherit the default layout. Generally that's a bad idea in this setup, but I was trying to break it and find holes. 😄 When I did this, it looked fine in the editor, but broke in the front end. |
I pushed a few small fixes to templates. In general, this is looking pretty good — I've been running through a bunch of content and haven't found any major errors. We should try some tests where there are alignfull items inside of columns though, cause I expect there could be issues. I'm going to mark it as ready for a true review. |
I introduced the exception for columns, I think this is the intended behavior, right? This is the markup I sued on the example above:
|
That looks about right to me. A couple general questions I thought of this morning:
|
Ugh, I just noticed the 1 column example above is not correct, I'll have another pass at that. |
I don't think so, no. It needs more testing, to see if we've missed something somewhere we don't want the negative margins besides the columns case. The idea for GB was to be able to handle the padding variable with a built-in variable so themes could opt-in into this, else you will break themes that implement this differently or don't want this behavior at all.
I don't know what you mean exactly, what implementation? |
@kjellr for the case of a full width block inside a one column that is not full width, the current behavior doesn't make the inner block go all the way to the borders because of the fixed width of the parent so I don't think we need a rule for those. I'm removing that exception |
This is ready for another look, I don't have any broken cases in my arsenal, please try and break this |
What I'm seeing is that the alignfull on that block is only working because the block has the class (in the front), but that block doesn't have alignment options showing up on the toolbar, so the editor doesn't add the data attribute that we are targeting in the editor. So I think that's a case of refactoring the template part, do you see it somewhere else? |
Ok I see, we have to add an additional group wrapper there. 😅 Pushed 6210863 to take care of that. |
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.
Still forming opinions on whether I think it's a generally a good idea to introduce these global rules to the theme, but right now I am noticing some regressions:
The home page header is getting some Gutenberg padding rules applying to it now, note the .wp-group-block:where
rule:
The default footer lacks padding on smaller viewports:
The default header appears at default instead of wide width:
48ff11a
to
395e093
Compare
I made three changes to try and resolve the issues reported above:
|
*/ | ||
|
||
.wp-site-blocks, | ||
.is-root-container, |
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.
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, I believe is-root-container
is used in multiple places. We should switch to something else or be more specific.
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.
I just pushed a potential fix in c4a80d3. It uses more specific selectors, but also required specifying both the root container for the site editor and for the post/page editor.
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.
Hmm actually, now that I'm looking closer I'm not sure that'll do it. 😕
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.
😕 It doesn't. Reverting that commit.
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.
Ok, after some further digging, I can see that this is basically a re-creation of this issue: WordPress/gutenberg#33248.
Basically, the Query block renders using some nested DOM elements, and that causes this duplicate selector where it shouldn't be. In the post/page editor, Gutenberg itself provides some is-root-container
styles that cause the same behavior you're seeing here.
Since WordPress/gutenberg#33248 is listed as a must-have for 5.9, and is currently in progress I think we're ok to push through with this bug present for now.
TT2 is my favorite theme in years, in part because it's able to do so much with just blocks alone. It's clearly shown the need to solve this at the block editor level. It's also shown how tricky it is to get that right, and so I think it's good to buy some time with this solution. Hopefully the usage and rules can help us zero in on the right heuristic to implement. As for the specific rules, it's definitely a little hard to parse if you haven't built a ton of the CSS. At a high level, the code looks good for me, and in testing, things look right to me: I also tried some patterns out, and it all appears to work well. The GIF was too big, so it's here. I would love for the clamp rules to be absorbed by the system as well — the inability to see or intuitively edit the some of the paddings feels a little janky. But that's a separate issue, and probably not one that needs solving in the near future. Ultimately, if we go with this approach, which as noted I think is good to do for the time being, it seems okay to merge soon and then keep an eye out for anything that might need following up on. |
This reverts commit c4a80d3.
Thanks for the testing! I also tested with the current Site Padding implementation, and it works fine... it just adds padding to the outside of all this:
I'd like to reiterate what I said over in this other thread: This is not our ideal solution, but it's the least complicated one for today. It's a handful of CSS rules, and it generally works without the user changing their behavior or opting into anything. The end goal is to get a solution merged into Gutenberg, but I think this is a first step towards that and is worth testing during the upcoming Beta cycle. |
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.
I think let's bring this since we've noted it as being a temporary solution, and have some consensus that this the best tradeoff to achieve the intended design result with the current tools available.
Kudos @MaggieCabrera for the PR and @jasmussen for all the testing and feedback!
Thank you all for testing this, it's a complicated problem! |
Hey all 👋 — love this. I noticed that there's a discrepancy between the use of the spacing.outer var and the padding set by various patterns. If you modify the outer value in theme.json, you'll see that the patterns don't adjust as well (as many set their own padding left/right values. I took a stab at it in #310 — which lets the patterns adapt to the outer value. Let me know what you think :) |
This PR provides an interim solution to the padding problem that eventually will be solved in Gutenberg (WordPress/gutenberg#35607). This leverages a custom outer spacing variable that will be absorbed with the future variable implemented for the editor plus a series of CSS rules that will eventually disappear as the editor provides a global solution instead.
To test this check that the full width blocks all over the theme go all the way to the borders of the viewport while the rest of the site maintains a padding on mobile to stop content from extending. The editor should show the same as the frontend does.
Alternative to #289
Addresses #234