News for hackers. Stuff that matters.
Re:Create React App 2.0: Babel 7, Sass, and More by sephware on Monday October 01, 2018 @10:40PM (#18118446)
> More styling options: you can use Sass and CSS Modules out of the box.

This is what I'm most excited about. Emotion is great but I've heard a lot of great things about CSS Modules, just haven't gotten around to trying them out yet because it's been so complicated to do. I'll definitely be giving it a try now.

Re:Create React App 2.0: Babel 7, Sass, and More by werbel on Tuesday October 02, 2018 @04:43AM (#18119793)
I started my engineering career as a front-end developer when being front-end developer meant slicing PSDs to HTML trying to figure out the best way to implement crazy glassy and shadowy designs without transparent PNG support in IE6.

Starting using CSS Modules "properly" with custom built UI components library was definitely the biggest single improvement in easiness of delivering stuff I've experienced across the "whole stack", from the hosting situation, DBs, through popularization of MVC on the server and client side, micro-services to react itself.

Please do give a try. :)

One rule of thumb I passed on my friend learning working with CSS Modules: Never share styles between components.

Sometimes it's very tempting but instead try to compose your components in different ways.

You might want to share style or create mixin for white box with a border and shadow for 2 very similar components. Creating WhiteShadowedBox component even if it's a div with 3 lines of CSS is fine and will save a some headache later. Of course needs a better name. ;)

It's fine to use variables and mixins for "style config" like colors, font definitions, margin scales (0.8rem, 1.2rem, 1.6rem) etc but in my experience not much more.

Re:Create React App 2.0: Babel 7, Sass, and More by davman on Tuesday October 02, 2018 @04:17AM (#18119664)
I wrote a bit[1] about CSS Modules with React, but interestingly it looks like CRA isn't using babel-plugin-react-css-modules so I'm trying to figure out what they're doing instead.

[1] https://dev.to/daveirvine/postcss-with-css-modules-andreact-...

Re:Create React App 2.0: Babel 7, Sass, and More by ascorbic on Thursday October 04, 2018 @01:17AM (#18137376)
It's perfectly fine to just use css-loader to handle CSS modules. No need for babel. Just do:

   import styles from "./style.css";

   <Component className={styles.myClassName} />
Re:Create React App 2.0: Babel 7, Sass, and More by brendanmc6 on Tuesday October 02, 2018 @01:17PM (#18123648)
I can't imagine using anything other than styled-components... Are there advantages to using CSS Modules instead?

Every time I look at the docs for another styling solution I just see unnecessary complexity for no clear benefit. Styled components are so easy to reason about and organize, especially when doing conditional / state based styling.