csswizardry / ama

Ask me anything!
57 stars 4 forks source link

What do you think about functional CSS? #2

Closed lucas-aragno closed 7 years ago

mhairston commented 7 years ago

I think this article might contain your answer: https://csswizardry.com/2015/03/can-css-be-too-modular/

csswizardry commented 7 years ago

Hey!

So yeah, the link @mhairston posted is a pretty good summary of my thoughts. To expand a little more though:

  1. I am glad that people are experimenting with this stuff, even though I’m not sure it’s the right approach.
  2. I do understand some of the thinking—why do we need to keep writing more CSS when we can just reuse the same utilities over and over?—but this feels like something of a fallacy to me. Just because we can break things into their smallest possible parts, it doesn’t mean this is the correct approach to take. For m, functional CSS is like letters of the alphabet; componentised CSS (e.g. BEM) is like words; and old-school nested CSS (e.g. #header ul li a span{}) is like sentences. We can compose letters, sure, but we don’t because that’s too granular and on their own they lack any meaning. We can’t really compose sentences too well because they’re pretty inflexible: this only works if we have the correct sentence(s) at the correct time(s). Words are the perfect level of granularity: they’re incredibly composable and have meaning in-and-of themselves. For me, this is encapsulation without too much constraint.
  3. If you work in a company with lots of different feature teams needing to consume CSS but slightly modify or reskin applications, this flat-out doesn’t work: you can’t really retheme a .blk class to be red.