Hacker News
Modern CSS Code Snippets: Stop writing CSS like it's 2015
ktpsns
|next
[-]
crooked-v
|root
|parent
|next
[-]
mattlondon
|root
|parent
|next
|previous
[-]
At least html and CSS are both presentation. React/JSX now confuses presentation and business logic.
lateforwork
|root
|parent
|next
[-]
React was originally designed to be the "V in MVC". You can still use it that way. React becomes very simple when you only use it as the V in MVC.
azangru
|root
|parent
[-]
lateforwork
|root
|parent
|next
[-]
V stands for View. This layer handles HTML and CSS. You can use React here.
C stands for Controller. Controllers know about Views and Models and which model objects to instantiate for which view. It makes REST API calls and does caching, and handles errors. Controllers know about the application state and decide what page to display next.
For an application written in this style see: https://github.com/wisercoder/eureka/tree/master/webapp/Clie...
(This app doesn't use React, but does use TSX, and you could use React as well).
apsurd
|root
|parent
|next
|previous
[-]
In practice, the entire JS ecosystem enjoys flying off the rails, every season, but it's not strictly react's fault.
To answer your question, however those props get into the component is up the the M & C. can be async server, or shoved in as json in the script tag.
h4x0rr
|root
|parent
|previous
[-]
lawn
|root
|parent
[-]
afiori
|root
|parent
|next
[-]
@scope fixes a lot of this, but it is a complex problem. With tailwind you mostly have to worry about inheritance
chrisweekly
|root
|parent
|next
|previous
[-]
apsurd
|root
|parent
[-]
And now with AI generated code i see so many wrapper patterns that forward endless props down, it's crazy!
TLDR: i almost always end up branching out into evergreen "reusable" components.
Bengalilol
|next
|previous
[-]
Browsers: Yeah, but beware of limited availability, most of those creative examples are in the 40-50% browsers support range.
cwillu
|next
|previous
[-]
anematode
|next
|previous
[-]
piskov
|next
|previous
[-]
For example instead of grid center, one can use flex and margin auto.
If you are building really nation-wide products, there are still a lot of guys in corporate with old windows (where even chrome stopped updating like win7). Or, you know, old or poor people with PC from 2008.
Also don’t forget guys with mobile phones: not like one could easily install a browser there. Especially on phones which no longer receive updates.
So writing CSS like it is 2015 is great. Not because it feels great but because it is what caring about your users (and business) is.
Otherwise you’ll get humbled by your clients soon enough. And in corporate they won’t even be your clients unless you support old stuff: IE 11 is a great target if you really want to shine.
jgalt212
|next
|previous
[-]
laacz
|next
|previous
[-]
apsurd
|root
|parent
|next
[-]
I too am saddened by the instant-polish marketing pages everyone and their grandma deploys to Render, but also some people at some point in time really did make these effects. And they are nice. HTML based UIs will always have a place in my heart.
Btw: actually I think webflow did more to pump this stuff out to the masses. The animate on scroll being the biggest offender. It's so good, but not for every literal text paragraph on your local bakery's website.