r/webdev • • Mar 30 '17

CSS is Fine, It’s Just Really Hard

https://medium.com/@jdan/css-is-fine-its-just-really-hard-638da7a3dce0
12 Upvotes

16 comments sorted by

14

u/lamb_pudding Mar 30 '17

I don't like this article. The author doesn't really explain the reason they like the JavaScript rendered CSS. Also, it's not perfect, it uses !importants.

2

u/eeanmu Mar 30 '17

Yeah...

Compile something into JavaScript you'll need to copy a dozen times in a simple UI...

/Shrug

6

u/lamb_pudding Mar 30 '17

This article is good. Goes into why people might not like CSS and it's because they are not using it correctly.

2

u/eeanmu Mar 30 '17

Nice. Thanks, I enjoyed that.

I personally have been using cssguidelin.es as the style guide I push at work.

-6

u/jordanscales Mar 30 '17

Thanks for the reply! Are you interested in reading the article? If you slow down your scroll wheel a bit you'll notice I explain exactly why I prefer my JavaScript rendered CSS: because it's automatic BEM. I also link to a post where I explain this point in greater detail: https://medium.com/@jdan/rendering-khan-academys-learn-menu-wherever-i-please-4b58d4a9432d

The point of this post, which I believe you zipped past, was that CSS is good and it's here to stay. So I am rallying up the "CSS-in-JS" crowd to stop saying "CSS is bad!" (it's fine!), and trying to get folks like you stop telling me my bugs are because I'm not good at CSS (I am good at CSS - I have a trophy). I am merely compiling to CSS. Still writing it.

5

u/lamb_pudding Mar 30 '17

In your last section where you show your CSS in JS method you do not mention that it does BEM naming for you. You mention you don't like writing CSS and you hint that JS makes it easier for you. It would have been helpful if you were explicit about what makes it helpful.

Also, calling CSS with !importants clean and perfect makes me not take the article seriously.

-2

u/xueye Mar 30 '17

You mention you don't like writing CSS and you hint that JS makes it easier for you. It would have been helpful if you were explicit about what makes it helpful.

Well, I mean:

It’s unique to this component

It travels with the component

I’m letting JavaScript handle all my constants and shared mixins.

I’m letting JavaScript write the perfect CSS for me.

etc.

That seems pretty explicit to me.

5

u/ahoy1 Mar 30 '17

The article doesn't explain any of that. It shows us 20 lines of js and expects the reader to make those assumptions.

8

u/fireaccount90 Mar 30 '17

"If you slow down your scroll wheel a bit you'll notice I explain"

you should work on your social skills & learn to take constructive criticism better if you plan on building a readership.

-1

u/TheDudePenguin Mar 30 '17

hes not wrong though, the guy didn't read the article and made a comment about it.

2

u/fireaccount90 Mar 30 '17

I don't really care about wrong or right...this guy is writing blogs. theres better ways to respond if you care about getting new/keeping older readers. if he is okay looking immature in a professional environment thats his call.

1

u/nyxin The 🍰 is a lie. Mar 30 '17

...you sound like you need a whiskey. It's OK. It's just a op-ed blog article. Nobody's getting interviewed over it...yet

1

u/fireaccount90 Mar 30 '17

im so mad i just audibly sighed at my desk.

7

u/ahoy1 Mar 30 '17

It's a funny article, but it doesn't make a case for the proposed "solution" at all. It doesn't seem meaningfully different than <div class="text-bold margin-auto border-bottom-thin">(with the associated single-property class definitions in a CSS file).

Why is this better than that?

2

u/Lyxs Mar 30 '17

Those were my thoughts exactly. It just seems like extra work to achieve the same result as having single property css classes. With the downside that you must now include js in your page, wether you need it or not.

1

u/jordanscales Mar 30 '17

You are correct - it is essentially the same as that! Component classes are a beautiful pattern, which is why things like http://tachyons.io/ have been so well-received.

"CSS-in-JS" solutions like aphrodite have the output of something like BEM, with the authoring experience of something like Tachyons. You can write component classes, or mixins (whatever abstraction you'd like, really), and you know the output is sound and won't collide with anything in the DOM. Properties like line-height will still cascade down and muddy the waters a bit, but you always reset.

"Well I can just do that without JavaScript" Great! Please do! But also understand that we're human and we make typos. Or make the wrong abstractions, and that's why I let the robots do the manual work for me.