Skip to content

Instantly share code, notes, and snippets.

@simonsmith
Created June 19, 2014 18:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonsmith/9d0e07b074862b5268cc to your computer and use it in GitHub Desktop.
Save simonsmith/9d0e07b074862b5268cc to your computer and use it in GitHub Desktop.
Sizing utility classes for Sass
/**
* Spacing classes
*
* Used to override styles on components without need for
* additional modifier classes
*
* Usage:
* <div class="u-mbZ"> // margin-bottom: 0
* <div class="u-mt20"> // margin-top: 20px
*/
/**
* Vertical
*/
$vertical-property-map: (
mt: margin-top,
mb: margin-bottom,
pt: padding-top,
pb: padding-bottom,
);
$sizes-list: 5 10 15 20 25 30;
@each $size in $sizes-list {
$val: $size + 0px;
@each $keyword, $property in $vertical-property-map {
.u-#{$keyword}#{$size} {
#{$property}: $val !important;
}
}
}
/**
* Zero
*/
$zero-property-map: (
m: margin,
mt: margin-top,
mr: margin-right,
mb: margin-bottom,
ml: margin-left,
p: padding,
pt: padding-top,
pr: padding-right,
pb: padding-bottom,
pl: padding-left
);
@each $keyword, $property in $zero-property-map {
.u-#{$keyword}Z {
#{$property}: 0 !important;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment