Debian Codegraph @

node/@patternfly/patternfly/layouts/Flex/flex.scss

raw
1 @use '../../sass-utilities' as *;
2 @use 'sass:list';
3 @use 'sass:map';
4
5 // Always keep list of spacers and breakpoints up-to-date
6 $pf-v6-l-flex--breakpoint-map: build-breakpoint-map();
7 $pf-v6-l-flex--spacer-map: build-spacer-map();
8 $pf-v6-l-flex--gap-map: build-spacer-map("base", "none", "xs", "sm", "md", "lg", "xl", "2xl", "3xl", "4xl");
9 $pf-v6-l-flex--variable-map: build-variable-map("#{$pf-prefix}l-flex--spacer", $pf-v6-l-flex--spacer-map);
10
11 @include pf-root($flex) {
12 --#{$flex}--Display: flex;
13 --#{$flex}--FlexWrap: wrap;
14 --#{$flex}--AlignItems: baseline;
15 --#{$flex}--m-row--AlignItems: baseline;
16 --#{$flex}--m-row-reverse--AlignItems: baseline;
17 --#{$flex}--item--Order: 0;
18 --#{$flex}--spacer--column--base: var(--pf-t--global--spacer--gutter--default); // default spacer/gap for columns
19 --#{$flex}--spacer--row--base: var(--pf-t--global--spacer--sm); // default spacer/gap for rows
20 --#{$flex}--RowGap: var(--#{$flex}--spacer--row--base);
21 --#{$flex}--ColumnGap: 0;
22 --#{$flex}--m-gap--RowGap: var(--#{$flex}--spacer--row--base);
23 --#{$flex}--m-gap--ColumnGap: var(--#{$flex}--spacer--column--base);
24 --#{$flex}--m-row-gap--RowGap: var(--#{$flex}--spacer--row--base);
25 --#{$flex}--m-column-gap--ColumnGap: var(--#{$flex}--spacer--column--base);
26 }
27
28 .#{$flex} {
29 // Emit spacer css variables that map to requested spacer values
30 @include pf-v6-emit-properties($pf-v6-l-flex--variable-map);
31
32 display: var(--#{$flex}--Display);
33 flex-wrap: var(--#{$flex}--FlexWrap);
34 gap: var(--#{$flex}--RowGap) var(--#{$flex}--ColumnGap);
35 align-items: var(--#{$flex}--AlignItems);
36 }
37
38 // stylelint-disable no-duplicate-selectors, max-nesting-depth
39
40 // Item
41 .#{$flex} > * {
42 // set/reset layout spacers on children, since the parent flex layout can be a child of another flex layout and needs these values from its parent
43 --#{$flex}--spacer: initial;
44 --#{$flex}--spacer--column: var(--#{$flex}--spacer, var(--#{$flex}--spacer--column--base));
45 --#{$flex}--spacer--row: var(--#{$flex}--spacer, var(--#{$flex}--spacer--row--base));
46
47 order: var(--#{$flex}--item--Order);
48 max-width: 100%;
49 margin-inline-end: var(--#{$flex}--spacer--column);
50
51 // don't set base value for --#{$flex}--item--Order as it defaults to 0
52 @media screen and (min-width: $pf-v6-global--breakpoint--sm) {
53 order: var(--#{$flex}--item--Order-on-sm, var(--#{$flex}--item--Order));
54 }
55
56 @media screen and (min-width: $pf-v6-global--breakpoint--md) {
57 order: var(--#{$flex}--item--Order-on-md, var(--#{$flex}--item--Order-on-sm, var(--#{$flex}--item--Order)));
58 }
59
60 @media screen and (min-width: $pf-v6-global--breakpoint--lg) {
61 order: var(--#{$flex}--item--Order-on-lg, var(--#{$flex}--item--Order-on-md, var(--#{$flex}--item--Order-on-sm, var(--#{$flex}--item--Order))));
62 }
63
64 @media screen and (min-width: $pf-v6-global--breakpoint--xl) {
65 order: var(--#{$flex}--item--Order-on-xl, var(--#{$flex}--item--Order-on-lg, var(--#{$flex}--item--Order-on-md, var(--#{$flex}--item--Order-on-sm, var(--#{$flex}--item--Order)))));
66 }
67
68 @media screen and (min-width: $pf-v6-global--breakpoint--2xl) {
69 order: var(--#{$flex}--item--Order-on-2xl, var(--#{$flex}--item--Order-on-xl, var(--#{$flex}--item--Order-on-lg, var(--#{$flex}--item--Order-on-md, var(--#{$flex}--item--Order-on-sm, var(--#{$flex}--item--Order))))));
70 }
71
72 &:last-child {
73 --#{$flex}--spacer: 0;
74 }
75 }
76
77 .#{$flex} {
78 @each $breakpoint, $breakpoint-value in $pf-v6-l-flex--breakpoint-map {
79 $breakpoint-name: "";
80
81 @if $breakpoint != "base" {
82 $breakpoint-name: -on-#{$breakpoint};
83 }
84
85 @include pf-v6-apply-breakpoint($breakpoint) {
86 // display
87 &.pf-m-flex#{$breakpoint-name} {
88 display: var(--#{$flex}--Display);
89 }
90
91 // inline flex
92 &.pf-m-inline-flex#{$breakpoint-name} {
93 --#{$flex}--Display: inline-flex;
94 }
95
96 // flex-direction
97 &.pf-m-column#{$breakpoint-name} {
98 --#{$flex}--RowGap: 0;
99 --#{$flex}--ColumnGap: var(--#{$flex}--spacer--column--base);
100
101 flex-direction: column;
102 align-items: normal;
103
104 > * {
105 margin-block-start: 0;
106 margin-block-end: var(--#{$flex}--spacer--row);
107 margin-inline-start: 0;
108 margin-inline-end: 0;
109 }
110 }
111
112 // flex-direction column-reverse
113 &.pf-m-column-reverse#{$breakpoint-name} {
114 flex-direction: column-reverse;
115 align-items: normal;
116
117 > * {
118 margin-block-start: var(--#{$flex}--spacer--row);
119 margin-block-end: 0;
120 margin-inline-start: 0;
121 margin-inline-end: 0;
122 }
123 }
124
125 // flex-direction row
126 &.pf-m-row#{$breakpoint-name} {
127 flex-direction: row;
128 align-items: var(--#{$flex}--m-row--AlignItems);
129
130 // unset styling set for .pf-m-column
131 > * {
132 margin-block-start: 0;
133 margin-block-end: 0;
134 margin-inline-start: 0;
135 margin-inline-end: var(--#{$flex}--spacer--column);
136 }
137 }
138
139 // flex-direction row-reverse
140 &.pf-m-row-reverse#{$breakpoint-name} {
141 flex-direction: row-reverse;
142 align-items: var(--#{$flex}--m-row-reverse--AlignItems);
143
144 // unset styling set for .pf-m-column
145 > * {
146 margin-block-start: 0;
147 margin-block-end: 0;
148 margin-inline-start: var(--#{$flex}--spacer--column);
149 margin-inline-end: 0;
150 }
151 }
152
153 // flex-wrap
154 &.pf-m-wrap#{$breakpoint-name} {
155 flex-wrap: wrap;
156 }
157
158 // flex-wrap reverse
159 &.pf-m-wrap-reverse#{$breakpoint-name} {
160 flex-wrap: wrap-reverse;
161 }
162
163 &.pf-m-nowrap#{$breakpoint-name} {
164 flex-wrap: nowrap;
165 }
166
167 // justify-content
168 &.pf-m-justify-content-flex-start#{$breakpoint-name} {
169 justify-content: flex-start;
170 }
171
172 &.pf-m-justify-content-flex-end#{$breakpoint-name} {
173 justify-content: flex-end;
174 }
175
176 &.pf-m-justify-content-center#{$breakpoint-name} {
177 justify-content: center;
178 }
179
180 &.pf-m-justify-content-space-between#{$breakpoint-name} {
181 justify-content: space-between;
182 }
183
184 &.pf-m-justify-content-space-around#{$breakpoint-name} {
185 justify-content: space-around;
186 }
187
188 &.pf-m-justify-content-space-evenly#{$breakpoint-name} {
189 justify-content: space-evenly;
190 }
191
192 // align-items
193 &.pf-m-align-items-flex-start#{$breakpoint-name} {
194 align-items: flex-start;
195 }
196
197 &.pf-m-align-items-flex-end#{$breakpoint-name} {
198 align-items: flex-end;
199 }
200
201 &.pf-m-align-items-center#{$breakpoint-name} {
202 align-items: center;
203 }
204
205 &.pf-m-align-items-stretch#{$breakpoint-name} {
206 align-items: stretch;
207 }
208
209 &.pf-m-align-items-baseline#{$breakpoint-name} {
210 align-items: baseline;
211 }
212
213 // align-content
214 &.pf-m-align-content-flex-start#{$breakpoint-name} {
215 align-content: flex-start;
216 }
217
218 &.pf-m-align-content-flex-end#{$breakpoint-name} {
219 align-content: flex-end;
220 }
221
222 &.pf-m-align-content-center#{$breakpoint-name} {
223 align-content: center;
224 }
225
226 &.pf-m-align-content-stretch#{$breakpoint-name} {
227 align-content: stretch;
228 }
229
230 &.pf-m-align-content-space-between#{$breakpoint-name} {
231 align-content: space-between;
232 }
233
234 &.pf-m-align-content-space-around#{$breakpoint-name} {
235 align-content: space-around;
236 }
237
238 // alignment
239 > .pf-m-align-right#{$breakpoint-name} {
240 margin-inline-start: auto;
241 }
242
243 > .pf-m-align-left#{$breakpoint-name} {
244 margin-inline-start: 0;
245 }
246
247 // item properties
248 > .pf-m-grow#{$breakpoint-name} {
249 flex-grow: 1;
250 }
251
252 > .pf-m-shrink#{$breakpoint-name} {
253 flex-shrink: 1;
254 }
255
256 > .pf-m-full-width#{$breakpoint-name} {
257 width: 100%;
258 margin-inline-end: 0;
259 }
260
261 > .pf-m-flex-1#{$breakpoint-name} {
262 flex: 1 0 0;
263 }
264
265 > .pf-m-flex-2#{$breakpoint-name} {
266 flex: 2 0 0;
267 }
268
269 > .pf-m-flex-3#{$breakpoint-name} {
270 flex: 3 0 0;
271 }
272
273 > .pf-m-flex-4#{$breakpoint-name} {
274 flex: 4 0 0;
275 }
276
277 > .pf-m-flex-default#{$breakpoint-name} {
278 flex: 0 1 auto;
279 }
280
281 > .pf-m-flex-none#{$breakpoint-name} {
282 flex: none;
283 }
284
285 // align-self
286 > .pf-m-align-self-flex-start#{$breakpoint-name} {
287 align-self: flex-start;
288 }
289
290 > .pf-m-align-self-flex-end#{$breakpoint-name} {
291 align-self: flex-end;
292 }
293
294 > .pf-m-align-self-center#{$breakpoint-name} {
295 align-self: center;
296 }
297
298 > .pf-m-align-self-baseline#{$breakpoint-name} {
299 align-self: baseline;
300 }
301
302 > .pf-m-align-self-stretch#{$breakpoint-name} {
303 align-self: stretch;
304 }
305 }
306 }
307
308 // .pf-m-space-items-{size}{-on-[breakpoint]}
309 @each $breakpoint, $breakpoint-value in $pf-v6-l-flex--breakpoint-map {
310 $breakpoint-name: "";
311
312 @if $breakpoint != "base" {
313 $breakpoint-name: -on-#{$breakpoint};
314 }
315
316 @include pf-v6-apply-breakpoint($breakpoint) {
317 @each $spacer, $spacer-value in $pf-v6-l-flex--spacer-map {
318 &.pf-m-space-items-#{$spacer}#{$breakpoint-name} {
319 > * {
320 --#{$flex}--spacer: var(#{map.get($pf-v6-l-flex--variable-map, $spacer-value)});
321 }
322
323 > :last-child {
324 --#{$flex}--spacer: 0;
325 }
326 }
327 }
328 }
329 }
330
331 // .pf-m-spacer-{size}{-on-[breakpoint]}
332 @each $breakpoint, $breakpoint-value in $pf-v6-l-flex--breakpoint-map {
333 $breakpoint-name: "";
334
335 @if $breakpoint != "base" {
336 $breakpoint-name: -on-#{$breakpoint};
337 }
338
339 @include pf-v6-apply-breakpoint($breakpoint) {
340 @each $spacer, $spacer-value in $pf-v6-l-flex--spacer-map {
341 .pf-m-spacer-#{$spacer}#{$breakpoint-name} {
342 --#{$flex}--spacer: var(#{map.get($pf-v6-l-flex--variable-map, $spacer-value)});
343
344 &:last-child {
345 --#{$flex}--spacer: var(#{map.get($pf-v6-l-flex--variable-map, $spacer-value)});
346 }
347 }
348 }
349 }
350 }
351
352 // .pf-m-gap{-[size]}{-on-[breakpoint]}
353 @each $breakpoint, $breakpoint-value in $pf-v6-l-flex--breakpoint-map {
354 $pf-v6-l-flex--gap--selectors: ();
355
356 @include pf-v6-apply-breakpoint($breakpoint) {
357 @each $spacer, $value in $pf-v6-l-flex--gap-map {
358 $breakpoint-name: -on-#{$breakpoint};
359
360 @if $breakpoint == "base" {
361 $breakpoint-name: "";
362 }
363
364 $spacer-name: -#{$spacer};
365
366 @if $spacer == "base" {
367 $spacer-name: "";
368 }
369
370 $spacer-row: $value;
371
372 @if $spacer == "base" {
373 $spacer-row: var(--#{$flex}--m-gap--RowGap);
374 }
375
376 $spacer-column: $value;
377
378 @if $spacer == "base" {
379 $spacer-column: var(--#{$flex}--m-gap--ColumnGap);
380 }
381
382 $selector: ".pf-m-gap#{$spacer-name}#{$breakpoint-name}";
383 $pf-v6-l-flex--gap--selectors: list.append($pf-v6-l-flex--gap--selectors, $selector, $separator: comma);
384
385 &#{$selector} {
386 --#{$flex}--RowGap: #{$spacer-row};
387 --#{$flex}--ColumnGap: #{$spacer-column};
388 }
389 }
390
391 &:is(#{$pf-v6-l-flex--gap--selectors}) {
392 > * {
393 --#{$flex}--spacer--row: 0;
394 --#{$flex}--spacer--column: 0;
395 }
396 }
397 }
398 }
399
400 // .pf-m-row-gap{-[size]}{-on-[breakpoint]}
401 @each $breakpoint, $breakpoint-value in $pf-v6-l-flex--breakpoint-map {
402 @include pf-v6-apply-breakpoint($breakpoint) {
403 $pf-v6-l-flex--row-gap--selectors: ();
404
405 @each $spacer, $value in $pf-v6-l-flex--gap-map {
406 $breakpoint-name: -on-#{$breakpoint};
407
408 @if $breakpoint == "base" {
409 $breakpoint-name: "";
410 }
411
412 $spacer-name: -#{$spacer};
413
414 @if $spacer == "base" {
415 $spacer-name: "";
416 }
417
418 $spacer-value: $value;
419
420 @if $spacer == "base" {
421 $spacer-value: var(--#{$flex}--m-row-gap--RowGap);
422 }
423
424 $selector: ".pf-m-row-gap#{$spacer-name}#{$breakpoint-name}";
425 $pf-v6-l-flex--row-gap--selectors: list.append($pf-v6-l-flex--row-gap--selectors, $selector, $separator: comma);
426
427 &#{$selector} {
428 --#{$flex}--RowGap: #{$spacer-value};
429 }
430 }
431
432 &:is(#{$pf-v6-l-flex--row-gap--selectors}) {
433 > * {
434 --#{$flex}--spacer--row: 0;
435 }
436 }
437 }
438 }
439
440 // .pf-m-column-gap{-[size]}{-on-[breakpoint]}
441 @each $breakpoint, $breakpoint-value in $pf-v6-l-flex--breakpoint-map {
442 $pf-v6-l-flex--column-gap--selectors: ();
443
444 @include pf-v6-apply-breakpoint($breakpoint) {
445 @each $spacer, $value in $pf-v6-l-flex--gap-map {
446 $breakpoint-name: -on-#{$breakpoint};
447
448 @if $breakpoint == "base" {
449 $breakpoint-name: "";
450 }
451
452 $spacer-name: -#{$spacer};
453
454 @if $spacer == "base" {
455 $spacer-name: "";
456 }
457
458 $spacer-value: $value;
459
460 @if $spacer == "base" {
461 $spacer-value: var(--#{$flex}--m-column-gap--ColumnGap);
462 }
463
464 $selector: ".pf-m-column-gap#{$spacer-name}#{$breakpoint-name}";
465 $pf-v6-l-flex--column-gap--selectors: list.append($pf-v6-l-flex--column-gap--selectors, $selector, $separator: comma);
466
467 &#{$selector} {
468 --#{$flex}--ColumnGap: #{$spacer-value};
469 }
470 }
471
472 &:is(#{$pf-v6-l-flex--column-gap--selectors}) {
473 > * {
474 --#{$flex}--spacer--column: 0;
475 }
476 }
477 }
478 }
479 }
480 // stylelint-enable