News for hackers. Stuff that matters.
Re:Nue: A React/Vue/Vite/Astro Alternative by zarzavat on Friday September 15, 2023 @04:18AM (#37520040)
Thank for for sticking up for external stylesheets.

When I was starting out with HTML, inline styles were considered to be a hack, and the goal of writing good HTML was to separate the data from the presentation as completely as possible. It seems that nowadays people place more emphasis on encapsulation rather than separation, they want their style to live with the component. Separation and encapsulation are in opposition: vertical vs horizontal architecture of code.

Personally I prefer separation. While components are a good way to divide up functionality, when it comes to presentation users are perceiving the UI of your entire website, not the individual UIs of each component. Separating the style into a stylesheet gives you global control over presentation and makes you more aligned with how the user is perceiving things.

Re:Nue: A React/Vue/Vite/Astro Alternative by shrimpx on Friday September 15, 2023 @05:33AM (#37520501)
Separation also has drawbacks. You have to go to open a different file and search for things by ID or class name. It’s like aspect oriented programming.
Re:Nue: A React/Vue/Vite/Astro Alternative by niutech on Friday September 15, 2023 @05:41AM (#37520563)
In almost every IDE you can open two files in a split view and you can ctrl-click on an ID to go to the definition.
Re:Nue: A React/Vue/Vite/Astro Alternative by Kiro on Friday September 15, 2023 @06:12AM (#37520800)
That's not good enough. I want to look at a tag and immediately see how it's styled. No cascading or hidden/indirect styling. It should be all there, completely isolated from the rest. In fact, I should be able to copy/paste just the HTML (or component) into a completely different application and it should remain exactly the same.
Re:Nue: A React/Vue/Vite/Astro Alternative by jacobsimon on Friday September 15, 2023 @05:45AM (#37520584)
This is a really good observation. If I can add on, I feel like a lot of the disagreements in modern front end development boil down to this: Some people actually like developing with HTML/CSS, and other people see it as an implementation detail and would rather abstract it away with JavaScript.

People in the first camp tend to like Vue, CSS/Sass, Htmx, server rendering, etc.

People in the second camp like React and React Native, CSS-in-JS, Tailwind, etc.

Re:Nue: A React/Vue/Vite/Astro Alternative by moritzwarhier on Friday September 15, 2023 @05:54AM (#37520675)
I don't agree with that separation. I feel that e.g. Tailwind appeals a lot to developers of templates for e.g. Laravel.

And I like to be an expert in HTML+CSS (at least I try), and still prefer JSX to e.g. Vue's template syntax.

Re:Nue: A React/Vue/Vite/Astro Alternative by jokethrowaway on Friday September 15, 2023 @05:22PM (#37529289)
It's a tradeoff, prototyping speed vs maintenance

prototype (or throwaway code you don't care about)? JS and tailwind something you have to maintain? TS and external stylesheet

Re:Nue: A React/Vue/Vite/Astro Alternative by tipiirai on Friday September 15, 2023 @12:49PM (#37525901)
Seems legit observation to me
Re:Nue: A React/Vue/Vite/Astro Alternative by seanwilson on Friday September 15, 2023 @08:27AM (#37521937)
> Separating the style into a stylesheet gives you global control over presentation

It doesn't though unless you're mostly dealing with traditional documents.

Most non-trivial styling requires you to edit the HTML as well because CSS alone isn't powerful enough e.g.

- you need to add tags to content you want to style only for presentation reasons

- to layout/align content it's often much easier or the only choice to reorganise the HTML

- lots of CSS problems require you to add extra tags because the styling you want to do cannot be done or isn't possible with a single tag.

I know about the Zen Garden demo, but this approach hasn't panned out in practice. Every website redesign I've ever seen involved large changes to the HTML, and it's not from lack of developer skill.

Re:Nue: A React/Vue/Vite/Astro Alternative by incrudible on Friday September 15, 2023 @08:02PM (#37530550)
> Separating the style into a stylesheet gives you global control over presentation and makes you more aligned with how the user is perceiving things.

This only works for trivial stuff. Presentation is more than just colors, fonts and margins. Layout is deeply intertwined with the structure your HTML, attempts at mitigating this have made a monumental mess of CSS. The sooner you recognize it as the pipe dream that it is, the more time you will have to work on your actual goal.

I also feel the opposite about what the user perceives. The user perceives the result of applying all your CSS rules - which is closer to inline styles everywhere rather than separating things out.

Re:Nue: A React/Vue/Vite/Astro Alternative by sonnhy on Sunday September 17, 2023 @05:22AM (#37543107)
> Separating the style into a stylesheet gives you global control over presentation and makes you more aligned with how the user is perceiving things.

Can you elaborate on this? Do you mean that the separation through external stylesheets creates a more cohesive UI for the user?

The HTML has its say on layout part, so the presentation is not exclusively on the CSS. Also, the core part of defining the whole UI is usually delegated to some global CSS rules, usually known as the theme in CSS-in-JS libraries. I don't think having external stylesheet helps that much.