cssinjs / jss

JSS is an authoring tool for CSS which uses JavaScript as a host language.
https://cssinjs.org
MIT License
7.08k stars 399 forks source link

Is there an utility function exposed on JSS to create DOM based inline styles? #1206

Closed ezsper closed 5 years ago

ezsper commented 5 years ago

A function css(element, cssProperties) that can reuse JSS plugins to create inline styles. This is particularly good for dynamic Javascript styles like positioning and animations.

I have seen some components using dependencies like dom-css.

It would be good a function like this so we could be using the same CSS generation API that is consistent with the ones on stylesheet.

kof commented 5 years ago

You can use function values for dynamic styles, they are updating cssom rules in JSS as opposed to creating new once in other cssinjs libs.

kof commented 5 years ago

Additionally you can use sheet.getRule(name).toJSON() which can be applied to style property on nodes, but I don't see the point of using it if you can have fast dynamic rendering while keeping all styling in one place in the style sheet.

kof commented 5 years ago

That being said, I am working on such an interface, but it's not released officially yet. https://github.com/cssinjs/jss/blob/master/packages/css-jss