From 492307530aa78d8f2e9ecd4c07cdaa3dbf426770 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sat, 13 Dec 2025 20:02:14 -0800 Subject: [PATCH] fix nav highlight for profile sub-routes --- src/lib/components/Navigation.svelte | 37 ++++++++++------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/src/lib/components/Navigation.svelte b/src/lib/components/Navigation.svelte index 06fb6965..9f612cd5 100644 --- a/src/lib/components/Navigation.svelte +++ b/src/lib/components/Navigation.svelte @@ -45,9 +45,6 @@ // Localized links const galleryHref = $derived(localizeHref('/teams/explore')) const guidesHref = $derived(localizeHref('/guides')) - const collectionHref = $derived( - username ? localizeHref(`/${username}/collection/characters`) : localizeHref('/collection') - ) const meHref = $derived(localizeHref('/me')) const loginHref = $derived(localizeHref('/auth/login')) const registerHref = $derived(localizeHref('/auth/register')) @@ -110,11 +107,6 @@ return path === href } - // For collection, check if we're on any collection page - if (href === collectionHref) { - return path.includes('/collection') - } - // Exact match or starts with href + / return path === href || path.startsWith(href + '/') } @@ -124,9 +116,13 @@ return $page.url.pathname === href || $page.url.pathname.startsWith(href + '/') } - // Check if the user profile link is selected + // Check if the user profile link is selected (includes sub-routes like /favorites, /collection) + const userProfilePath = $derived(localizeHref(`/${username}`)) const isProfileSelected = $derived( - isAuth && ($page.url.pathname === meHref || $page.url.pathname === localizeHref(`/${username}`)) + isAuth && + ($page.url.pathname === meHref || + $page.url.pathname === userProfilePath || + $page.url.pathname.startsWith(userProfilePath + '/')) ) // Settings modal state @@ -225,12 +221,10 @@ {m.nav_gallery()} {#if isAuth} - +
  • Guides
  • - {m.nav_collection()} + Crew
  • {#if !isAuth} - + Guides + + {/if} + {#if role !== null && role >= 7} - {m.nav_collection()} + Database {/if} {#if isAuth} - - Crew - - {#if role !== null && role >= 7} - - Database - - {/if} {#if isAuth}