| Línea 1... |
Línea 1... |
| 1 |
// Breakpoint viewport sizes and media queries.
|
1 |
// Breakpoint viewport sizes and media queries.
|
| 2 |
//
|
2 |
//
|
| 3 |
// Breakpoints are defined as a map of (name: minimum width), order from small to large:
|
3 |
// Breakpoints are defined as a map of (name: minimum width), order from small to large:
|
| 4 |
//
|
4 |
//
|
| 5 |
// (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px)
|
5 |
// (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px, xxl: 1400px)
|
| 6 |
//
|
6 |
//
|
| 7 |
// The map defined in the `$grid-breakpoints` global variable is used as the `$breakpoints` argument by default.
|
7 |
// The map defined in the `$grid-breakpoints` global variable is used as the `$breakpoints` argument by default.
|
| Línea 8... |
Línea 8... |
| 8 |
|
8 |
|
| 9 |
// Name of the next breakpoint, or null for the last breakpoint.
|
9 |
// Name of the next breakpoint, or null for the last breakpoint.
|
| 10 |
//
|
10 |
//
|
| 11 |
// >> breakpoint-next(sm)
|
11 |
// >> breakpoint-next(sm)
|
| 12 |
// md
|
12 |
// md
|
| 13 |
// >> breakpoint-next(sm, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px))
|
13 |
// >> breakpoint-next(sm, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px, xxl: 1400px))
|
| 14 |
// md
|
14 |
// md
|
| 15 |
// >> breakpoint-next(sm, $breakpoint-names: (xs sm md lg xl))
|
15 |
// >> breakpoint-next(sm, $breakpoint-names: (xs sm md lg xl xxl))
|
| 16 |
// md
|
16 |
// md
|
| 17 |
@function breakpoint-next($name, $breakpoints: $grid-breakpoints, $breakpoint-names: map-keys($breakpoints)) {
|
17 |
@function breakpoint-next($name, $breakpoints: $grid-breakpoints, $breakpoint-names: map-keys($breakpoints)) {
|
| - |
|
18 |
$n: index($breakpoint-names, $name);
|
| - |
|
19 |
@if not $n {
|
| - |
|
20 |
@error "breakpoint `#{$name}` not found in `#{$breakpoints}`";
|
| 18 |
$n: index($breakpoint-names, $name);
|
21 |
}
|
| 19 |
@return if($n != null and $n < length($breakpoint-names), nth($breakpoint-names, $n + 1), null);
|
22 |
@return if($n < length($breakpoint-names), nth($breakpoint-names, $n + 1), null);
|
| Línea 20... |
Línea 23... |
| 20 |
}
|
23 |
}
|
| 21 |
|
24 |
|
| 22 |
// Minimum breakpoint width. Null for the smallest (first) breakpoint.
|
25 |
// Minimum breakpoint width. Null for the smallest (first) breakpoint.
|
| 23 |
//
|
26 |
//
|
| 24 |
// >> breakpoint-min(sm, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px))
|
27 |
// >> breakpoint-min(sm, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px, xxl: 1400px))
|
| 25 |
// 576px
|
28 |
// 576px
|
| 26 |
@function breakpoint-min($name, $breakpoints: $grid-breakpoints) {
|
29 |
@function breakpoint-min($name, $breakpoints: $grid-breakpoints) {
|
| 27 |
$min: map-get($breakpoints, $name);
|
30 |
$min: map-get($breakpoints, $name);
|
| Línea 28... |
Línea 31... |
| 28 |
@return if($min != 0, $min, null);
|
31 |
@return if($min != 0, $min, null);
|
| 29 |
}
|
32 |
}
|
| 30 |
|
33 |
|
| 31 |
// Maximum breakpoint width. Null for the largest (last) breakpoint.
|
34 |
// Maximum breakpoint width.
|
| 32 |
// The maximum value is calculated as the minimum of the next one less 0.02px
|
35 |
// The maximum value is reduced by 0.02px to work around the limitations of
|
| 33 |
// to work around the limitations of `min-` and `max-` prefixes and viewports with fractional widths.
|
36 |
// `min-` and `max-` prefixes and viewports with fractional widths.
|
| 34 |
// See https://www.w3.org/TR/mediaqueries-4/#mq-min-max
|
37 |
// See https://www.w3.org/TR/mediaqueries-4/#mq-min-max
|
| 35 |
// Uses 0.02px rather than 0.01px to work around a current rounding bug in Safari.
|
38 |
// Uses 0.02px rather than 0.01px to work around a current rounding bug in Safari.
|
| 36 |
// See https://bugs.webkit.org/show_bug.cgi?id=178261
|
39 |
// See https://bugs.webkit.org/show_bug.cgi?id=178261
|
| 37 |
//
|
40 |
//
|
| 38 |
// >> breakpoint-max(sm, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px))
|
41 |
// >> breakpoint-max(md, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px, xxl: 1400px))
|
| 39 |
// 767.98px
|
42 |
// 767.98px
|
| 40 |
@function breakpoint-max($name, $breakpoints: $grid-breakpoints) {
|
43 |
@function breakpoint-max($name, $breakpoints: $grid-breakpoints) {
|
| Línea 41... |
Línea 44... |
| 41 |
$next: breakpoint-next($name, $breakpoints);
|
44 |
$max: map-get($breakpoints, $name);
|
| 42 |
@return if($next, breakpoint-min($next, $breakpoints) - .02, null);
|
45 |
@return if($max and $max > 0, $max - .02, null);
|
| 43 |
}
|
46 |
}
|
| 44 |
|
47 |
|
| 45 |
// Returns a blank string if smallest breakpoint, otherwise returns the name with a dash in front.
|
48 |
// Returns a blank string if smallest breakpoint, otherwise returns the name with a dash in front.
|
| 46 |
// Useful for making responsive utilities.
|
49 |
// Useful for making responsive utilities.
|
| 47 |
//
|
50 |
//
|
| 48 |
// >> breakpoint-infix(xs, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px))
|
51 |
// >> breakpoint-infix(xs, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px, xxl: 1400px))
|
| 49 |
// "" (Returns a blank string)
|
52 |
// "" (Returns a blank string)
|
| 50 |
// >> breakpoint-infix(sm, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px))
|
53 |
// >> breakpoint-infix(sm, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px, xxl: 1400px))
|
| Línea 102... |
Línea 105... |
| 102 |
|
105 |
|
| 103 |
// Media between the breakpoint's minimum and maximum widths.
|
106 |
// Media between the breakpoint's minimum and maximum widths.
|
| 104 |
// No minimum for the smallest breakpoint, and no maximum for the largest one.
|
107 |
// No minimum for the smallest breakpoint, and no maximum for the largest one.
|
| 105 |
// Makes the @content apply only to the given breakpoint, not viewports any wider or narrower.
|
108 |
// Makes the @content apply only to the given breakpoint, not viewports any wider or narrower.
|
| 106 |
@mixin media-breakpoint-only($name, $breakpoints: $grid-breakpoints) {
|
109 |
@mixin media-breakpoint-only($name, $breakpoints: $grid-breakpoints) {
|
| - |
|
110 |
$min: breakpoint-min($name, $breakpoints);
|
| 107 |
$min: breakpoint-min($name, $breakpoints);
|
111 |
$next: breakpoint-next($name, $breakpoints);
|
| Línea 108... |
Línea 112... |
| 108 |
$max: breakpoint-max($name, $breakpoints);
|
112 |
$max: breakpoint-max($next, $breakpoints);
|
| 109 |
|
113 |
|
| 110 |
@if $min != null and $max != null {
|
114 |
@if $min != null and $max != null {
|
| 111 |
@media (min-width: $min) and (max-width: $max) {
|
115 |
@media (min-width: $min) and (max-width: $max) {
|
| 112 |
@content;
|
116 |
@content;
|
| 113 |
}
|
117 |
}
|
| 114 |
} @else if $max == null {
|
118 |
} @else if $max == null {
|
| 115 |
@include media-breakpoint-up($name, $breakpoints) {
|
119 |
@include media-breakpoint-up($name, $breakpoints) {
|
| 116 |
@content;
|
120 |
@content;
|
| 117 |
}
|
121 |
}
|
| 118 |
} @else if $min == null {
|
122 |
} @else if $min == null {
|
| 119 |
@include media-breakpoint-down($name, $breakpoints) {
|
123 |
@include media-breakpoint-down($next, $breakpoints) {
|
| 120 |
@content;
|
124 |
@content;
|
| 121 |
}
|
125 |
}
|