@ts-kit/lit-framework
Version:
Framework arouhd Lit-Html
48 lines (36 loc) • 1.17 kB
Markdown
# lit-framework
A small frameworking for building web components using lit-html
Goals
* [X] Small (~7k for todo app)
* [X] uses standards (custom elements and shadow dom)
* [X] component template can ONLY be updated by calling set state. no exceptions
* [X] Uses dependency Injection
* [X] Component and Custom Element are Separate. (Your should be able to test component code without creating the custom element)
#### Installation:
```BASH
npm i -kit/lit-framework -kit/di lit-html
```
#### Example:
```TS
import { Component, State, ComponentState, Handle } from '@ts-kit/lit-framework';
import { html } from 'lit-html';
<number>({
tag: 'hello-world',
defaultState: 0,
template(state, run) {
return html`
<button =${run('DECREMENT')}>Decrement</button>
${state}
<button =${run('INCREMENT')}>Increment</button>
`
}
})
class HelloWorldComponent {
constructor( private state: ComponentState<number>) {}
onIncrement() {
this.state.setState(state => state + 1);
}
onDecrement() {
this.state.setState(state => state - 1);
}
}