Last active
February 24, 2017 22:55
-
-
Save poeticninja/70717c214266af8237fc203ef22dc705 to your computer and use it in GitHub Desktop.
Spacing for styles
This file contains 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
@mixin spacing($prop: padding, $dir: top, $value: 1) { | |
#{$prop}-#{$dir}: $value; | |
} | |
@function initial($string) { | |
@return str-slice($string, 0, 1); | |
} | |
$properties: ( | |
margin, | |
padding | |
); | |
$sizes: ( | |
0: 0px, | |
1: 3px, | |
2: 5px, | |
3: 7px, | |
4: 10px, | |
5: 15px, | |
6: 25px, | |
7: 50px | |
); | |
$positions: ( | |
top, | |
right, | |
bottom, | |
left | |
); | |
$elements: ( | |
h1, | |
h2, | |
h3, | |
h4, | |
h5, | |
h6, | |
p, | |
li, | |
i, | |
a, | |
small, | |
ul, | |
ol, | |
form, | |
input, | |
button, | |
null | |
); | |
@each $element in $elements { | |
@each $prop in $properties { | |
@each $position in $positions { | |
@each $size_name, $size_value in $sizes { | |
#{$element}.#{initial($prop)}#{initial($position)}-#{$size_name} { | |
@include spacing($prop, $position, $size_value); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Generates spacing classes for margin and padding.