@chasemoskal/magical
Version:
web toolkit for lit apps
32 lines (23 loc) • 683 B
text/typescript
import {html} from "lit"
import {property} from "lit/decorators.js"
import {mixinCss} from "../../mixins/css.js"
import {MagicElement} from "../../element.js"
import counterStylesCss from "../styles/counter-styles.css.js"
(counterStylesCss)
export class CounterElement extends MagicElement {
({type: Number})
start = 0
realize() {
const {use} = this
const [count, setCount] = use.state(this.start)
const increment = () => setCount(count + 1)
const reset = () => setCount(this.start)
return html`
<div>
<p>count ${count}</p>
<button @click=${increment}>increment</button>
<button @click=${reset}>reset</button>
</div>
`
}
}