import { LitElement, html, css } from "lit";
import "./nav-bar.js";
import "./page-home.js";
import "./page-items.js";
class AppRoot extends LitElement {
#user = new StoreController(this, store, s => s.user);
#route = new StoreController(this, store, s => s.route);
static styles = css`
:host {
display: block;
min-height: 100vh;
}
`;
#navigate(route) {
this.route = route;
}
#addItem(item) {
this.items = [...this.items, item];
}
#removeItem(id) {
this.items = this.items.filter(i => i.id !== id);
}
render() {
return html`
this.#navigate(e.detail.route)}
>
${this.#renderRoute()}
`;
}
#renderRoute() {
switch (this.route) {
case "home":
return html``;
case "items":
return html` this.#addItem(e.detail.item)}
@remove-item=${(e) => this.#removeItem(e.detail.id)}
>`;
default:
return html``;
}
}
}
customElements.define('app-root', AppRoot);