|
1 | | -// Loop over each breakpoint |
2 | | -@each $breakpoint in map-keys($grid-breakpoints) { |
3 | | - |
4 | | - // Generate media query if needed |
5 | | - @include media-breakpoint-up($breakpoint) { |
6 | | - $infix: breakpoint-infix($breakpoint, $grid-breakpoints); |
7 | | - |
8 | | - // Loop over each utility property |
9 | | - @each $key, $utility in $utilities { |
10 | | - // The utility can be disabled with `false`, thus check if the utility is a map first |
11 | | - // Only proceed if responsive media queries are enabled or if it's the base media query |
12 | | - @if type-of($utility) == "map" and (map-get($utility, responsive) or $infix == "") { |
13 | | - @include generate-utility($utility, $infix); |
14 | | - } |
15 | | - } |
16 | | - } |
17 | | -} |
18 | | - |
19 | | -// RFS rescaling |
20 | | -@media (min-width: $rfs-mq-value) { |
| 1 | +@if $enable-utility-classes { |
| 2 | + // Loop over each breakpoint |
21 | 3 | @each $breakpoint in map-keys($grid-breakpoints) { |
22 | | - $infix: breakpoint-infix($breakpoint, $grid-breakpoints); |
| 4 | + // Generate media query if needed |
| 5 | + @include media-breakpoint-up($breakpoint) { |
| 6 | + $infix: breakpoint-infix($breakpoint, $grid-breakpoints); |
23 | 7 |
|
24 | | - @if (map-get($grid-breakpoints, $breakpoint) < $rfs-breakpoint) { |
25 | 8 | // Loop over each utility property |
26 | 9 | @each $key, $utility in $utilities { |
27 | 10 | // The utility can be disabled with `false`, thus check if the utility is a map first |
28 | 11 | // Only proceed if responsive media queries are enabled or if it's the base media query |
29 | | - @if type-of($utility) == "map" and map-get($utility, rfs) and (map-get($utility, responsive) or $infix == "") { |
30 | | - @include generate-utility($utility, $infix, true); |
| 12 | + @if type-of($utility) == "map" and (map-get($utility, responsive) or $infix == "") { |
| 13 | + @include generate-utility($utility, $infix); |
| 14 | + } |
| 15 | + } |
| 16 | + } |
| 17 | + } |
| 18 | + |
| 19 | + // RFS rescaling |
| 20 | + @media (min-width: $rfs-mq-value) { |
| 21 | + @each $breakpoint in map-keys($grid-breakpoints) { |
| 22 | + $infix: breakpoint-infix($breakpoint, $grid-breakpoints); |
| 23 | + |
| 24 | + @if (map-get($grid-breakpoints, $breakpoint) < $rfs-breakpoint) { |
| 25 | + // Loop over each utility property |
| 26 | + @each $key, $utility in $utilities { |
| 27 | + // The utility can be disabled with `false`, thus check if the utility is a map first |
| 28 | + // Only proceed if responsive media queries are enabled or if it's the base media query |
| 29 | + @if type-of($utility) == "map" and map-get($utility, rfs) and (map-get($utility, responsive) or $infix == "") { |
| 30 | + @include generate-utility($utility, $infix, true); |
| 31 | + } |
31 | 32 | } |
32 | 33 | } |
33 | 34 | } |
34 | 35 | } |
| 36 | + |
| 37 | + |
| 38 | + // Print utilities |
| 39 | + @media print { |
| 40 | + @each $key, $utility in $utilities { |
| 41 | + // The utility can be disabled with `false`, thus check if the utility is a map first |
| 42 | + // Then check if the utility needs print styles |
| 43 | + @if type-of($utility) == "map" and map-get($utility, print) == true { |
| 44 | + @include generate-utility($utility, "-print"); |
| 45 | + } |
| 46 | + } |
| 47 | + } |
35 | 48 | } |
36 | 49 |
|
| 50 | +// Generate utility placeholders |
| 51 | + |
| 52 | +$utilities-map: build-utilities-map(); // stylelint-disable-line scss/dollar-variable-default |
37 | 53 |
|
38 | | -// Print utilities |
39 | | -@media print { |
40 | | - @each $key, $utility in $utilities { |
41 | | - // The utility can be disabled with `false`, thus check if the utility is a map first |
42 | | - // Then check if the utility needs print styles |
43 | | - @if type-of($utility) == "map" and map-get($utility, print) == true { |
44 | | - @include generate-utility($utility, "-print"); |
| 54 | +@mixin util($class) { |
| 55 | + @if map-has-key($utilities-map, $class) { |
| 56 | + $definition: map-get($utilities-map, $class); |
| 57 | + $breakpoint: map-get($definition, breakpoint); |
| 58 | + @if $breakpoint != null { |
| 59 | + @include media-breakpoint-up($breakpoint) { |
| 60 | + @each $property in map-get($definition, properties) { |
| 61 | + #{$property}: map-get($definition, value); |
| 62 | + } |
| 63 | + } |
45 | 64 | } |
| 65 | + @else { |
| 66 | + @each $property in map-get($definition, properties) { |
| 67 | + #{$property}: map-get($definition, value); |
| 68 | + } |
| 69 | + } |
| 70 | + } |
| 71 | + @else { |
| 72 | + @debug "Unknown utility class " + $class; |
46 | 73 | } |
47 | 74 | } |
0 commit comments