-
Notifications
You must be signed in to change notification settings - Fork 0
/
margins.txt
29 lines (28 loc) · 967 Bytes
/
margins.txt
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
/* Margin converter */
@mixin margins($mt: null, $mr: null, $mb: null, $ml: null) {
@if ($mt or $mr or $mb or $ml) {
@if (($mt == $mb) and ($mb == $mr) and ($mr == $ml)) {
margin: $mt;
} @else if (($mt == $mb) and ($mr == $ml)) {
margin: $mt $mr;
} @else if
(
((($mt != $mb) and (($mt and $mb) != null)) and (($mr == $ml) and ($mr != null))) or
((($mr != $ml) and (($mr and $ml) != null)) and (($mt == $mb) and ($mt != null)))
)
{
margin: $mt $mr $mb;
} @else if
((($mt != $mb) and (($mt and $mb) != null)) and (($mr != $ml) and (($mr and $ml) != null)))
{
margin: $mt $mr $mb $ml;
} @else {
/* prettier-ignore */
$margins: ('top': $mt, 'right': $mr, 'bottom': $mb, 'left': $ml,);
/* prettier-ignore */
@each $side, $direction in $margins { @if map-get($margins, $side) {
#{margin-#{$side}}: map-get($margins, $side); }}
}
}
@content;
}