]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Change breakpoint-max implementation
authorMartijn Cuppens <martijn.cuppens@gmail.com>
Sat, 18 Apr 2020 11:02:26 +0000 (13:02 +0200)
committerMark Otto <otto@github.com>
Sun, 14 Jun 2020 21:50:47 +0000 (14:50 -0700)
- 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.

scss/_modal.scss
scss/_tables.scss
scss/mixins/_breakpoints.scss
site/assets/scss/_content.scss
site/assets/scss/_navbar.scss
site/assets/scss/_subnav.scss
site/content/docs/5.0/layout/breakpoints.md
site/content/docs/5.0/migration.md

index 49f27d304a50fe7c739b1b1b911637379e3fe8c6..44519724e5159f03bfc98e5044ec49ad5d955e28 100644 (file)
 }
 
 @each $breakpoint in map-keys($grid-breakpoints) {
-  $next-breakpoint: breakpoint-next($breakpoint);
-  $postfix: if(breakpoint-max($breakpoint, $grid-breakpoints) == null, "", "-#{$next-breakpoint}-down");
+  $infix: breakpoint-infix($breakpoint, $grid-breakpoints);
+  $postfix: if($infix != "", $infix + "-down", "");
 
   @include media-breakpoint-down($breakpoint) {
     .modal-fullscreen#{$postfix} {
index 1250a36c18293fc34df2207369829cde26207aa2..5ae45ffe8e5b80a4cd08c391728dadcc7f9ecc3b 100644 (file)
 // size of where your table will overflow.
 
 @each $breakpoint in map-keys($grid-breakpoints) {
-  $next: breakpoint-next($breakpoint, $grid-breakpoints);
-  $infix: breakpoint-infix($next, $grid-breakpoints);
+  $infix: breakpoint-infix($breakpoint, $grid-breakpoints);
 
   @include media-breakpoint-down($breakpoint) {
     .table-responsive#{$infix} {
index 81f8ffb2819a3bbdb3afa0e1fe71803470f0d477..66a0050c1b34101b7123622f190a3f6ce56859a3 100644 (file)
   @return if($min != 0, $min, null);
 }
 
-// Maximum breakpoint width. Null for the largest (last) breakpoint.
-// The maximum value is calculated as the minimum of the next one less 0.02px
-// to work around the limitations of `min-` and `max-` prefixes and viewports with fractional widths.
+// Maximum breakpoint width.
+// The maximum value is reduced by 0.02px to work around the limitations of
+// `min-` and `max-` prefixes and viewports with fractional widths.
 // See https://www.w3.org/TR/mediaqueries-4/#mq-min-max
 // Uses 0.02px rather than 0.01px to work around a current rounding bug in Safari.
 // See https://bugs.webkit.org/show_bug.cgi?id=178261
 //
-//    >> breakpoint-max(sm, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px))
+//    >> breakpoint-max(md, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px))
 //    767.98px
 @function breakpoint-max($name, $breakpoints: $grid-breakpoints) {
-  $next: breakpoint-next($name, $breakpoints);
-  @return if($next, breakpoint-min($next, $breakpoints) - .02, null);
+  $max: map-get($breakpoints, $name);
+  @return if($max and $max > 0, $max - .02, null);
 }
 
 // Returns a blank string if smallest breakpoint, otherwise returns the name with a dash in front.
 // Makes the @content apply only to the given breakpoint, not viewports any wider or narrower.
 @mixin media-breakpoint-only($name, $breakpoints: $grid-breakpoints) {
   $min: breakpoint-min($name, $breakpoints);
-  $max: breakpoint-max($name, $breakpoints);
+  $max: breakpoint-max(breakpoint-next($name, $breakpoints));
 
   @if $min != null and $max != null {
     @media (min-width: $min) and (max-width: $max) {
index 4e744895fd8e1bbad97adb58f8281ffb02cfb564..f238fdf7273c6550e4c052338b14ced2d2a75e8b 100644 (file)
@@ -29,7 +29,7 @@
     margin-bottom: 1.5rem;
     @include font-size(.875rem);
 
-    @include media-breakpoint-down(md) {
+    @include media-breakpoint-down(lg) {
       display: block;
       overflow-x: auto;
 
index 54d0c425c7e468342a09a57232f24ff2489f09a3..1ba779f93727f04e1b19c97e2d61588c8db62ce2 100644 (file)
@@ -2,7 +2,7 @@
   padding: .625rem 0;
   background-color: $bd-purple-bright;
 
-  @include media-breakpoint-down(md) {
+  @include media-breakpoint-down(lg) {
     .navbar-nav-scroll {
       width: 100%;
 
index e3ce8ba14ceb6d4ba995da88b39319e325f406fd..89c14b3821845f94968e6a6361fbb0d726011598 100644 (file)
@@ -26,7 +26,7 @@
 }
 
 .bd-search {
-  @include media-breakpoint-down(sm) {
+  @include media-breakpoint-down(md) {
     width: 100%;
   }
 
index 3fa3513ef5d0912ef8da05043bb86eb4314844eb..3d61ad67cd7bd9facc2d1736cb7c04ecce208cf3 100644 (file)
@@ -127,12 +127,12 @@ These Sass mixins translate in our compiled CSS using the values declared in our
 We occasionally use media queries that go in the other direction (the given screen size *or smaller*):
 
 {{< highlight scss >}}
-@include media-breakpoint-down(xs) { ... }
+// No media query necessary for xs breakpoint as it's effectively `@media (max-width: 0) { ... }`
 @include media-breakpoint-down(sm) { ... }
 @include media-breakpoint-down(md) { ... }
 @include media-breakpoint-down(lg) { ... }
 @include media-breakpoint-down(xl) { ... }
-// No media query necessary for xxl breakpoint as it has no upper bound on its width
+@include media-breakpoint-down(xxl) { ... }
 
 // Example: Style from medium breakpoint and down
 @include media-breakpoint-down(md) {
@@ -181,18 +181,25 @@ There are also media queries and mixins for targeting a single segment of screen
 @include media-breakpoint-only(xxl) { ... }
 {{< /highlight >}}
 
-Similarly, media queries may span multiple breakpoint widths:
+For example the `@include media-breakpoint-only(md) { ... }` will result in :
 
 {{< highlight scss >}}
-// Example
-// Apply styles starting from medium devices and up to extra large devices
-@media (min-width: 768px) and (max-width: 1199.98px) { ... }
+@media (min-width: 768px) and (max-width: 991.98px) { ... }
 {{< /highlight >}}
 
 ### Between breakpoints
 
-The Sass mixin for targeting the same screen size range would be:
+Similarly, media queries may span multiple breakpoint widths:
 
 {{< highlight scss >}}
 @include media-breakpoint-between(md, xl) { ... }
 {{< /highlight >}}
+
+Which results in:
+
+{{< highlight scss >}}
+// Example
+// Apply styles starting from medium devices and up to extra large devices
+@media (min-width: 768px) and (max-width: 1199.98px) { ... }
+{{< /highlight >}}
+
index 998dd9974e73ef6f82bdfb6c002b924b9df89e5b..dbb649bb1182494dcb50f9290366a0d0fa9d556e 100644 (file)
@@ -48,6 +48,8 @@ Changes to our source Sass files and compiled CSS.
   - `$yiq-text-dark` and `$yiq-text-light` are respectively renamed to `$color-contrast-dark` and `$color-contrast-light`.
 - Linear gradients are simplified when gradients are enabled and therefore, `gradient-bg()` now only accepts an optional `$color` parameter.
 - The `bg-gradient-variant()` mixin is removed since the `.bg-gradient` class can now be used to add gradients to elements instead of the `.bg-gradient-*` classes.
+- 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.
 
 ## JavaScript