Skip to content

Instantly share code, notes, and snippets.

@jensjns
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jensjns/1e87ccb7c903fa5b35c8 to your computer and use it in GitHub Desktop.
Save jensjns/1e87ccb7c903fa5b35c8 to your computer and use it in GitHub Desktop.
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