-
-
Save botmaster/e61f4885c87ecd94540548db6b1036f2 to your computer and use it in GitHub Desktop.
Sass spacing utility
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
// ---- | |
// libsass (v3.3.2) | |
// ---- | |
$spacer: 1rem; | |
$spacer-x: $spacer; | |
$spacer-y: $spacer; | |
$spacers: (); | |
@for $i from 0 through 3 { | |
$spacers: map-merge($spacers, ( | |
$i: ( | |
x: $spacer-x * $i, | |
y: $spacer-y * $i | |
) | |
)) | |
} | |
@each $prop, $abbrev in (margin: m, padding: p) { | |
@each $size, $lengths in $spacers { | |
$length-x: map-get($lengths, x); | |
$length-y: map-get($lengths, y); | |
.#{$abbrev}-a-#{$size} { #{$prop}: $length-y $length-x !important; } // a = All sides | |
.#{$abbrev}-t-#{$size} { #{$prop}-top: $length-y !important; } | |
.#{$abbrev}-r-#{$size} { #{$prop}-right: $length-x !important; } | |
.#{$abbrev}-b-#{$size} { #{$prop}-bottom: $length-y !important; } | |
.#{$abbrev}-l-#{$size} { #{$prop}-left: $length-x !important; } | |
// Axes | |
.#{$abbrev}-x-#{$size} { | |
#{$prop}-right: $length-x !important; | |
#{$prop}-left: $length-x !important; | |
} | |
.#{$abbrev}-y-#{$size} { | |
#{$prop}-top: $length-y !important; | |
#{$prop}-bottom: $length-y !important; | |
} | |
} | |
} |
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
.m-a-0 { | |
margin: 0rem 0rem !important; | |
} | |
.m-t-0 { | |
margin-top: 0rem !important; | |
} | |
.m-r-0 { | |
margin-right: 0rem !important; | |
} | |
.m-b-0 { | |
margin-bottom: 0rem !important; | |
} | |
.m-l-0 { | |
margin-left: 0rem !important; | |
} | |
.m-x-0 { | |
margin-right: 0rem !important; | |
margin-left: 0rem !important; | |
} | |
.m-y-0 { | |
margin-top: 0rem !important; | |
margin-bottom: 0rem !important; | |
} | |
.m-a-1 { | |
margin: 1rem 1rem !important; | |
} | |
.m-t-1 { | |
margin-top: 1rem !important; | |
} | |
.m-r-1 { | |
margin-right: 1rem !important; | |
} | |
.m-b-1 { | |
margin-bottom: 1rem !important; | |
} | |
.m-l-1 { | |
margin-left: 1rem !important; | |
} | |
.m-x-1 { | |
margin-right: 1rem !important; | |
margin-left: 1rem !important; | |
} | |
.m-y-1 { | |
margin-top: 1rem !important; | |
margin-bottom: 1rem !important; | |
} | |
.m-a-2 { | |
margin: 2rem 2rem !important; | |
} | |
.m-t-2 { | |
margin-top: 2rem !important; | |
} | |
.m-r-2 { | |
margin-right: 2rem !important; | |
} | |
.m-b-2 { | |
margin-bottom: 2rem !important; | |
} | |
.m-l-2 { | |
margin-left: 2rem !important; | |
} | |
.m-x-2 { | |
margin-right: 2rem !important; | |
margin-left: 2rem !important; | |
} | |
.m-y-2 { | |
margin-top: 2rem !important; | |
margin-bottom: 2rem !important; | |
} | |
.m-a-3 { | |
margin: 3rem 3rem !important; | |
} | |
.m-t-3 { | |
margin-top: 3rem !important; | |
} | |
.m-r-3 { | |
margin-right: 3rem !important; | |
} | |
.m-b-3 { | |
margin-bottom: 3rem !important; | |
} | |
.m-l-3 { | |
margin-left: 3rem !important; | |
} | |
.m-x-3 { | |
margin-right: 3rem !important; | |
margin-left: 3rem !important; | |
} | |
.m-y-3 { | |
margin-top: 3rem !important; | |
margin-bottom: 3rem !important; | |
} | |
.p-a-0 { | |
padding: 0rem 0rem !important; | |
} | |
.p-t-0 { | |
padding-top: 0rem !important; | |
} | |
.p-r-0 { | |
padding-right: 0rem !important; | |
} | |
.p-b-0 { | |
padding-bottom: 0rem !important; | |
} | |
.p-l-0 { | |
padding-left: 0rem !important; | |
} | |
.p-x-0 { | |
padding-right: 0rem !important; | |
padding-left: 0rem !important; | |
} | |
.p-y-0 { | |
padding-top: 0rem !important; | |
padding-bottom: 0rem !important; | |
} | |
.p-a-1 { | |
padding: 1rem 1rem !important; | |
} | |
.p-t-1 { | |
padding-top: 1rem !important; | |
} | |
.p-r-1 { | |
padding-right: 1rem !important; | |
} | |
.p-b-1 { | |
padding-bottom: 1rem !important; | |
} | |
.p-l-1 { | |
padding-left: 1rem !important; | |
} | |
.p-x-1 { | |
padding-right: 1rem !important; | |
padding-left: 1rem !important; | |
} | |
.p-y-1 { | |
padding-top: 1rem !important; | |
padding-bottom: 1rem !important; | |
} | |
.p-a-2 { | |
padding: 2rem 2rem !important; | |
} | |
.p-t-2 { | |
padding-top: 2rem !important; | |
} | |
.p-r-2 { | |
padding-right: 2rem !important; | |
} | |
.p-b-2 { | |
padding-bottom: 2rem !important; | |
} | |
.p-l-2 { | |
padding-left: 2rem !important; | |
} | |
.p-x-2 { | |
padding-right: 2rem !important; | |
padding-left: 2rem !important; | |
} | |
.p-y-2 { | |
padding-top: 2rem !important; | |
padding-bottom: 2rem !important; | |
} | |
.p-a-3 { | |
padding: 3rem 3rem !important; | |
} | |
.p-t-3 { | |
padding-top: 3rem !important; | |
} | |
.p-r-3 { | |
padding-right: 3rem !important; | |
} | |
.p-b-3 { | |
padding-bottom: 3rem !important; | |
} | |
.p-l-3 { | |
padding-left: 3rem !important; | |
} | |
.p-x-3 { | |
padding-right: 3rem !important; | |
padding-left: 3rem !important; | |
} | |
.p-y-3 { | |
padding-top: 3rem !important; | |
padding-bottom: 3rem !important; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment