|
| 1 | +@use "sass:map"; |
| 2 | +@use "sass:math"; |
1 | 3 | @use "config" as *;
|
| 4 | +@use "mixins" as *; |
2 | 5 |
|
3 | 6 | $selectors: ("m": margin, "p": padding);
|
4 | 7 | $directions: ("t": top, "b": bottom, "l": left, "r": right);
|
5 | 8 | $axes: "y", "x";
|
6 | 9 |
|
7 |
| -@each $prefix, $selector in $selectors { |
8 |
| - @each $suffix, $space in $spacing { |
9 |
| - .#{$prefix}-#{$suffix} { |
10 |
| - #{$selector}: #{$space} !important; |
11 |
| - } |
12 |
| - } |
13 |
| -} |
| 10 | +$breakpoint-values: map.values($breakpoints); |
| 11 | +$min-breakpoint: math.min($breakpoint-values...); |
| 12 | + |
| 13 | +@each $breakpoint, $breakpoint-value in $breakpoints { |
| 14 | + @if $breakpoint-value == $min-breakpoint { |
| 15 | + @each $prefix, $selector in $selectors { |
| 16 | + @each $suffix, $space in $spacing { |
| 17 | + @include validate-unit($space, number, px, em, rem); |
14 | 18 |
|
15 |
| -@each $prefix, $selector in $selectors { |
16 |
| - @each $abbr-dir, $direction in $directions { |
17 |
| - @each $suffix, $space in $spacing { |
18 |
| - .#{$prefix}#{$abbr-dir}-#{$suffix} { |
19 |
| - #{$selector}-#{$direction}: #{$space} !important; |
| 19 | + @each $abbr-dir, $direction in $directions { |
| 20 | + .#{$prefix}#{$abbr-dir}-#{$suffix} { |
| 21 | + #{$selector}-#{$direction}: #{$space} !important; |
| 22 | + } |
| 23 | + } |
| 24 | + |
| 25 | + @each $axis in $axes { |
| 26 | + .#{$prefix}#{$axis}-#{$suffix} { |
| 27 | + @if $axis == "y" { |
| 28 | + #{$selector}-top: #{$space} !important; |
| 29 | + #{$selector}-bottom: #{$space} !important; |
| 30 | + } @else if $axis == "x" { |
| 31 | + #{$selector}-left: #{$space} !important; |
| 32 | + #{$selector}-right: #{$space} !important; |
| 33 | + } |
| 34 | + } |
| 35 | + } |
| 36 | + |
| 37 | + .#{$prefix}-#{$suffix} { |
| 38 | + #{$selector}: #{$space} !important; |
| 39 | + } |
20 | 40 | }
|
21 | 41 | }
|
22 |
| - } |
23 |
| -} |
| 42 | + } @else { |
| 43 | + @media (min-width: $breakpoint-value) { |
| 44 | + @each $prefix, $selector in $selectors { |
| 45 | + @each $suffix, $space in $spacing { |
| 46 | + @include validate-unit($space, number, px, em, rem); |
| 47 | + |
| 48 | + @each $abbr-dir, $direction in $directions { |
| 49 | + .#{$prefix}#{$abbr-dir}-#{$breakpoint}-#{$suffix} { |
| 50 | + #{$selector}-#{$direction}: #{$space} !important; |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | + @each $axis in $axes { |
| 55 | + .#{$prefix}#{$axis}-#{$breakpoint}-#{$suffix} { |
| 56 | + @if $axis == "y" { |
| 57 | + #{$selector}-top: #{$space} !important; |
| 58 | + #{$selector}-bottom: #{$space} !important; |
| 59 | + } @else if $axis == "x" { |
| 60 | + #{$selector}-left: #{$space} !important; |
| 61 | + #{$selector}-right: #{$space} !important; |
| 62 | + } |
| 63 | + } |
| 64 | + } |
24 | 65 |
|
25 |
| -@each $prefix, $selector in $selectors { |
26 |
| - @each $axis in $axes { |
27 |
| - @each $suffix, $space in $spacing { |
28 |
| - .#{$prefix}#{$axis}-#{$suffix} { |
29 |
| - @if $axis == "y" { |
30 |
| - #{$selector}-top: #{$space} !important; |
31 |
| - #{$selector}-bottom: #{$space} !important; |
32 |
| - } @else if $axis == "x" { |
33 |
| - #{$selector}-left: #{$space} !important; |
34 |
| - #{$selector}-right: #{$space} !important; |
| 66 | + .#{$prefix}-#{$breakpoint}-#{$suffix} { |
| 67 | + #{$selector}: #{$space} !important; |
| 68 | + } |
35 | 69 | }
|
36 | 70 | }
|
37 | 71 | }
|
|
0 commit comments