Merge "Invalid ApplicationExceptionTest"
[portal.git] / portal-FE-common / src / styles / bootstrap / mixins / _breakpoints.scss
1 // Breakpoint viewport sizes and media queries.
2 //
3 // Breakpoints are defined as a map of (name: minimum width), order from small to large:
4 //
5 //    (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px)
6 //
7 // The map defined in the `$grid-breakpoints` global variable is used as the `$breakpoints` argument by default.
8
9 // Name of the next breakpoint, or null for the last breakpoint.
10 //
11 //    >> breakpoint-next(sm)
12 //    md
13 //    >> breakpoint-next(sm, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px))
14 //    md
15 //    >> breakpoint-next(sm, $breakpoint-names: (xs sm md lg xl))
16 //    md
17 @function breakpoint-next($name, $breakpoints: $grid-breakpoints, $breakpoint-names: map-keys($breakpoints)) {
18   $n: index($breakpoint-names, $name);
19   @return if($n < length($breakpoint-names), nth($breakpoint-names, $n + 1), null);
20 }
21
22 // Minimum breakpoint width. Null for the smallest (first) breakpoint.
23 //
24 //    >> breakpoint-min(sm, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px))
25 //    576px
26 @function breakpoint-min($name, $breakpoints: $grid-breakpoints) {
27   $min: map-get($breakpoints, $name);
28   @return if($min != 0, $min, null);
29 }
30
31 // Maximum breakpoint width. Null for the largest (last) breakpoint.
32 // The maximum value is calculated as the minimum of the next one less 0.01px
33 // to work around the limitations of `min-` and `max-` prefixes and viewports with fractional widths.
34 // See https://www.w3.org/TR/mediaqueries-4/#mq-min-max
35 //
36 //    >> breakpoint-max(sm, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px))
37 //    767px
38 @function breakpoint-max($name, $breakpoints: $grid-breakpoints) {
39   $next: breakpoint-next($name, $breakpoints);
40   @return if($next, breakpoint-min($next, $breakpoints) - .01px, null);
41 }
42
43 // Returns a blank string if smallest breakpoint, otherwise returns the name with a dash infront.
44 // Useful for making responsive utilities.
45 //
46 //    >> breakpoint-infix(xs, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px))
47 //    ""  (Returns a blank string)
48 //    >> breakpoint-infix(sm, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px))
49 //    "-sm"
50 @function breakpoint-infix($name, $breakpoints: $grid-breakpoints) {
51   @return if(breakpoint-min($name, $breakpoints) == null, "", "-#{$name}");
52 }
53
54 // Media of at least the minimum breakpoint width. No query for the smallest breakpoint.
55 // Makes the @content apply to the given breakpoint and wider.
56 @mixin media-breakpoint-up($name, $breakpoints: $grid-breakpoints) {
57   $min: breakpoint-min($name, $breakpoints);
58   @if $min {
59     @media (min-width: $min) {
60       @content;
61     }
62   } @else {
63     @content;
64   }
65 }
66
67 // Media of at most the maximum breakpoint width. No query for the largest breakpoint.
68 // Makes the @content apply to the given breakpoint and narrower.
69 @mixin media-breakpoint-down($name, $breakpoints: $grid-breakpoints) {
70   $max: breakpoint-max($name, $breakpoints);
71   @if $max {
72     @media (max-width: $max) {
73       @content;
74     }
75   } @else {
76     @content;
77   }
78 }
79
80 // Media that spans multiple breakpoint widths.
81 // Makes the @content apply between the min and max breakpoints
82 @mixin media-breakpoint-between($lower, $upper, $breakpoints: $grid-breakpoints) {
83   $min: breakpoint-min($lower, $breakpoints);
84   $max: breakpoint-max($upper, $breakpoints);
85
86   @if $min != null and $max != null {
87     @media (min-width: $min) and (max-width: $max) {
88       @content;
89     }
90   } @else if $max == null {
91     @include media-breakpoint-up($lower) {
92       @content;
93     }
94   } @else if $min == null {
95     @include media-breakpoint-down($upper) {
96       @content;
97     }
98   }
99 }
100
101 // Media between the breakpoint's minimum and maximum widths.
102 // No minimum for the smallest breakpoint, and no maximum for the largest one.
103 // Makes the @content apply only to the given breakpoint, not viewports any wider or narrower.
104 @mixin media-breakpoint-only($name, $breakpoints: $grid-breakpoints) {
105   $min: breakpoint-min($name, $breakpoints);
106   $max: breakpoint-max($name, $breakpoints);
107
108   @if $min != null and $max != null {
109     @media (min-width: $min) and (max-width: $max) {
110       @content;
111     }
112   } @else if $max == null {
113     @include media-breakpoint-up($name) {
114       @content;
115     }
116   } @else if $min == null {
117     @include media-breakpoint-down($name) {
118       @content;
119     }
120   }
121 }