Re:ReactCSS – Bringing Classes to Inline Styles
by guiporto on Friday July 03, 2015 @12:52PM
(#9826619)
I understand the idea but I still think the BEM methodology is better than this approach.
Re:ReactCSS – Bringing Classes to Inline Styles
by RussianCow on Friday July 03, 2015 @02:33PM
(#9827176)
I disagree. Using something like ReactCSS, all the code related to a component is in the same file. I don't have to switch between HTML, JS, and CSS files just to edit some small part of my app.
Re:ReactCSS – Bringing Classes to Inline Styles
by snookca on Friday July 03, 2015 @07:50PM
(#9828523)
I'm not sure that trying to keep everything in one file is necessarily a great argument. Optimizing for not having to open files doesn't seem like the best thing to optimize for. Even many of the react+inline styles examples include putting variables and other patterns into external files. Language (i18n) strings could be another external dependency. Data model, controllers, and routing are other good examples. (Rarely (if ever) have I seen an MVC framework that doesn't separate things into separate files.)
Re:ReactCSS – Bringing Classes to Inline Styles
by RussianCow on Friday July 03, 2015 @08:25PM
(#9828613)
It's more conceptual than keeping everything in one file. I want to be able to see everything related to a component without looking at anything else, and to be able to easily change its styling in the same way I change its structure or behavior (at least with React). You can technically do this by creating a separate CSS file for every component, but the problem is your CSS has no context about your component, and so you end up doing all kinds of shuffling with classes to get things to display the way you want them to. This is a much more elegant solution, in my opinion.
Re:ReactCSS – Bringing Classes to Inline Styles
by prezjordan on Friday July 03, 2015 @02:45PM
(#9827242)
BEM is a clever naming strategy to deal with the problems of a medium-to-large CSS codebase. Why put up with it in the first place?
Re:ReactCSS – Bringing Classes to Inline Styles
by clessg on Friday July 03, 2015 @03:06PM
(#9827369)
Component-orientation and both exist to mend the problems of global CSS. If you use BEM in React you will usually have a one-to-one relationship between BEM component classes and React components. RaisedButton component has a .RaisedButton class, Icon has .Icon, etc.
Re:ReactCSS – Bringing Classes to Inline Styles
by andreasklinger on Saturday July 04, 2015 @02:56AM
(#9829491)
We do this
Imho this is just "better" management of the same problem
this becomes very quickly hard to manage
the core idea is to do what react did in js (global namespace => components) but for css
that being said i believe stuff like https://github.com/css-modules/css-modules will be a more correct solution (you can also use scss to precompile eg)