Last active
August 29, 2015 14:15
-
-
Save S3ak/b53edb6592118f1ee15a to your computer and use it in GitHub Desktop.
OOCSS size helpers
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
// Sizes are determined by the golden ratio formula | |
$ms-base: 8px; | |
$ms-ratio: $golden; | |
$ms-xs: $ms-base; | |
$ms-sm: floor((ms(2))); | |
$ms-md: floor((ms(3))); | |
$ms-lg: floor((ms(4))); | |
$ms-xl: floor((ms(6))); | |
$ms-xxl: floor((ms(10))); | |
@mixin size-tb($property, $top, $bottom: $top) { | |
#{$property}-top: $top; | |
#{$property}-bottom: $bottom; | |
} | |
@mixin size-lr($property, $left, $right: $left) { | |
#{$property}-left: $left; | |
#{$property}-right: $right; | |
} | |
$size-list: ( | |
'0' : 0, | |
'xs' : $ms-xs, | |
'sm' : $ms-sm, | |
'md' : $ms-md, | |
'lg' : $ms-lg, | |
'xl' : $ms-xl, | |
'xxl' : $ms-xxl | |
); | |
$directions: ( | |
'l': 'left', | |
't': 'top', | |
'r': 'right', | |
'b': 'bottom', | |
); | |
$property: ( | |
'm': 'margin', | |
'p': 'padding', | |
); | |
@each $property-alias, $property-full in $property { | |
@each $size-alias, $size-value in $size-list { | |
.#{$property-alias}4-#{$size-alias} { | |
@include size-tb($property-full, $size-value); | |
@include size-lr($property-full, $size-value); | |
} | |
} | |
} | |
@each $property-short, $property-full in $property { | |
@each $direction-short, $direction-full in $directions { | |
@each $size-name, $size-value in $size-list { | |
.#{$property-short}#{$direction-short}-#{$size-name} {#{$property-full}-#{$direction-full}: $size-value} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Gets complied to
.m4-0 {
margin-top: 0;
margin-bottom: 0;
margin-left: 0;
margin-right: 0; }
.m4-xs {
margin-top: 8px;
margin-bottom: 8px;
margin-left: 8px;
margin-right: 8px; }
.m4-sm {
margin-top: 20px;
margin-bottom: 20px;
margin-left: 20px;
margin-right: 20px; }
.m4-md {
margin-top: 33px;
margin-bottom: 33px;
margin-left: 33px;
margin-right: 33px; }
.m4-lg {
margin-top: 54px;
margin-bottom: 54px;
margin-left: 54px;
margin-right: 54px; }
.m4-xl {
margin-top: 143px;
margin-bottom: 143px;
margin-left: 143px;
margin-right: 143px; }
.m4-xxl {
margin-top: 983px;
margin-bottom: 983px;
margin-left: 983px;
margin-right: 983px; }
.p4-0 {
padding-top: 0;
padding-bottom: 0;
padding-left: 0;
padding-right: 0; }
.p4-xs {
padding-top: 8px;
padding-bottom: 8px;
padding-left: 8px;
padding-right: 8px; }
.p4-sm {
padding-top: 20px;
padding-bottom: 20px;
padding-left: 20px;
padding-right: 20px; }
.p4-md {
padding-top: 33px;
padding-bottom: 33px;
padding-left: 33px;
padding-right: 33px; }
.p4-lg {
padding-top: 54px;
padding-bottom: 54px;
padding-left: 54px;
padding-right: 54px; }
.p4-xl {
padding-top: 143px;
padding-bottom: 143px;
padding-left: 143px;
padding-right: 143px; }
.p4-xxl {
padding-top: 983px;
padding-bottom: 983px;
padding-left: 983px;
padding-right: 983px; }
.ml-0 {
margin-left: 0; }
.ml-xs {
margin-left: 8px; }
.ml-sm {
margin-left: 20px; }
.ml-md {
margin-left: 33px; }
.ml-lg {
margin-left: 54px; }
.ml-xl {
margin-left: 143px; }
.ml-xxl {
margin-left: 983px; }
.mt-0 {
margin-top: 0; }
.mt-xs {
margin-top: 8px; }
.mt-sm {
margin-top: 20px; }
.mt-md {
margin-top: 33px; }
.mt-lg {
margin-top: 54px; }
.mt-xl {
margin-top: 143px; }
.mt-xxl {
margin-top: 983px; }
.mr-0 {
margin-right: 0; }
.mr-xs {
margin-right: 8px; }
.mr-sm {
margin-right: 20px; }
.mr-md {
margin-right: 33px; }
.mr-lg {
margin-right: 54px; }
.mr-xl {
margin-right: 143px; }
.mr-xxl {
margin-right: 983px; }
.mb-0 {
margin-bottom: 0; }
.mb-xs {
margin-bottom: 8px; }
.mb-sm {
margin-bottom: 20px; }
.mb-md {
margin-bottom: 33px; }
.mb-lg {
margin-bottom: 54px; }
.mb-xl {
margin-bottom: 143px; }
.mb-xxl {
margin-bottom: 983px; }
.pl-0 {
padding-left: 0; }
.pl-xs {
padding-left: 8px; }
.pl-sm {
padding-left: 20px; }
.pl-md {
padding-left: 33px; }
.pl-lg {
padding-left: 54px; }
.pl-xl {
padding-left: 143px; }
.pl-xxl {
padding-left: 983px; }
.pt-0 {
padding-top: 0; }
.pt-xs {
padding-top: 8px; }
.pt-sm {
padding-top: 20px; }
.pt-md {
padding-top: 33px; }
.pt-lg {
padding-top: 54px; }
.pt-xl {
padding-top: 143px; }
.pt-xxl {
padding-top: 983px; }
.pr-0 {
padding-right: 0; }
.pr-xs {
padding-right: 8px; }
.pr-sm {
padding-right: 20px; }
.pr-md {
padding-right: 33px; }
.pr-lg {
padding-right: 54px; }
.pr-xl {
padding-right: 143px; }
.pr-xxl {
padding-right: 983px; }
.pb-0 {
padding-bottom: 0; }
.pb-xs {
padding-bottom: 8px; }
.pb-sm {
padding-bottom: 20px; }
.pb-md {
padding-bottom: 33px; }
.pb-lg {
padding-bottom: 54px; }
.pb-xl {
padding-bottom: 143px; }
.pb-xxl {
padding-bottom: 983px; }