| ▲ | Building optimistic UI in Rails (and learn custom elements)(railsdesigner.com) |
| 71 points by amalinovic 9 hours ago | 10 comments |
| |
|
| ▲ | dmix an hour ago | parent | next [-] |
| I appreciate how the author compares it to writing Stimulus components and it sounds like there's little real benefit for the day-to-day dev, unless you're doing something fancy and highly reusable in JS. |
|
| ▲ | bdcravens 4 hours ago | parent | prev | next [-] |
| This is actually a very nice primer on how to build custom elements even if you don't use Rails. |
|
| ▲ | usernamed7 7 hours ago | parent | prev | next [-] |
| FWIW you don't even need to define custom elements to use them: https://html3000.dev/ |
| |
| ▲ | lazylester 3 hours ago | parent | next [-] | | imho the vaunted readability of custom elements has long been available with haml, with added readability by virtue of the indentation rules replacing closing tags. Not sure why it didn't really gain much traction, maybe the pre-processing is problematic when there's no server-side framework like Rails? | | |
| ▲ | dmix an hour ago | parent [-] | | Either everyone uses HAML or no one does IMO. Developers like to copy/paste UI component example HTML from Tailwind/Bootstrap documentation, they like predictability/portability. They don't want a project that's half HTML and half HAML...ie, Vue/React using HTML/JSX vs 50% of Rails views in HAML, 50% old ones in HTML. Just like how using Vanilla JS is much smoother and reliable than using the latest wrapper framework. |
| |
| ▲ | yoz-y 5 hours ago | parent | prev | next [-] | | This website violates the rule that all custom elements must have a dash in the tag name. | | |
| ▲ | rsstack 4 hours ago | parent [-] | | https://html.spec.whatwg.org/multipage/custom-elements.html#... > This is used for namespacing and to ensure forward compatibility (since no elements will be added to HTML, SVG, or MathML with hyphen-containing local names going forward). So things that work today without a dash might break in the future if <badge>, for example, becomes a standard HTML element. | | |
| ▲ | yoz-y 3 minutes ago | parent [-] | | Indeed. And since a lot of web is fire and forget, one day you might get a surprise. |
|
| |
| ▲ | cgarvis 7 hours ago | parent | prev [-] | | never knew you could do css selectors on custom elements! does seem like syntactical sugar over classes. I do like the current trend with tailwind: style with markup using smaller components. But maybe there is something here with so many components being just styles... |
|
|
| ▲ | phoronixrly 4 hours ago | parent | prev [-] |
| Great article, however using raw custom elements goes IMO against Rails' spirit, as it is way too low level, and requires lots of boilerplate to get working. Stimulus is in the sweet spot for that. Both lean (as opposed to bloated), and not too low level, so that using it does not lead to verbose code. It is one of the very few JS frameworks that IMO do not contribute to JS proliferation, but actually work to reduce the amount of JS written. |