Created
August 9, 2018 23:20
-
-
Save imliam/798315d83a1b5dc588a83fae6c1ad99c to your computer and use it in GitHub Desktop.
Utilities for controlling an element's padding and margin.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
|-------------------------------------------------------------------------- | |
| Spacing | |
|-------------------------------------------------------------------------- | |
| | |
| Utilities for controlling an element's padding and margin. | |
| | |
*/ | |
$spacing-class: ( | |
"p": "padding", | |
"m": "margin", | |
); | |
$spacing-sides: ( | |
"": "", | |
"t": "-top", | |
"b": "-bottom", | |
"l": "-left", | |
"r": "-right", | |
"x": "-left" "-right", | |
"y": "-top" "-bottom", | |
); | |
$spacing-spaces: ( | |
"-0": "0", | |
"-1": "0.25rem", | |
"-2": "0.5rem", | |
"-3": "0.75rem", | |
"-4": "1rem", | |
"-6": "1.5rem", | |
"-8": "2rem", | |
"-px": "1px", | |
"-auto": "auto", | |
); | |
@each $className, $classProperty in $spacing-class { | |
@each $sideName, $sideProperty in $spacing-sides { | |
@each $spaceName, $spaceProperty in $spacing-spaces { | |
.#{$className}#{$sideName}#{$spaceName} { | |
@if type-of($sideProperty) == "list" { | |
@each $side in $sideProperty { | |
#{$classProperty}#{$side}: #{$spaceProperty}; | |
} | |
} @else { | |
#{$classProperty}#{$sideProperty}: #{$spaceProperty}; | |
} | |
} | |
@if $classProperty == "margin" { | |
.-#{$className}#{$sideName}#{$spaceName} { | |
@if type-of($sideProperty) == "list" { | |
@each $side in $sideProperty { | |
#{$classProperty}#{$side}: -#{$spaceProperty}; | |
} | |
} @else { | |
#{$classProperty}#{$sideProperty}: -#{$spaceProperty}; | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment