|
13 | 13 | /// @name Grid media
|
14 | 14 | ///
|
15 | 15 | /// @argument {map} $grid
|
16 |
| -/// The grid to be used within the scope of the block. |
17 |
| -/// This grid should include the `media` property to determine the expression |
| 16 | +/// The grid or grids to be used within the scope of the block. |
| 17 | +/// These grids should include the `media` property to determine the expression |
18 | 18 | /// for the media query.
|
19 | 19 | ///
|
20 | 20 | /// @content
|
21 |
| -/// Grid media will temporarily the override the default grid with the |
22 |
| -/// attributes of the custom grid. This change is scoped to within the mixin |
23 |
| -/// block, and once the mixin has ended the default grid will revert to its |
24 |
| -/// original state as defined by `$neat-grid`. This allows for different |
| 21 | +/// Grid media will temporarily override the default grid with the attributes |
| 22 | +/// of the custom grids. When `grid-media` is given a custom grid, it will |
| 23 | +/// apply that grid to any of other Neat mixins within the `grid-media` block |
| 24 | +/// (`{…}`). Once the mixin block has ended the default grid will revert to |
| 25 | +/// its original state as defined by `$neat-grid`. This allows for different |
25 | 26 | /// gutter width and column count based on screen size or other properties.
|
26 | 27 | ///
|
| 28 | +/// If multiple grids are passed in to `grid-media`, it will loop through the |
| 29 | +/// contents of the block, quickly allowing you to apply multiple grids in a |
| 30 | +/// single mixin. |
| 31 | +/// |
27 | 32 | /// @example scss
|
28 | 33 | /// $custom-neat-grid: (
|
29 | 34 | /// columns: 12,
|
30 | 35 | /// gutter: 50px,
|
| 36 | +/// media: "screen and (max-width: 999px)", |
| 37 | +/// ); |
| 38 | +/// |
| 39 | +/// $custom-neat-grid-2: ( |
| 40 | +/// columns: 12, |
| 41 | +/// gutter: 70px, |
31 | 42 | /// media: 1000px,
|
32 | 43 | /// );
|
33 | 44 | ///
|
34 | 45 | /// .element {
|
35 | 46 | /// @include grid-column(3);
|
36 | 47 | ///
|
37 |
| -/// @include grid-media($custom-neat-grid){ |
| 48 | +/// @include grid-media($custom-neat-grid, $custom-neat-grid-2){ |
38 | 49 | /// @include grid-column(6);
|
39 | 50 | /// }
|
40 | 51 | /// }
|
|
46 | 57 | /// margin-left: 20px;
|
47 | 58 | /// }
|
48 | 59 | ///
|
49 |
| -/// @media only screen and (min-width: 1000px) { |
| 60 | +/// @media only screen and (max-width: 999px) { |
50 | 61 | /// .element {
|
51 | 62 | /// width: calc(50% - 75px);
|
52 | 63 | /// float: left;
|
53 | 64 | /// margin-left: 50px;
|
54 | 65 | /// }
|
55 | 66 | /// }
|
| 67 | +/// |
| 68 | +/// @media only screen and (min-width: 1000px) { |
| 69 | +/// .element { |
| 70 | +/// width: calc(50% - 75px); |
| 71 | +/// float: left; |
| 72 | +/// margin-left: 70px; |
| 73 | +/// } |
| 74 | +/// } |
56 | 75 |
|
57 |
| -@mixin grid-media($grid) { |
58 |
| - $_media: _retrieve-neat-setting($grid, media); |
59 |
| - $_query: _neat-parse-media($_media); |
| 76 | +@mixin grid-media($grids...) { |
| 77 | + @each $_grid in $grids { |
| 78 | + $_media: _retrieve-neat-setting($_grid, media); |
| 79 | + $_query: _neat-parse-media($_media); |
60 | 80 |
|
61 |
| - @media #{$_query} { |
62 |
| - $_default-neat-grid: $neat-grid; |
63 |
| - $neat-grid: map-merge($neat-grid, $grid) !global; |
64 |
| - @content; |
65 |
| - $neat-grid: $_default-neat-grid !global; |
| 81 | + @media #{$_query} { |
| 82 | + $_default-neat-grid: $neat-grid; |
| 83 | + $neat-grid: map-merge($neat-grid, $_grid) !global; |
| 84 | + @content; |
| 85 | + $neat-grid: $_default-neat-grid !global; |
| 86 | + } |
66 | 87 | }
|
67 | 88 | }
|
0 commit comments