From b25340644bb23d5b959e92ff6586a18912a87819 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 30 Apr 2026 19:10:17 +0200 Subject: [PATCH] refactor(nav): Today tab shortcut to week view; delete /today route MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Today nav link targets /week?week=&day= - Today tab active: route=/week AND ?day===todayKey() (not just pathname) - Week tab active: route=/week AND today tab not active - Root / redirect updated from /today to /week?week=…&day=… - /today route hard-deleted (src/routes/today/ removed) - +layout.svelte imports todayKey/currentWeekKey for link generation --- web/src/routes/+layout.svelte | 27 ++++++++++++++++++--------- web/src/routes/+page.svelte | 3 ++- web/src/routes/today/+page.svelte | 19 ------------------- 3 files changed, 20 insertions(+), 29 deletions(-) delete mode 100644 web/src/routes/today/+page.svelte diff --git a/web/src/routes/+layout.svelte b/web/src/routes/+layout.svelte index 590fa4f..1da3837 100644 --- a/web/src/routes/+layout.svelte +++ b/web/src/routes/+layout.svelte @@ -4,6 +4,7 @@ import { onMount, onDestroy } from 'svelte'; import { goto } from '$app/navigation'; import { startSync, stopSync } from '$lib/stores/sync'; + import { todayKey, currentWeekKey } from '$lib/utils'; let { children } = $props(); @@ -16,18 +17,26 @@ onDestroy(stopSync); - const navItems = [ - { href: '/today', label: 'Today' }, - { href: '/week', label: 'Week' }, - { href: '/history', label: 'History' }, - { href: '/settings', label: 'Settings' } - ]; + function todayHref(): string { + return `/week?week=${currentWeekKey()}&day=${todayKey()}`; + } + + // "Today" tab is active when on /week with ?day === todayKey(). + const todayActive = $derived( + page.url.pathname === '/week' && + page.url.searchParams.get('day') === todayKey() + ); + + const weekActive = $derived( + page.url.pathname === '/week' && !todayActive + );
diff --git a/web/src/routes/+page.svelte b/web/src/routes/+page.svelte index 9899104..c083b53 100644 --- a/web/src/routes/+page.svelte +++ b/web/src/routes/+page.svelte @@ -1,5 +1,6 @@ diff --git a/web/src/routes/today/+page.svelte b/web/src/routes/today/+page.svelte deleted file mode 100644 index 80e77e0..0000000 --- a/web/src/routes/today/+page.svelte +++ /dev/null @@ -1,19 +0,0 @@ - - -
-

Today — {today}

- -
- -