glam icon indicating copy to clipboard operation
glam copied to clipboard

stylis

Open threepointone opened this issue 8 years ago • 5 comments

Use stylis as the parser, this will make a runtime version more viable

threepointone avatar May 11 '17 06:05 threepointone

👍

thysultan avatar May 11 '17 14:05 thysultan

yo @thysultan, thanks or showing up! quick question - is it possible for stylis to return the parsed rules as an array, instead all concatenated into a string? This will make it possible to use insertRule. Thanks!

threepointone avatar May 18 '17 08:05 threepointone

It is possible with a middleware, ex.

function plugin (context, block, line, column, id, length) {
    switch (context) {
       // executed whenever a block of css is done compiling.
       case 5: case 6: rules.push(block);
       // or directly interface with insertRulle
       // case 5: case 6: styleSheet.insertRule(block, length)
    }
}

Since it could become a common pattern this could be added to be built into stylis in the V3 rewrite, ex.

const rules = [];

stylis.set({
output: rules
})

// rules
[
'selector {...body}'
]

// or
const rules = {};

stylis.set({
output: rules
})

// rules
{
'selector': '...body'
}

thysultan avatar May 18 '17 09:05 thysultan

@threepointone do you still want to do this? I want to add keyframes but I think this should be done first if we are going with it.

tkh44 avatar Jun 08 '17 19:06 tkh44

Not high priority for now.

threepointone avatar Jun 08 '17 19:06 threepointone