2026-03-04 11:13:15 -08:00
|
|
|
import { LitElement, html, css } from "lit";
|
2026-03-04 18:26:43 -08:00
|
|
|
import { store} from "../store/index.js";
|
|
|
|
|
import { StoreController } from "../controllers/store-controller.js";
|
2026-03-04 11:13:15 -08:00
|
|
|
import "./nav-bar.js";
|
|
|
|
|
import "./page-home.js";
|
|
|
|
|
import "./page-items.js";
|
2026-03-04 18:55:48 -08:00
|
|
|
import "./error-toast.js";
|
2026-03-04 11:13:15 -08:00
|
|
|
|
|
|
|
|
class AppRoot extends LitElement {
|
2026-03-04 18:26:43 -08:00
|
|
|
#hydrated = new StoreController(this, store, s => s._hydrated);
|
2026-03-04 11:13:15 -08:00
|
|
|
#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;
|
|
|
|
|
}
|
2026-03-04 18:26:43 -08:00
|
|
|
|
|
|
|
|
.loading {
|
|
|
|
|
display: grid;
|
|
|
|
|
place-items: center;
|
|
|
|
|
height: 100vh;
|
|
|
|
|
opacity: 0.4;
|
|
|
|
|
}
|
2026-03-04 11:13:15 -08:00
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
render() {
|
2026-03-04 18:26:43 -08:00
|
|
|
if (!this.#hydrated.value) {
|
|
|
|
|
return html`<div class="loading">loading...</div>`;
|
|
|
|
|
}
|
2026-03-04 11:13:15 -08:00
|
|
|
return html`
|
2026-03-04 18:26:43 -08:00
|
|
|
<nav-bar .user=${this.#user.value}></nav-bar>
|
2026-03-04 11:13:15 -08:00
|
|
|
<main>${this.#renderRoute()}</main>
|
2026-03-04 18:55:48 -08:00
|
|
|
<error-toast></error-toast>
|
2026-03-04 11:13:15 -08:00
|
|
|
`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#renderRoute() {
|
2026-03-04 18:26:43 -08:00
|
|
|
switch (this.#route.value) {
|
|
|
|
|
case "home": return html`<page-home></page-home>`;
|
|
|
|
|
case "items": return html`<page-items></page-items>`;
|
|
|
|
|
default: return html`<page-home></page-home>`;
|
2026-03-04 11:13:15 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
customElements.define('app-root', AppRoot);
|