Last active
December 3, 2015 13:55
-
-
Save kevinruscoe/cdc90bf5cf10867af4ee to your computer and use it in GitHub Desktop.
utils-padding-margin.scss
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
$scopes: ( | |
margin: mar, | |
padding: pad | |
); | |
$locations: ( | |
top: t, | |
bottom: b, | |
left: l, | |
right: r, | |
x: x, | |
y: y | |
); | |
$ems: ( | |
.25em: xs, | |
.5em: sm, | |
1em: md, | |
1.5em: lg, | |
2em: xl | |
); | |
@mixin spacing($scope: padding, $location: top, $size: 1em){ | |
@if $location == "y" { | |
#{$scope}-top: $size; | |
#{$scope}-bottom: $size; | |
} | |
@elseif $location == "x" { | |
#{$scope}-left: $size; | |
#{$scope}-right: $size; | |
} | |
@else { | |
#{$scope}-#{$location}: $size; | |
} | |
} | |
@each $size, $size_short_name in $ems { | |
@each $scope, $scope_short_name in $scopes { | |
@each $location, $location_short_name in $locations { | |
.#{$scope_short_name}-#{$location_short_name}-#{$size_short_name} { | |
@include spacing($scope, $location, $size); | |
} | |
} | |
} | |
} | |
@mixin margin( $location: top, $size: 1em) { | |
@include spacing('margin', $location, $size); | |
} | |
@mixin padding($location: top, $size: 1em) { | |
@include spacing('padding', $location, $size); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment