Re:Comparison of CSS in JavaScript Libraries for React
by colinmegill on Monday July 13, 2015 @09:56PM
(#9882393)
We've stopped shipping CSS on green fields client projects. It's been amazing. All of our styles are in JS objects that are applied to inline style tags. It's modularized like classes are, but there is no cascade so there are no globals. Most importantly, everything can be recomputed at any time - no longer dealing with a static stylesheet.
Re:Comparison of CSS in JavaScript Libraries for React
by natmaster on Monday July 13, 2015 @04:49PM
(#9880963)
Or just use webpack? Not sure what these things are trying to solve that making a less or scss file for every component file and require-ing it doesn't.
Re:Comparison of CSS in JavaScript Libraries for React
by PhrosTT on Monday July 13, 2015 @11:34PM
(#9882732)
So I'm looking for a simple solution 1 step beyond just using js style objects. Would radium be good without creating a ton of lock-in? I can't really sort through this giant chart.
var globalStyles = require("globalStyles");
var styles = { color: globalStyles.blue, padding: foo ? "15px" : "10px", margin: bar(this.state.qux) }
We built Radium to solve the problems this causes, like :hover - it's the lib Chan talks about in that React Europe talk christopherscot links to.
http://projects.formidablelabs.com/radium/
I talked at CSSConf about ditching CSS for inline about a month ago:
https://www.youtube.com/watch?v=NoaxsCi13yQ
You get scoped, modular, composable, requirable CSS without the burden of doing styles in JS.
[1] https://github.com/css-modules/css-modules
[2] https://github.com/webpack/css-loader
[3] https://github.com/css-modules/css-modulesify
I think that css-modules (implemented in webpack's css-loader) is the sanest approach: https://medium.com/seek-ui-engineering/the-end-of-global-css...