top | item 47027598

(no title)

lawn | 15 days ago

Is jumping between files supposed to be difficult or something?

discuss

order

chrisweekly|15 days ago

Colocation is a useful principle in component-based architecture.

temporallobe|15 days ago

As much hate as it gets, this is one thing I like about Angular.

apsurd|15 days ago

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.

afiori|15 days ago

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 <A type=1><B><A type=2></A></B></A> 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. With tailwind you mostly have to worry about inheritance

the_other|15 days ago

> Any selector with the " " operator on A risk expanding to the inner A even if it was intended only for the outer.

Then <a type=b> is potentially a <c>. Consider a small refactor?

robertoandred|15 days ago

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

mattacular|14 days ago

I find it to be more difficult. Especially if I can't pane the files in view comfortably (ie. beyond 2 or 3 it gets significantly harder to work across them).

Some frameworks or coding styles really lean into having lots of tiny files. That necessitates a more complicated directory structure for the project. Locating files eventually tends to requires search capability rather than being able to look through the tree in a sidebar.

None of this is "hard" per se but I find the opposite is nicer to work with typically.

onion2k|15 days ago

Yes.

The problem is that the styles for something can be defined in multiple places, and that makes it hard. Especially with CSS and (potentially) having specificity issues if things aren't managed well. Having them as a part of the component means that problem goes away.

ewuhic|15 days ago

Is staying in one file supposed to be difficult or something?

luckylion|15 days ago

this is grey text from tailwindcss.com, I wouldn't call it easy and readable.

<div class="relative before:absolute before:top-0 before:h-px before:w-[200vw] before:bg-gray-950/5 dark:before:bg-white/10 before:-left-[100vw] after:absolute after:bottom-0 after:h-px after:w-[200vw] after:bg-gray-950/5 dark:after:bg-white/10 after:-left-[100vw]"><p class="max-w-(--breakpoint-md) px-2 text-base/7 text-gray-600 max-sm:px-4 dark:text-gray-400">Because Tailwind is so low-level, it never encourages you to design the same site twice. Some of your favorite sites are built with Tailwind, and you probably had no idea.</p></div>

dbbk|15 days ago

You can literally command click a class to go into a styled components css file. I do not understand what the big issue is.

halfcat|15 days ago

Cognitive load of looking at 12 open files trying to understand what’s happening. Well, in fairness some of those 12 are the same file because we have one part for the default CSS and then one for the media query that’s 900 lines further down the file.

runarberg|15 days ago

Also modern CSS is often written in a <style> tag either in a native web component or in a framework which supports single file component like vue or svelte.