fixed a few bugs, fleshed out a few cornerstones
This commit is contained in:
parent
b54c89c9c4
commit
4e612cb224
4 changed files with 22 additions and 5 deletions
|
|
@ -40,7 +40,7 @@ class NavBar extends LitElement {
|
||||||
|
|
||||||
#link(route, label) {
|
#link(route, label) {
|
||||||
return html`
|
return html`
|
||||||
|
<a
|
||||||
href="/${route}"
|
href="/${route}"
|
||||||
?active=${this.#route.value === route}
|
?active=${this.#route.value === route}
|
||||||
@click=${(e) => this.#navigate(route, e)}
|
@click=${(e) => this.#navigate(route, e)}
|
||||||
|
|
|
||||||
14
index.html
14
index.html
|
|
@ -4,8 +4,18 @@
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Document</title>
|
<title>Document</title>
|
||||||
<script type="importmap" src="importmap.json"></script>
|
<script type="importmap">
|
||||||
<script src="https://ga.jspm.io/npm:es-module-shims@1.10.0/dist/es-module-shims.js"></script>
|
{
|
||||||
|
"imports": {
|
||||||
|
"lit": "https://esm.sh/lit@3",
|
||||||
|
"lit/decorators.js": "https://esm.sh/lit@3/decorators.js",
|
||||||
|
"zustand/vanilla": "https://esm.sh/zustand@5/vanilla",
|
||||||
|
"zustand/middleware": "https://esm.sh/zustand@5/middleware",
|
||||||
|
"idb-keyval": "https://esm.sh/idb-keyval@6"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<script async src="https://ga.jspm.io/npm:es-module-shims@1.10.0/dist/es-module-shims.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<script type="module" src="components/app-root.js"></script>
|
<script type="module" src="components/app-root.js"></script>
|
||||||
|
|
|
||||||
|
|
@ -5,14 +5,21 @@ import { idbStorage } from './middleware/persistence.js'
|
||||||
export const store = createStore(
|
export const store = createStore(
|
||||||
persist(
|
persist(
|
||||||
(set, get) => ({
|
(set, get) => ({
|
||||||
|
_hydrated: false,
|
||||||
user: null,
|
user: null,
|
||||||
items: [],
|
items: [],
|
||||||
|
route: 'home',
|
||||||
setUser: (user) => set({ user }),
|
setUser: (user) => set({ user }),
|
||||||
addItem: (item) => set(s => ({ items: [...s.items, item] })),
|
addItem: (item) => set(s => ({ items: [...s.items, item] })),
|
||||||
|
removeItem: (id) => set(s => ({ items: s.items.filter(i => i.id !== id) })),
|
||||||
|
navigate: (route) => set({ route }),
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
name: 'app-store',
|
name: 'app-store',
|
||||||
storage: idbStorage, // custom adapter (see below)
|
storage: idbStorage,
|
||||||
|
onRehydrateStorage: () => (state) => {
|
||||||
|
if (state) state._hydrated = true
|
||||||
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue