-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
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
Change media-breakpoint-down implementation #29148
Conversation
Can't we keep the only |
453201d
to
8c70648
Compare
Ok, I just restored |
8c70648
to
e1dc1bc
Compare
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.
LGTM but please wait for another approval from @twbs/css-review
@MartijnCuppens this needs a rebase @twbs/css-review this needs a review please :) |
337cc3c
to
d386f55
Compare
I'm understanding that the current specification is based on device size: https://getbootstrap.com/docs/4.4/layout/overview/#responsive-breakpoints The suggestion of this PR is to change it to breakpoint based. I summarized my understanding in the following diagram: Neither theory is wrong, but the current specification is bit complex when considered in the code base. Actually I’ve felt confusing before. I have no objection to change, but the only concern is incompatibility. @mdo Thought? |
I understand the reasoning for the change, and while I think it would take a bit to get used to thinking about how these work from the new perspective, I agree with @ysds that compatibility is a concern here, as anyone upgrading to v5 - or even folks used to how v4 worked - might not immediately notice the slight change to how their breakpoints are working when compiling with v5. One possible solution to avoid potential subtle incompatibility issues would be to rename the mixins as part of the change, forcing users to address the change. Something along these lines: I happen to also think these names better reflect the fact that they're operating on a breakpoint as a specific value rather than a range, but that could just be me thinking that. |
BTW, being this will only land in v5, it can certainly be a breaking change, and that's OK. We just need to remember to highlight it. |
To replace If we can't come up with (or agree on) a better name to replace |
Also possible to change the head part e.g. |
@ysds' proposal feels like a good idea, so than we have:
I'll change it within a couple of days. |
I wouldn't go with this approach personally. Anyway, better wait for @mdo's feedback |
@MartijnCuppens can you fix the conflicts? @mdo: friendly ping |
For a refresher on the breakpoints, definitely read the docs at https://getbootstrap.com/docs/4.4/layout/overview/#responsive-breakpoints as @ysds says. I might need to reread them a few more times myself lol. Here's a snapshot comparison of each type of media query mixin we have today, and it's CSS equivalent. @include media-breakpoint-up(sm) { ... }
@media (min-width: 576px) { ... }
@include media-breakpoint-down(sm) { ... }
@media (max-width: 767.98px) { ... }
@include media-breakpoint-only(sm) { ... }
@media (min-width: 576px) and (max-width: 767.98px) { ... }
@include media-breakpoint-between(md, xl) { ... }
@media (min-width: 768px) and (max-width: 1199.98px) { ... } I think @ysds got one detail wrong in the v4 diagram— With this PR in particular, I don't think this is a behavior we should change in v5. The fundamental basis for these mixins is that I could see us renaming these, or perhaps providing aliases (is that a thing?), to be much more descriptive. Something like this maybe?
Nothing but the names would change here though as I understand it. Thoughts? |
My diagram show it (include or not) with black and white circles 😉 v4: @include media-breakpoint-between(sm, md) { ... } is @media (min-width: 576px) and (max-width: 991.98px) { ... } |
0965c0c
to
d763947
Compare
Ok, switched this to @mdo s suggestions. Wouldn't work with aliases, it 'll just pollute our code base. |
@MartijnCuppens this needs a rebase. @mdo let us know what you think |
I prefer #28683 will add classes such as |
5b7fdcb
to
0431aa2
Compare
I've removed the renames and just continued with the initial idea of using the the current bp instead of the next. If the renaming of mixins is needed, we could cover this in another PR. It seems this way of using the @twbs/css-review, could you review this? |
0431aa2
to
c0352f8
Compare
@MartijnCuppens Sorry for late approval, I say we bite the bullet on this and ship it in v5. Any chance for a rebase? |
- The `media-breakpoint-down()` uses the breakpoint itself instead of the next breakpoint. Use `media-breakpoint-down(lg)` instead of `media-breakpoint-down(md)` to target viewports smaller than the `lg` breakpoint. - The `media-breakpoint-between()` mixin's second parameter also uses the breakpoint itself instead of the next breakpoint. Use `media-between(sm, lg)` instead of `media-breakpoint-between(sm, md)` to target viewports between the `sm` and `lg` breakpoints.
c0352f8
to
e1c47f0
Compare
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.
Thanks!
media-breakpoint-down()
always used the next breakpoint, so if you want to target viewports smaller thanlg
(992px) you needed to use:I've made another codepen to illustrate the problem:
https://codepen.io/MartijnCuppens/pen/pMNjaN?editors=1100
In this PR, I've changed the implementation to use the breakpoint itself. I've also dropped the
media-breakpoint-only()
mixin since we do not use the "breakpoint zone" approach like we did in v3.The new implementation looks like this:
https://codepen.io/MartijnCuppens/pen/MNBqjY?editors=1100
To simplify reviews: this is the difference in generated css, some blocks are just shifted:
https://www.diffchecker.com/2ZUTxc1P (updated June 14th)