Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Generate spacing classes
/*
Usage: {shorthand for rule}{shorthand for direction}{integer-index}
{shorthand for rule}
p - padding
m - margin
{shorthand for direction}
t - top
r - right
b - bottom
l - left
v - vertical
h - horizontal
a - all
{integer-index}
[1-8]
*/
t(rule, size, u)
{rule}-top (u ? unit(size, u) : size)
r(rule, size, u)
{rule}-right (u ? unit(size, u) : size)
b(rule, size, u)
{rule}-bottom (u ? unit(size, u) : size)
l(rule, size, u)
{rule}-left (u ? unit(size, u) : size)
v(rule, size, u)
t(rule, size, u)
b(rule, size, u)
h(rule, size, u)
r(rule, size, u)
l(rule, size, u)
a(rule, size, u)
{rule} (u ? unit(size, u) : size)
spacing(base, numSizes)
for n in a v h t r b l
for m in 0..numSizes
.p{n}{m}
n(padding, (m*base), "px")
.m{n}{m}
n(margin, (m*base), "px")
.m{n}a
n(margin, auto, false)
spacing(10, 8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment