UNPKG

@polight/lego

Version:

Tiny Web-Components lib for future-proof HTML mentors

30 lines (20 loc) 545 B
// Lego version 1.9.0 import { h, Component } from '/dist/lego.js' class Lego extends Component { get vdom() { return ({ state }) => [ h("button", {"onclick": this.increment.bind(this)}, `Increment!`), h("p", {}, `Count: ${state.count}`), h("input", {"value": state.count}, "")] } } import store from "./store.js" export default class extends Lego { useShadowDOM = false init() { store.subscribe(this, ["count"]) } increment(method) { this.render({ count: this.state.count + 1 }) } }