4 ms·
In some of my projects I have 2 scopes: A framework scope and a component scope. The framework scope has all the composeable classes and standard forms like li
by mistersys 10y ago
In some of my projects I have 2 scopes: A framework scope and a component scope.
The framework scope has all the composeable classes and standard forms like lists, shadows, colors, grids, cards etc.
Then, when the framework doesn't cover everything, I use component scoped css to complete it, without having to worry about a naming scheme like BEM. It just makes things easier when you have css that is really only relevant to one component. Just like programming, I can always make the code abstract and move it up to the framework.
- debaserab2 10y agoWhat is the advantage of bringing your styling into javascript to do that? I do the exact same thing (I don't use BEM either) by isolating specific component styling to it's own SASS file.
- ryanar 10y agoCan I see how you setup webpack to parse individual sass files imported into components?
- mistersys 10y agoThe parent post as more about component based styling then css-in-js. As for css-in-js, there isn't much of an advantage to using it vs importing sass files as scoped. With Sass you get: - Familiare Syntax - Avoids inline styles - All benefits of the Sass community vs with css-in-js you primarily gain: - Dynamic and regular styles together - One less compiler dependency - Benefits of full JS for style generation So I think this really depends on the project and your preference, I don't think there's a massive benefit either way.