ViteJS, lit-html, haunted, optionally with SAP UI5 or Vaadin or any other (Shoelace) web components experimental project (Sylla)
ViteJS, lit-html, haunted, optionally with SAP UI5 web components experimental project (Sylla)
After cloning npm install and then npm run dev.
Check out the live application on Azure
feat(initial): Implement Haunted Counter web component sample
Haunted was written in TypeScript
Project initialization Steps:
Just watch the video, how simple it is to use haunted, if you are familiar with the concepts of web components aka custom elements and reactive hooks popularized by React.
Also not how much cleaner this style is va react.
Everything is standard: JavaScript standard template (back-tick) literals vs JSX and web components vs React’s own proprietary component machinery.
Also check out how amazingly simple is ViteJs to setup a project vs create-react-app.
Also a number of excellent production ready web component libraries are available you can start using right away: SAP UI5 web components, Vaadin Fusion (based on Lit Element), Shoelace (based on Lit Element), Microsoft @fluentui/web-components (based on Microsoft Fast). In theory even IONIC (based on Stencil, but Stencil uses JSX for templating) could be used, too, since a webcomponent is a native custom element that the browsers support, no need to polyfill in practice today.
Keep in mind that lit-html can be used with regular HTML, not only with web components. By coincidence the same invented lit-html as well as Lit Element to pioneer web components.
So, with Haunted you have the functonal hook programming paradigm, with Lit Element the classic TypeScript decorators-powered class component life-style.
A function component has private/local state only (useState), the only way it can communicate with the environment are
Class components (regular custom element implementations like Lit Element) can have properties that can be accessed bidirectionally, this way providing a traditional imperative (MVC/MVVM) programming paradigm, which is totally impossible with function components.
So, get prepared, if you have experience with Lit Element a number of patterns simply won’t work with Haunted components.
The values of HTML attributes even when defined for custom elements are always strings; so, always define the type of an attribute as string in the props interface. The type of properties can be anything but attributes should always be strings.
window.customElements.define("my-app", component<IAppProps>(App,{observedAttributes:["startpage"]}))