|
|
|
|
|
by wildrhythms
1694 days ago
|
|
Think about it in terms of components. // Left container
<MyHeading /> // Right container
<MyHeading /> What's the point of a .MyHeading class in this instance? Why are you spending so much time naming things solely to reference them in a separate file? In my Tailwind projects I can have an entire components/ directory with just .jsx files. No more having to spend time naming one-off elements, or cross-referencing class names with separate definitions in separate files. |
|
Doesn't this make them untargetable if you ever use it somewhere else? Plus, it already has a CSS name: whatever you named the component (and therefore its folder).
UI code should be modular, component-based, and lends itself to being logically grouped into single folders or files:
MyComponent ->index.tsx ->style.css
Or for vue just MyComponent, etc.
Now, this component has all the abilities that we tap into these frameworks for in the first place: it's composable, it's targetable by a known & unique name, we can use it anywhere without restriction.
I don't even want to imagine a world where I render some component and it has no targetable name... Terrible for reuse