blob: 8068b7980244377d370827d4c002ce80392956d6 [file] [log] [blame]
Copybara botbe50d492023-11-30 00:16:42 +01001@charset "UTF-8";
2
3/**
4 * This code is modified from Material Design Lite _grid.sass,
5 * which is Licensed under the Apache License, Version 2.0
6 * Copyright 2015 Google Inc. All Rights Reserved.
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 *
20 */
21
22//////////////////////////////////////////////////////////////////////////////////
23//
24// Element queries for _grid.scss, based on: https://github.com/Snugug/eq.js
25//
26//////////////////////////////////////////////////////////////////////////////////
27
28// Use of this module requires the user to include variables from material-design-lite in hers/his main SASS module
29//@import "../../node_modules/material-design-lite/src/variables";
30.mdlext-grid {
31 display: flex;
32 flex-flow: row wrap;
33 margin: 0 auto;
34 align-items: stretch;
35
36 &.mdlext-grid--no-spacing {
37 padding: 0;
38 }
39
40 & > .mdlext-cell {
41 box-sizing: border-box;
42 }
43
44 & > .mdlext-cell--top {
45 align-self: flex-start;
46 }
47
48 & > .mdlext-cell--middle {
49 align-self: center;
50 }
51
52 & > .mdlext-cell--bottom {
53 align-self: flex-end;
54 }
55
56 & > .mdlext-cell--stretch {
57 align-self: stretch;
58 }
59
60 .mdlext-grid--no-spacing > .mdlext-cell {
61 margin: 0;
62 }
63
64 // Define order override classes.
65 @for $i from 1 through $grid-max-columns {
66 & > .mdlext-cell--order-#{$i} {
67 order: $i;
68 }
69 }
70}
71
72// Mixins for width calculation.
73@mixin _partial-size($size, $columns, $gutter) {
74 width: calc(#{(($size / $columns) * 100) + "%"} - #{$gutter});
75}
76@mixin _full-size($gutter) {
77 @include _partial-size(1, 1, $gutter);
78}
79@mixin _offset-size($size, $columns, $gutter) {
80 margin-left: calc(#{(($size / $columns) * 100) + "%"} + #{$gutter / 2});
81}
82
83@mixin _partial-size-no-spacing($size, $columns) {
84 width: #{(($size / $columns) * 100) + "%"};
85}
86@mixin _full-size-no-spacing() {
87 @include _partial-size-no-spacing(1, 1);
88}
89@mixin _offset-size-no-spacing($size, $columns) {
90 margin-left: #{(($size / $columns) * 100) + "%"};
91}
92
93
94.mdlext-grid {
95
96 @include eq-pts((
97 grid_phone: 0,
98 grid_tablet: strip-unit($grid-tablet-breakpoint),
99 grid_desktop: strip-unit($grid-desktop-breakpoint)
100 ));
101
102 ////////// Phone //////////
103 @include eq('grid_phone') {
104 padding: $grid-phone-margin - ($grid-phone-gutter / 2);
105
106 & > .mdlext-cell {
107 margin: $grid-phone-gutter / 2;
108 @include _partial-size($grid-cell-default-columns, $grid-phone-columns, $grid-phone-gutter);
109 }
110
111 & > .mdlext-cell--hide-phone {
112 display: none !important;
113 }
114
115 // Define order override classes.
116 @for $i from 1 through $grid-max-columns {
117 & > .mdlext-cell--order-#{$i}-phone.mdlext-cell--order-#{$i}-phone {
118 order: $i;
119 }
120 }
121
122 // Define partial sizes for columnNumber < totalColumns.
123 @for $i from 1 through ($grid-phone-columns - 1) {
124 & > .mdlext-cell--#{$i}-col,
125 & > .mdlext-cell--#{$i}-col-phone.mdlext-cell--#{$i}-col-phone {
126 @include _partial-size($i, $grid-phone-columns, $grid-phone-gutter);
127 }
128 }
129
130 // Define 100% for everything else.
131 @for $i from $grid-phone-columns through $grid-desktop-columns {
132 & > .mdlext-cell--#{$i}-col,
133 & > .mdlext-cell--#{$i}-col-phone.mdlext-cell--#{$i}-col-phone {
134 @include _full-size($grid-phone-gutter);
135 }
136 }
137
138 // Define valid phone offsets.
139 @for $i from 1 through ($grid-phone-columns - 1) {
140 & > .mdlext-cell--#{$i}-offset,
141 & > .mdlext-cell--#{$i}-offset-phone.mdlext-cell--#{$i}-offset-phone {
142 @include _offset-size($i, $grid-phone-columns, $grid-phone-gutter);
143 }
144 }
145
146 &.mdlext-grid--no-spacing {
147 padding: 0;
148
149 & > .mdlext-cell {
150 margin: 0;
151 @include _partial-size-no-spacing($grid-cell-default-columns, $grid-phone-columns);
152 }
153
154 // Define partial sizes for columnNumber < totalColumns.
155 @for $i from 1 through ($grid-phone-columns - 1) {
156 & > .mdlext-cell--#{$i}-col,
157 & > .mdlext-cell--#{$i}-col-phone.mdlext-cell--#{$i}-col-phone {
158 @include _partial-size-no-spacing($i, $grid-phone-columns);
159 }
160 }
161
162 // Define 100% for everything else.
163 @for $i from $grid-phone-columns through $grid-desktop-columns {
164 & > .mdlext-cell--#{$i}-col,
165 & > .mdlext-cell--#{$i}-col-phone.mdlext-cell--#{$i}-col-phone {
166 @include _full-size-no-spacing();
167 }
168 }
169
170 // Define valid phone offsets.
171 @for $i from 1 through ($grid-phone-columns - 1) {
172 & > .mdlext-cell--#{$i}-offset,
173 & > .mdlext-cell--#{$i}-offset-phone.mdlext-cell--#{$i}-offset-phone {
174 @include _offset-size-no-spacing($i, $grid-phone-columns);
175 }
176 }
177 }
178 }
179
180 ////////// Tablet //////////
181 @include eq('grid_tablet') {
182 padding: $grid-tablet-margin - ($grid-tablet-gutter / 2);
183
184 & > .mdlext-cell {
185 margin: $grid-tablet-gutter / 2;
186 @include _partial-size($grid-cell-default-columns, $grid-tablet-columns, $grid-tablet-gutter);
187 }
188
189 & > .mdlext-cell--hide-tablet {
190 display: none !important;
191 }
192
193 // Define order override classes.
194 @for $i from 1 through $grid-max-columns {
195 & > .mdlext-cell--order-#{$i}-tablet.mdlext-cell--order-#{$i}-tablet {
196 order: $i;
197 }
198 }
199
200 // Define partial sizes for columnNumber < totalColumns.
201 @for $i from 1 through ($grid-tablet-columns - 1) {
202 & > .mdlext-cell--#{$i}-col,
203 & > .mdlext-cell--#{$i}-col-tablet.mdlext-cell--#{$i}-col-tablet {
204 @include _partial-size($i, $grid-tablet-columns, $grid-tablet-gutter);
205 }
206 }
207
208 // Define 100% for everything else.
209 @for $i from $grid-tablet-columns through $grid-desktop-columns {
210 & > .mdlext-cell--#{$i}-col,
211 & > .mdlext-cell--#{$i}-col-tablet.mdlext-cell--#{$i}-col-tablet {
212 @include _full-size($grid-tablet-gutter);
213 }
214 }
215
216 // Define valid tablet offsets.
217 @for $i from 1 through ($grid-tablet-columns - 1) {
218 & > .mdlext-cell--#{$i}-offset,
219 & > .mdlext-cell--#{$i}-offset-tablet.mdlext-cell--#{$i}-offset-tablet {
220 @include _offset-size($i, $grid-tablet-columns, $grid-tablet-gutter);
221 }
222 }
223
224 &.mdlext-grid--no-spacing {
225 padding: 0;
226
227 & > .mdlext-cell {
228 margin: 0;
229 @include _partial-size-no-spacing($grid-cell-default-columns, $grid-tablet-columns);
230 }
231
232 // Define partial sizes for columnNumber < totalColumns.
233 @for $i from 1 through ($grid-tablet-columns - 1) {
234 & > .mdlext-cell--#{$i}-col,
235 & > .mdlext-cell--#{$i}-col-tablet.mdlext-cell--#{$i}-col-tablet {
236 @include _partial-size-no-spacing($i, $grid-tablet-columns);
237 }
238 }
239
240 // Define 100% for everything else.
241 @for $i from $grid-tablet-columns through $grid-desktop-columns {
242 & > .mdlext-cell--#{$i}-col,
243 & > .mdlext-cell--#{$i}-col-tablet.mdlext-cell--#{$i}-col-tablet {
244 @include _full-size-no-spacing();
245 }
246 }
247
248 // Define valid tablet offsets.
249 @for $i from 1 through ($grid-tablet-columns - 1) {
250 & > .mdlext-cell--#{$i}-offset,
251 & > .mdlext-cell--#{$i}-offset-tablet.mdlext-cell--#{$i}-offset-tablet {
252 @include _offset-size-no-spacing($i, $grid-tablet-columns);
253 }
254 }
255 }
256 }
257
258 ////////// Desktop //////////
259 @include eq('grid_desktop') {
260 padding: $grid-desktop-margin - ($grid-desktop-gutter / 2);
261
262 & > .mdlext-cell {
263 margin: $grid-desktop-gutter / 2;
264 @include _partial-size($grid-cell-default-columns, $grid-desktop-columns, $grid-desktop-gutter);
265 }
266
267 & > .mdlext-cell--hide-desktop {
268 display: none !important;
269 }
270
271 // Define order override classes.
272 @for $i from 1 through $grid-max-columns {
273 & > .mdlext-cell--order-#{$i}-desktop.mdlext-cell--order-#{$i}-desktop {
274 order: $i;
275 }
276 }
277
278 // Define partial sizes for all numbers of columns.
279 @for $i from 1 through $grid-desktop-columns {
280 & > .mdlext-cell--#{$i}-col,
281 & > .mdlext-cell--#{$i}-col-desktop.mdlext-cell--#{$i}-col-desktop {
282 @include _partial-size($i, $grid-desktop-columns, $grid-desktop-gutter);
283 }
284 }
285
286 // Define valid desktop offsets.
287 @for $i from 1 through ($grid-desktop-columns - 1) {
288 & > .mdlext-cell--#{$i}-offset,
289 & > .mdlext-cell--#{$i}-offset-desktop.mdlext-cell--#{$i}-offset-desktop {
290 @include _offset-size($i, $grid-desktop-columns, $grid-desktop-gutter);
291 }
292 }
293
294 &.mdlext-grid--no-spacing {
295 padding: 0;
296
297 & > .mdlext-cell {
298 margin: 0;
299 @include _partial-size-no-spacing($grid-cell-default-columns, $grid-desktop-columns);
300 }
301
302 // Define partial sizes for all numbers of columns.
303 @for $i from 1 through $grid-desktop-columns {
304 & > .mdlext-cell--#{$i}-col,
305 & > .mdlext-cell--#{$i}-col-desktop.mdlext-cell--#{$i}-col-desktop {
306 @include _partial-size-no-spacing($i, $grid-desktop-columns);
307 }
308 }
309
310 // Define valid desktop offsets.
311 @for $i from 1 through ($grid-desktop-columns - 1) {
312 & > .mdlext-cell--#{$i}-offset,
313 & > .mdlext-cell--#{$i}-offset-desktop.mdlext-cell--#{$i}-offset-desktop {
314 @include _offset-size-no-spacing($i, $grid-desktop-columns);
315 }
316 }
317 }
318 }
319}
320
321@include eq-selectors;