-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Columns - fix margins, keep 2-col breakpoint #12816
Changes from 5 commits
f7c8f1f
2cb1ffb
4f54644
cd9873d
9ccb87d
78c58d3
4ab8745
28cd81d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,7 @@ | |
// Responsiveness: Allow wrapping on mobile. | ||
flex-wrap: wrap; | ||
|
||
@include break-small() { | ||
@include break-medium() { | ||
flex-wrap: nowrap; | ||
} | ||
|
||
|
@@ -89,27 +89,43 @@ | |
|
||
// Beyond mobile, allow 2 columns. | ||
@include break-small() { | ||
flex-basis: 50%; | ||
// Size should be half the available width, minus the margins added below. | ||
// In the editor, we also need to account for additional block padding. | ||
flex-basis: calc(50% - #{$grid-size-large * 2} - #{$block-padding * 2}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I took a stab at fixing the margin issue I noted. When I reverted this back to Keep in mind that the editor uses a lot of negative margins left and right so as to make available a selectable/hoverable space left and right of blocks. This might be why the additional grid stuff isn't necessary here. Am I missing something? This is with Again, I have no doubt that this is necessary on the front-end, but I think it's what's causing issues in the editor. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Ah good call. But if you change "break-medium" back to "break-small" here: https://github.com/WordPress/gutenberg/pull/12816/files#diff-49ac41bc72e24e343a451fe254801c0fR38 — it works again: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At the small (2-column) breakpoint… I think as long as there's a margin b/w the columns, then There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Possibly. But keep in mind that there is negative margins applied to columns in the editor only, to ensure that this looks right. Keep in mind the markup in the editor is different from the markup on the frontend — there are a lot more divs in the editor to enable the various tools for each block. So until we have access to something like Did you try flex-basis: 50%? For me it seemed to fix the issue of the extra right margin, but there could be situations I haven't accounted for there. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For me I think the problem was actually that at the medium breakpoint, I had reset the ODD/EVEN margins to It gets a little confusing with all the nesting, but I think that's right. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This only works if you also set the wrap property to nowrap as noted in #12816 (comment). But I'm going to take a look at your latest push, see if that fixes it! |
||
flex-grow: 0; | ||
} | ||
|
||
// Add space between columns. Themes can customize this if they wish to work differently. | ||
// This has to match the same padding applied in style.scss. | ||
// Only apply this beyond the mobile breakpoint, as there's only a single column on mobile. | ||
|
||
// 2 columns at this breakpoint, and items beyond the second will wrap. | ||
@include break-small() { | ||
&:nth-child(odd) { | ||
margin-right: $grid-size-large * 2; | ||
} | ||
|
||
&:nth-child(even) { | ||
margin-left: $grid-size-large * 2; | ||
} | ||
} | ||
|
||
@include break-small() { | ||
@include break-medium() { | ||
// Reset odd, even margins from small breakpoint. | ||
&:nth-child(even) { | ||
margin-left: initial; | ||
} | ||
|
||
&:nth-child(odd) { | ||
margin-right: initial; | ||
} | ||
|
||
// Add left margin to all but first column | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs a period. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks. |
||
&:not(:first-child) { | ||
margin-left: $grid-size-large * 2; | ||
} | ||
|
||
// Add right margin to all but last column. | ||
&:not(:last-child) { | ||
margin-right: $grid-size-large * 2; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,9 @@ | |
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we change the shorthand A little redundant. This is essentially what we currently have:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good call there I'd say. I still always have to lookup what There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, I don't think we need to set |
||
// Beyond mobile, allow 2 columns. | ||
@include break-small() { | ||
flex-basis: 50%; | ||
|
||
// Size should be half the available width, minus the margins added below. | ||
flex-basis: calc(50% - #{$grid-size-large * 2}); | ||
flex-grow: 0; | ||
} | ||
|
||
|
@@ -31,18 +33,35 @@ | |
|
||
// Add space between columns. Themes can customize this if they wish to work differently. | ||
// Only apply this beyond the mobile breakpoint, as there's only a single column on mobile. | ||
|
||
// 2 columns at this breakpoint, and items beyond the second will wrap. | ||
@include break-small() { | ||
&:nth-child(even) { | ||
margin-left: $grid-size-large * 2; | ||
} | ||
|
||
&:nth-child(odd) { | ||
margin-right: $grid-size-large * 2; | ||
} | ||
} | ||
|
||
// All columns fit in one row at this breakpoint. | ||
@include break-medium() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This Any interest in simplifying this? Something along these lines maybe: @include break-medium() {
// Fill in the left and right margin holes left by the previous small breakpoint.
// First column already has a margin-right and no margin-left.
&:not(:first-child) {
margin-left: $grid-size-large;
margin-right: $grid-size-large;
}
// Remove right margin on last column.
&:last-child {
margin-right: 0;
}
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see the value in simplifying things, but I also see the value in not changing the logic once a block is already in the wild. I'd defer to @jasmussen and others on this. |
||
// Reset odd, even margins from small breakpoint. | ||
&:nth-child(even) { | ||
margin-left: $grid-size-large * 2; | ||
margin-left: initial; | ||
} | ||
|
||
&:nth-child(odd) { | ||
margin-right: initial; | ||
} | ||
|
||
// Add left margin to all but first column. | ||
&:not(:first-child) { | ||
margin-left: $grid-size-large * 2; | ||
} | ||
|
||
// Add right margin to all but last column. | ||
&:not(:last-child) { | ||
margin-right: $grid-size-large * 2; | ||
} | ||
|
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.
We discussed this a little bit already, but what is the context for changing this to medium?
To my understanding the ideal situation is this:
To me this says that Mobile should wrap, but anything above mobile should not wrap.
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.
The reason to change this to medium is so that the small-to-medium breakpoint (600px - 782px) can wrap after the EVEN columns.
If we set 'nowrap' at the Small breakpoint (600px), then the small-to-medium breakpoint doesn't work.
flex-wrap:nowrap
will prevent the columns from wrapping.I'm not opposed to removing the small-to-medium breakpoint entirely; I just didn't think that was the original intent.
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.
That's a solid point. Thank you for clarifying, and for the patience.