forked from twbs/bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Breakpoints and container widths are now defined as maps.
- Loading branch information
Showing
9 changed files
with
163 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// Breakpoint viewport sizes and media queries. | ||
// | ||
// Breakpoints are defined as a map of (name: minimum width), order from small to large: | ||
// | ||
// (xs: 0, sm: 34rem, md: 45rem) | ||
// | ||
// The map defined in the `$grid-breakpoints` global variable is used as the `$breakpoints` argument by default. | ||
|
||
// Name of the next breakpoint, or null for the last breakpoint. | ||
// | ||
// >> breakpoint-next(sm) | ||
// md | ||
// >> breakpoint-next(sm, $breakpoints: (xs: 0, sm: 34rem, md: 45rem)) | ||
// md | ||
// >> breakpoint-next(sm, $breakpoint-names: (xs sm md)) | ||
// md | ||
@function breakpoint-next($name, $breakpoints: $grid-breakpoints, $breakpoint-names: map-keys($breakpoints)) { | ||
$n: index($breakpoint-names, $name); | ||
@return if($n < length($breakpoint-names), nth($breakpoint-names, $n + 1), null); | ||
} | ||
|
||
// Minimum breakpoint width. Null for the smallest (first) breakpoint. | ||
// | ||
// >> breakpoint-min(sm, (xs: 0, sm: 34rem, md: 45rem)) | ||
// 34rem | ||
@function breakpoint-min($name, $breakpoints: $grid-breakpoints) { | ||
$min: map-get($breakpoints, $name); | ||
@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.1. | ||
// | ||
// >> breakpoint-max(sm, (xs: 0, sm: 34rem, md: 45rem)) | ||
// 44.9rem | ||
@function breakpoint-max($name, $breakpoints: $grid-breakpoints) { | ||
$next: breakpoint-next($name, $breakpoints); | ||
@return if($next, breakpoint-min($next, $breakpoints) - 0.1, null); | ||
} | ||
|
||
// Media of at least the minimum breakpoint width. No query for the smallest breakpoint. | ||
@mixin media-breakpoint-min($name, $breakpoints: $grid-breakpoints) { | ||
$min: breakpoint-min($name, $breakpoints); | ||
@if $min { | ||
@media (min-width: $min) { | ||
@content; | ||
} | ||
} @else { | ||
@content; | ||
} | ||
} | ||
|
||
// Media of at most the maximum breakpoint width. No query for the largest breakpoint. | ||
@mixin media-breakpoint-max($name, $breakpoints: $grid-breakpoints) { | ||
$max: breakpoint-max($name, $breakpoints); | ||
@if $max { | ||
@media (max-width: $max) { | ||
@content; | ||
} | ||
} @else { | ||
@content; | ||
} | ||
} | ||
|
||
// Media between the breakpoint's minimum and maximum widths. | ||
// No minimum for the smallest breakpoint, and no maximum for the largest one. | ||
@mixin media-breakpoint-only($name, $breakpoints: $grid-breakpoints) { | ||
// Nested media query combination does not work in libsass yet | ||
// https://github.com/sass/libsass/issues/185 | ||
// Work around until the issue is resolved: | ||
$min: breakpoint-min($name, $breakpoints); | ||
$max: breakpoint-max($name, $breakpoints); | ||
@if $min and $max { | ||
@media (min-width: $min) and (max-width: $max) { | ||
@content; | ||
} | ||
} @else { | ||
// One of min or max is a no-op, so this branch is not affected by libsass#185 | ||
@include media-breakpoint-min($name, $breakpoints) { | ||
@include media-breakpoint-max($name, $breakpoints) { | ||
@content; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.