1 // breakpoints.scss v1.0 | @ajlkn | MIT licensed */
7 $breakpoints: () !global;
12 /// @param {map} $x Breakpoints.
13 @mixin breakpoints($x: ()) {
14 $breakpoints: $x !global;
17 /// Wraps @content in a @media block targeting a specific orientation.
18 /// @param {string} $orientation Orientation.
19 @mixin orientation($orientation) {
20 @media screen and (orientation: #{$orientation}) {
25 /// Wraps @content in a @media block using a given query.
26 /// @param {string} $query Query.
27 @mixin breakpoint($query: null) {
33 // Determine operator, breakpoint.
35 // Greater than or equal.
36 @if (str-slice($query, 0, 2) == '>=') {
39 $breakpoint: str-slice($query, 3);
43 // Less than or equal.
44 @elseif (str-slice($query, 0, 2) == '<=') {
47 $breakpoint: str-slice($query, 3);
52 @elseif (str-slice($query, 0, 1) == '>') {
55 $breakpoint: str-slice($query, 2);
60 @elseif (str-slice($query, 0, 1) == '<') {
63 $breakpoint: str-slice($query, 2);
68 @elseif (str-slice($query, 0, 1) == '!') {
71 $breakpoint: str-slice($query, 2);
84 @if ($breakpoint and map-has-key($breakpoints, $breakpoint)) {
86 $a: map-get($breakpoints, $breakpoint);
89 @if (type-of($a) == 'list') {
97 // Greater than or equal (>= 0 / anything)
102 // Less than or equal (<= y)
103 @elseif ($op == 'lte') {
104 $media: 'screen and (max-width: ' + $y + ')';
107 // Greater than (> y)
108 @elseif ($op == 'gt') {
109 $media: 'screen and (min-width: ' + ($y + 1) + ')';
112 // Less than (< 0 / invalid)
113 @elseif ($op == 'lt') {
114 $media: 'screen and (max-width: -1px)';
118 @elseif ($op == 'not') {
119 $media: 'screen and (min-width: ' + ($y + 1) + ')';
124 $media: 'screen and (max-width: ' + $y + ')';
130 @else if ($y == null) {
132 // Greater than or equal (>= x)
134 $media: 'screen and (min-width: ' + $x + ')';
137 // Less than or equal (<= inf / anything)
138 @elseif ($op == 'lte') {
142 // Greater than (> inf / invalid)
143 @elseif ($op == 'gt') {
144 $media: 'screen and (max-width: -1px)';
148 @elseif ($op == 'lt') {
149 $media: 'screen and (max-width: ' + ($x - 1) + ')';
153 @elseif ($op == 'not') {
154 $media: 'screen and (max-width: ' + ($x - 1) + ')';
159 $media: 'screen and (min-width: ' + $x + ')';
167 // Greater than or equal (>= x)
169 $media: 'screen and (min-width: ' + $x + ')';
172 // Less than or equal (<= y)
173 @elseif ($op == 'lte') {
174 $media: 'screen and (max-width: ' + $y + ')';
177 // Greater than (> y)
178 @elseif ($op == 'gt') {
179 $media: 'screen and (min-width: ' + ($y + 1) + ')';
183 @elseif ($op == 'lt') {
184 $media: 'screen and (max-width: ' + ($x - 1) + ')';
188 @elseif ($op == 'not') {
189 $media: 'screen and (max-width: ' + ($x - 1) + '), screen and (min-width: ' + ($y + 1) + ')';
192 // Equal (>= x and <= y)
194 $media: 'screen and (min-width: ' + $x + ') and (max-width: ' + $y + ')';
204 // Missing a media type? Prefix with "screen".
205 @if (str-slice($a, 0, 1) == '(') {
206 $media: 'screen and ' + $a;
209 // Otherwise, use as-is.