-
Notifications
You must be signed in to change notification settings - Fork 0
/
_space-util.scss
63 lines (54 loc) · 1.61 KB
/
_space-util.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**
* New spacing utilities
*
* Multiple of spacing.
*
* 1. We want -half to be displayed in modifiers for spacing(0.5) since class names can't contain dot.
*/
$u-space-units: 0, 0.5, 1, 2, 3, 4, 5;
@mixin generate-spacing-classes-for($margin-side, $responsive-size) {
@each $spacing in $u-space-units {
$spacing-label: $spacing;
$classname: '';
$responsive-label: '';
$margin: '';
@if $margin-side == all {
@if $spacing == 0.5 {
$spacing-label: half; // 1
}
$classname: space-#{$spacing-label};
$margin: margin;
} @else {
@if $spacing == 0.5 {
$spacing-label: -half;
}
$side-abbr: str-slice($margin-side, 1, 1);
$classname: space-#{$side-abbr}#{$spacing-label};
$margin: margin-#{$margin-side};
}
@if ($responsive-size != ''){
$responsive-label: #{$responsive-size}#{'-'};
}
.u-#{$responsive-label}#{$classname} {
#{$margin}: spacing($spacing) !important;
}
}
}
$margin-sides: all, left, right, top, bottom;
@each $margin-side in $margin-sides {
@include generate-spacing-classes-for($margin-side, '');
}
@include responsive-medium {
.responsive {
@each $margin-side in $margin-sides {
@include generate-spacing-classes-for($margin-side, 'md');
}
}
}
@include responsive-small {
.responsive {
@each $margin-side in $margin-sides {
@include generate-spacing-classes-for($margin-side, 'sm');
}
}
}