Live data from Hacker News

Progressive Web Components

arielsalminen.com

11–20 of 61 posts

Re: Progressive Web Components

#13
post #9

I like web components, the simpler the better, so I like what I see but having a strong OCD about syntax I just want to propose the use of It's just a matter of using a regex [1] and making your syntax more palatable Regardless, kudos for the release * const componentRegex = / )([^%] ?)%>/g;

HTML is case insensitive, so is the same as , and custom element names must have a hyphen.

Your component regex represents a JSX limitation, but web components do not need React. Plus, if you capitalize the first letter, JSX would treat it as a React component rather than a web component (i.e. custom native HTML elements)

Re: Progressive Web Components

#14
Web Components are great for doing multi-pass rendering with template placeholder substitution happening at multiple levels in the component hierarchy. The entire element HTML hierarchy can be declared in one place. It's extremely versatile.

React cannot do this. It's difficult to explain without writing a whole essay but the benefits are very clear once you try this approach.

Re: Progressive Web Components

#15

The HTML + CSS first approach and JS only for enrichment sounds great, and like what should be done anyway. I wonder though, how it will play out in reality. Will web developers using this library make the effort to keep essential functionality JS free, if possible, and provide additional views using whatever web framework they use, or will they implement essential functionality as "JS enrichment", requiring JS for t…

In reality, building anything complex is a huge pain using web components, particularly because it is hard to author them with appropriate level of styling API and accessibility support. In my experience, web components are fantastic for consumers but terrible for the authors. Still, the advantages are clear: they don’t need any special runtime and can be used with other JS frameworks. Another thing in favor of web c…

Try keeping them in the light dom.

Everything works like normal html + css, but you get all the benefits of reusability and encapsulated script logic.

Lit-html (the library, not the framework) gives this approach super rendering speed too.

Re: Progressive Web Components

#16
post #9

I like web components, the simpler the better, so I like what I see but having a strong OCD about syntax I just want to propose the use of It's just a matter of using a regex [1] and making your syntax more palatable Regardless, kudos for the release * const componentRegex = / )([^%] ?)%>/g;

I don't understand your proposal

Customer elements MUST have an hyphen.

is the same as in HTML

Re: Progressive Web Components

#17
I think it's better to think of "Web components" as "Custom Elements" they really aren't components in the way you think of components in other frameworks (which on the web introduced them first), and I think most of the dissatisfaction with them comes from trying pretend they're an alternative as they just aren't. Components in almost every other framework are efficient (efficient rendering runtime) and expressive (the ability not to have a root element but instead a frag, or context APIs etc) in ways that web components never will be, which makes them unappealing.

But when you think of them as a suite of APIs to define custom elements, that can coexist with your framework components, this delimma goes away.

I do think it's a-shame that modern frameworks don't better support shadow dom and local styles, and local events. Understandably I also get why they also don't see that as a good use of their time either, it adds complexity to the runtimes, they need to observe events at multiple root nodes.

Besides the cost of implementation and commitment to additional complexity, assuming that was a nonissue, with the exception of those otherwise legitimate reasons, there's no technical limitation that prevents React from supporting shadow roots for arbitrary custom element. I made a proof of concept of this myself seems to work quite nicely with a stylesheet loader hook (which ensured it was loaded once and there was a shared sheet between all instances of the same element), but I had to start observing events in each elements shadow root.

Re: Progressive Web Components

#20
Anyone doing anything interesting to use CSS libs like Bulma, Bootstrap with web components? Definitely feels like swimming against the tide. Got a hobby project in Lit.js, can't easily wrap (e.g.) `.btn` in a component without breaking styles because the component root/host ends up between `.btn-group` and `.btn`. One can manually add classes to the root/host but that only gets you so far. Ideally I could select when to render a root and I vaguely remember that Lit allows this but I don't remember figuring this one out.
Post reply on HN