Live data from Hacker News

Modern CSS Code Snippets: Stop writing CSS like it's 2015

modern-css.com

31–40 of 318 posts

Re: Modern CSS Code Snippets: Stop writing CSS like it's 2015

#31
post #26

Earlier quoted context omitted.

> React/JSX now confuses presentation and business logic 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.

What are the M and the C, and how do they talk to the V in this case?

M stands for Model layer. This layer handles business logic and knows nothing about UI. It does not have any html or CSS.

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).

Re: Modern CSS Code Snippets: Stop writing CSS like it's 2015

#32
post #28
post #26

Earlier quoted context omitted.

What are the M and the C, and how do they talk to the V in this case?

react can be pure functions that take in props. Given a set of props, ideally data primitives, the outputted view is guaranteed. it's nice. 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.

If you move the data (the M and the C) entirely out of react, and only pass it in via props, there would be only one place — the root react node — where the props could get into react. Is this what you have in mind? Or are you envisioning multiple root nodes?

Re: Modern CSS Code Snippets: Stop writing CSS like it's 2015

#33
post #13

Earlier quoted context omitted.

Is jumping between files supposed to be difficult or something?

Colocation is a useful principle in component-based architecture.

In my lived experience, shared components just become another problem. Especially in a fledgling company, the iteration velocity is actually negatively affected by shared libs because there's always overhead to (not) break legacy. so shared components bloat to address every evolving need.

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 anyway.

Very unlikely the component library the CTO asked claude to DRY up the code with, is the one to rule them all.

Re: Modern CSS Code Snippets: Stop writing CSS like it's 2015

#34
post #4

CSS in 2025: Let's write html inlined styles as if it was 2005 and separation of formatting/representation was never invented. I talk of tailwind, of course.

Wait until you see React & JSX... At least html and CSS are both presentation. React/JSX now confuses presentation and business logic.

I think you're confusing business logic with view logic.

Re: Modern CSS Code Snippets: Stop writing CSS like it's 2015

#35
post #32
post #28

Earlier quoted context omitted.

react can be pure functions that take in props. Given a set of props, ideally data primitives, the outputted view is guaranteed. it's nice. 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.

If you move the data (the M and the C) entirely out of react, and only pass it in via props, there would be only one place — the root react node — where the props could get into react. Is this what you have in mind? Or are you envisioning multiple root nodes?

With signals you can avoid the prop drilling. I think signals can help a lot with this approach

Re: Modern CSS Code Snippets: Stop writing CSS like it's 2015

#36
post #22
post #13

Earlier quoted context omitted.

Is jumping between files supposed to be difficult or something?

Without a lot of discipline it is very easy to end up with a css with lots of unclear and hard to guess effects. Eg consider the case of where A and B are complex templates. Any selector with the " " operator on A risk expanding to the inner A even if it was intended only for the outer. Similarly a :has selector might catch a descendant of the wrong element. @scope fixes a lot of this, but it is a complex problem. Wi…

This problem was solved a long time ago with CSS Modules.

Re: Modern CSS Code Snippets: Stop writing CSS like it's 2015

#37
post #32
post #28

Earlier quoted context omitted.

react can be pure functions that take in props. Given a set of props, ideally data primitives, the outputted view is guaranteed. it's nice. 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.

If you move the data (the M and the C) entirely out of react, and only pass it in via props, there would be only one place — the root react node — where the props could get into react. Is this what you have in mind? Or are you envisioning multiple root nodes?

Well, i've always been a fan of the island architecture that effectively mounts root nodes as little islands of isolated state, yes.

Mainly this avoids the hell that global state SPA patterns produce: redux, reducer patterns in general, and 8 thousand context providers.

I do think there's use cases that warrant global in-memory state, but it's such a pain in the ass to maintain and evolve, i'd always plan against it. Every html node in your app does not need to know about literally everything going on and react instantly to it. it just doesn't.

Just make another page!

Also: so the islands pattern can be as fancy or rudimentary as desired. they can bootstrap themselves via async endpoints, they can be shipped as web components even, or they can be static, pre-hydrated in some manner.

Re: Modern CSS Code Snippets: Stop writing CSS like it's 2015

#38
post #30

Earlier quoted context omitted.

Wait until you see React & JSX... At least html and CSS are both presentation. React/JSX now confuses presentation and business logic.

React is great for MVVM indeed. Who is still using MVC in 2026?

MVVM was invented by Microsoft for 2-way syncing in WPF. Today we know 2-way syncing is a mistake.

Who uses MVC in 2026? Pretty much every framework out there, including Java frameworks and Python frameworks and .net

Re: Modern CSS Code Snippets: Stop writing CSS like it's 2015

#39
post #37
post #32

Earlier quoted context omitted.

If you move the data (the M and the C) entirely out of react, and only pass it in via props, there would be only one place — the root react node — where the props could get into react. Is this what you have in mind? Or are you envisioning multiple root nodes?

Well, i've always been a fan of the island architecture that effectively mounts root nodes as little islands of isolated state, yes. Mainly this avoids the hell that global state SPA patterns produce: redux, reducer patterns in general, and 8 thousand context providers. I do think there's use cases that warrant global in-memory state, but it's such a pain in the ass to maintain and evolve, i'd always plan against it.…

The islands pattern is underrated for maintainability. I've found the biggest win isn't even the state isolation — it's that each island can have a completely independent upgrade path. You can rewrite one island from React to vanilla JS (or whatever comes next) without touching anything else.

The global state SPA pattern fails for a more fundamental reason than just being painful to maintain: it creates an implicit contract between every component in the app. Change one reducer and you're debugging side effects three layers away. Islands make the contract explicit — each one owns its data, full stop.

The one gotcha I've hit is cross-island communication. PostMessage works but gets messy. Custom events on a shared DOM ancestor end up being the cleanest pattern for the rare cases where islands genuinely need to coordinate.

Post reply on HN