Last active
August 29, 2015 13:57
-
-
Save yamadapc/9836055 to your computer and use it in GitHub Desktop.
I'm just playing with stylus; it's funny markup is the kind of thing which *should* be as dynamic as possible :P
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
/** | |
* Sets a selector to a variable. | |
* | |
* @example | |
* | |
* font-size-h1 = 10px | |
* from-variable(h1, font-size) | |
* | |
* would yield: | |
* | |
* h1 { | |
* font-size: 10px | |
* } | |
* | |
* The following would also result in the same CSS: | |
* // when the variable is != than the attribute | |
* fs-h1 = 10px | |
* from-variable(h1, font-size, variable: fs) | |
* | |
* // when the posfix is diferent from the selector | |
* font-size-something = 10px | |
* from-variable(h1, font-size, posfix: 'something') | |
* | |
* // when things are weird (here the selector would be h1, .h1) | |
* fs-something = 10px | |
* from-variable('h1, .h1', font-size, fs, 'something') | |
*/ | |
from-variable(selector, attribute, variable=attribute, posfix=null) | |
value = variable + '-' + posfix // i.e. font-size + '-' + h1 | |
{selector} | |
{attribute}: value |
this could easily be a mixin too
with some clever seletor()
hack
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
... but... maybe I'm going against the flow...
I want programming to be static and markup to be dynamic o.O