-
Notifications
You must be signed in to change notification settings - Fork 7
/
mixins.scss
163 lines (131 loc) · 3.67 KB
/
mixins.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
$spacing-sizes: (
0: 0rem,
1: 0.25rem,
2: 0.5rem,
3: 1rem,
4: 2rem,
5: 4rem,
6: 8rem,
) !default;
$spacing-important: true !default;
@mixin m($t : 1, $r: null, $b: null, $l: null) {
@if ($t and $r and $b and $l) {
@include mt($t);
@include mr($r);
@include mb($b);
@include ml($l);
} @else if ($t and $r and $b and not $l) {
@include mt($t);
@include mx($r);
@include mb($b);
} @else if ($t and $r and not $b and not $l) {
@include my($t);
@include mx($r);
} @else if ($t and not $r and not $b and not $l) {
@if ($t == 'auto') {
@include my(0); //be explicit about what the browser does
@include mx(auto);
} @else {
@include my($t);
@include mx($t);
}
} @else {
@error "m(#{$t}, #{$r}, #{$b}, #{$l}): Invalid parameters. Expects m($size), m($y, $x), m($t, $x, $b) or m($t, $r, $b, $l)"
}
}
@mixin mx($r : 1, $l : null) {
@if ($r and $l) {
@include mr($r);
@include ml($l);
} @else if ($r and not $l) {
@include mr($r);
@include ml($r);
} @else {
@error "mx(#{$r}, #{$l}): Invalid parameters. Expects mx($size) or mx($r, $l)"
}
}
@mixin my($t : 1, $b : null) {
@if ($t and $b) {
@include mt($t);
@include mb($b);
} @else if ($t and not $b) {
@include mt($t);
@include mb($t);
} @else {
@error "my(#{$t}, #{$b}): Invalid parameters. Expects my($size) or my($t, $b)"
}
}
@mixin ml($size : 1) {
@if ($size == 'auto') {
margin-left: auto #{if($spacing-important, '!important', '')};
} @else {
margin-left: map-get($spacing-sizes, $size) #{if($spacing-important, '!important', '')};
}
}
@mixin mt($size : 1) {
margin-top: map-get($spacing-sizes, $size) #{if($spacing-important, '!important', '')};
}
@mixin mr($size : 1) {
@if ($size == 'auto') {
margin-right: auto #{if($spacing-important, '!important', '')};
} @else {
margin-right: map-get($spacing-sizes, $size) #{if($spacing-important, '!important', '')};
}
}
@mixin mb($size : 1) {
margin-bottom: map-get($spacing-sizes, $size) #{if($spacing-important, '!important', '')};
}
@mixin p($t : 1, $r: null, $b: null, $l: null) {
@if ($t and $r and $b and $l) {
@include pt($t);
@include pr($r);
@include pb($b);
@include pl($l);
} @else if ($t and $r and $b and not $l) {
@include pt($t);
@include px($r);
@include pb($b);
} @else if ($t and $r and not $b and not $l) {
@include py($t);
@include px($r);
} @else if ($t and not $r and not $b and not $l) {
@include py($t);
@include px($t);
} @else {
@error "p(#{$t}, #{$r}, #{$b}, #{$l}): Invalid parameters. Expects p($size), p($y, $x), p($t, $x, $b) or p($t, $r, $b, $l)"
}
}
@mixin px($r : 1, $l : null) {
@if ($r and $l) {
@include pr($r);
@include pl($l);
} @else if ($r and not $l) {
@include pr($r);
@include pl($r);
} @else {
@error "px(#{$r}, #{$l}): Invalid parameters. Expects px($size) or px($r, $l)"
}
}
@mixin py($t : 1, $b : null) {
@if ($t and $b) {
@include pt($t);
@include pb($b);
} @else if ($t and not $b) {
@include pt($t);
@include pb($t);
} @else {
@error "py(#{$t}, #{$b}): Invalid parameters. Expects py($size) or py($t, $b)"
}
}
@mixin pl($size : 1) {
padding-left: map-get($spacing-sizes, $size) #{if($spacing-important, '!important', '')};
}
@mixin pt($size : 1) {
padding-top: map-get($spacing-sizes, $size) #{if($spacing-important, '!important', '')};
}
@mixin pr($size : 1) {
padding-right: map-get($spacing-sizes, $size) #{if($spacing-important, '!important', '')};
}
@mixin pb($size : 1) {
padding-bottom: map-get($spacing-sizes, $size) #{if($spacing-important, '!important', '')};
}