News for hackers. Stuff that matters.
Re:Show HN: Minimalist Web Components for your static website by nojvek on Sunday March 21, 2021 @12:53AM (#26528212)
The hard part about webcomponents is templating. React paved the way for view = fn(state). Vue followed suite with virtual dom too and so does angular now.

There are micro libs like snabbdom that get you that.

However in my 4 years of building complex webcomponents , the missing pieces are a same way to do templating and a sane way to declare attribute schema

Webcomponents assume all attributes are strings, but you deffo end up needing to parse numbers, Booleans and objects from it.

Re:Show HN: Minimalist Web Components for your static website by passle on Sunday March 21, 2021 @04:33AM (#26528991)
If you've been building complex web components for 4 years, hopefully by now you've realized you can actually pass _properties_ down to custom elements.
Re:Show HN: Minimalist Web Components for your static website by nojvek on Friday March 26, 2021 @04:52PM (#26596799)
Yep, but now you have two ways of doing a thing. With attributes you have attributeChangedCallback, with props you have set prop functions.

Attributes show up nice in dom explorer and make it easy to debug, props don’t.

I could go deep into this, when you bring typescript into the equation for large apps, there are all sorts of tradeoffs to keep in mind.

Re:Show HN: Minimalist Web Components for your static website by linkdd on Sunday March 21, 2021 @08:40AM (#26529976)
Well, in our case, the templating is done with Hugo in partials. We just needed the interactivity.
Re:Show HN: Minimalist Web Components for your static website by linkdd on Saturday March 20, 2021 @07:23PM (#26526823)
We needed some interactivity within our Hugo websites, and those 12 lines of code (360 bytes) were being copy-pasted in all our projects.

It is released in the public domain, because there is no value in keeping it to us.