...and you get deduped atomic classes (plus proper source maps, so the debugging experience is actually pretty similar to vanilla CSS)
There are also more transparent ways to leverage existing functional css frameworks. For example, Mithril.js[2] lets you use CSS selectors in templates, so you can do things like:
const Button = 'button.some.atomic.classes';
m(Button) // equivalent to <Button /> in JSX
The problem with `class="button button-with-quirks"` has to do with specificity. Yes, you can edit the base class... but then you also need to go hunting for visual regressions anywhere you have a compound class because who knows what might be overwriting your edit and how. Also, your team needs to be extremely disciplined when dealing with 7 slightly different variations of left margin on a button (and usually they are not).
The two most important benefits of functional css that the post doesn't go into that are kinda important to the discussion are these:
- atomic styles can be deduped, making for smaller bundle sizes
- they make it nearly impossible to accrue specificity-related technical debt
Many of the downsides alluded in the article are solved by libraries like styletron.
There are also more transparent ways to leverage existing functional css frameworks. For example, Mithril.js[2] lets you use CSS selectors in templates, so you can do things like:
The problem with `class="button button-with-quirks"` has to do with specificity. Yes, you can edit the base class... but then you also need to go hunting for visual regressions anywhere you have a compound class because who knows what might be overwriting your edit and how. Also, your team needs to be extremely disciplined when dealing with 7 slightly different variations of left margin on a button (and usually they are not).The two most important benefits of functional css that the post doesn't go into that are kinda important to the discussion are these:
- atomic styles can be deduped, making for smaller bundle sizes
- they make it nearly impossible to accrue specificity-related technical debt
Many of the downsides alluded in the article are solved by libraries like styletron.
[1] https://github.com/styletron/styletron/
[2] https://mithril.js.org