Skip to content

Instantly share code, notes, and snippets.

@lineharo
Forked from jeremyben/generators.scss
Last active April 14, 2019 15:13
Show Gist options
  • Save lineharo/ca9ac9025802b6288ca9a357bcae9b0c to your computer and use it in GitHub Desktop.
Save lineharo/ca9ac9025802b6288ca9a357bcae9b0c to your computer and use it in GitHub Desktop.
Css space around element generators (margin, padding) #css #stylus
// Generate class helpers for size properties such as margin, padding
// Usage :
// marginer(0.5, 3, 0.5)
// .mt3 will then add margin-top: 2.5rem; to the element,
// and so on for each side, from 0.5rem to 2,5rem with a 0.5rem step.
paddinger(min, max, step, counter=0)
.pt{counter}
padding-top (min rem)
.pb{counter}
padding-bottom (min rem)
.pl{counter}
padding-left (min rem)
.pr{counter}
padding-right (min rem)
.px{counter}
padding-left (min rem)
padding-right (min rem)
.py{counter}
padding-bottom (min rem)
padding-top (min rem)
if min < max
paddinger(min + step, max, step, counter+1)
marginer(min, max, step, counter=0)
.mt{counter}
margin-top (min rem)
.mpb{counter}
margin-bottom (min rem)
.ml{counter}
margin-left (min rem)
.mr{counter}
margin-right (min rem)
.mx{counter}
margin-left (min rem)
margin-right (min rem)
.my{counter}
margin-bottom (min rem)
margin-top (min rem)
if min < max
marginer(min + step, max, step, counter+1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment