Skip to content

Instantly share code, notes, and snippets.

@zaydek-old
Last active June 15, 2018 10:07
Show Gist options
  • Save zaydek-old/533a8570348fed6c4d0db2a263148b2d to your computer and use it in GitHub Desktop.
Save zaydek-old/533a8570348fed6c4d0db2a263148b2d to your computer and use it in GitHub Desktop.
position(
- justification [left, h-center, right], // - could delimit optional, + could delimit required
- alignment [top, v-center, bottom]
) {
// map enum to expressions
:: [left, top] flex-start
:: [h-center, v-center] center
:: [right, bottom] flex-end
// no colons or semicolons
display flex
[justify-content justification] // [] delimits optional
[align-items alignment]
}
left() { position(left) } // () distinguishes function from element
h-center() { position(h-center) }
right() { position(right) }
top() { position(top) }
v-center() { position(v-center) }
bottom() { position(bottom) }
center() {
h-center // () unneeded if no arguments
v-center
}
.h1 {
headline
center
highlight
}
.h2 {
headline
center
highlight--alternate // BEM identifiers!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment