First working prototype

This commit is contained in:
2026-09-06 13:50:58 +02:00
parent ecf08f8307
commit f61b9025eb
44 changed files with 5118 additions and 905 deletions

29
src/lib/router.svelte.js Normal file
View File

@@ -0,0 +1,29 @@
/**
* Three screens, so no router dependency — just enough hash handling that the
* Android back button behaves inside an installed PWA.
*
* `route === null` means "wherever the day state says", which is the default the
* worker should land on.
*/
const ROUTES = ['resume', 'today', 'settings'];
function fromHash() {
const h = location.hash.replace(/^#\/?/, '');
return ROUTES.includes(h) ? h : null;
}
export const router = $state({ route: fromHash() });
window.addEventListener('hashchange', () => {
router.route = fromHash();
});
export function go(route) {
location.hash = route ? `#/${route}` : '';
}
export function back() {
if (history.length > 1) history.back();
else go(null);
}