DEV Community

Discussion on: Sticky Transitioning Veggie Hamburger 🍔

Collapse
 
efpage profile image
Eckehard

One reason to use CSS -in-JS could be the easier handling. You can put all the complicated things together in a module and just use one function call to apply all this to your menue. And - as JS is a programming language - you can react to whatever you want, not limited to what CSS provides. What if you want your menue to act differently on christmas, or on different machines? There sure is an easy solution with JS, but not necessarily with CSS.

Collapse
 
florianrappl profile image
Florian Rappl

Well the given scenario could be handled differently already on the server-side / when serving your page.

All in all I hope the CSS-in-JS did not confuse you. It was not needed in the beginning and is not needed right now. You can do the same code (at every step) with standard CSS. I just did not want to separate files / complicate the setup (as the original code used SASS I wanted the same convenience for the examples without having to use SASS).

The main objective was still to get the hamburger + sticky working exactly as beforehand - but without any JS.

Collapse
 
efpage profile image
Eckehard

That was exactly my topic: Though you can do things in different ways, sometimes you will decide to use a solution that is slower, but more convenient, uses less boilerplate and less configuration. Speed is not everything.

Thread Thread
 
florianrappl profile image
Florian Rappl

Definitely. I think we both agree here. The point was also not to say you need to use it - in our case it makes sense as the website is optimized for speed and most pages would not load any JS - if the menu would not require it. Thus looking for a non-JS solution made sense for us.