wcb/demo/HelloWorld.mjs
2023-11-19 18:25:49 +01:00

19 lines
484 B
JavaScript

// @ts-check
import WebComponent from "../src/WebComponent.js";
export class HelloWorld extends WebComponent {
static properties = ["my-name", "emotion"];
onInit() {
let count = 0;
this.onclick = () => (this.props.myName = `Clicked ${++count}`);
}
get template() {
return `<button id="btn">Hello ${this.props.myName ?? "World"}${
this.props.emotion === "sad" ? ". 😭" : "! 🙌"
}</button>`;
}
}
customElements.define("hello-world", HelloWorld);