From 734c5a498aa450ce3092b7a8276a3803d9b1dfb5 Mon Sep 17 00:00:00 2001 From: Bashar Alhato Date: Fri, 4 Apr 2025 08:25:07 +0200 Subject: [PATCH] Fix active links --- resources/js/components/AppHeader.vue | 37 +++++++++++++++----------- resources/js/components/AppSidebar.vue | 5 +++- resources/js/components/NavMain.vue | 5 ++-- resources/js/types/index.d.ts | 2 ++ 4 files changed, 30 insertions(+), 19 deletions(-) diff --git a/resources/js/components/AppHeader.vue b/resources/js/components/AppHeader.vue index 84902b2e..ab71a079 100644 --- a/resources/js/components/AppHeader.vue +++ b/resources/js/components/AppHeader.vue @@ -32,29 +32,33 @@ const props = withDefaults(defineProps(), { const page = usePage(); const auth = computed(() => page.props.auth); -const isCurrentRoute = computed(() => (url: string) => page.url === url); +const isCurrentRoute = computed(() => (component: string) => page.component === component); const activeItemStyles = computed( - () => (url: string) => (isCurrentRoute.value(url) ? 'text-neutral-900 dark:bg-neutral-800 dark:text-neutral-100' : ''), + () => (component: string) => (isCurrentRoute.value(component) ? 'text-neutral-900 dark:bg-neutral-800 dark:text-neutral-100' : ''), ); const mainNavItems: NavItem[] = [ { title: 'Dashboard', href: '/dashboard', + component: 'Dashboard', icon: LayoutGrid, - }, + // when: !!auth.value.user, // to show/hide when on a condition + } ]; const rightNavItems: NavItem[] = [ { title: 'Repository', href: 'https://github.com/laravel/vue-starter-kit', + component: null, icon: Folder, }, { title: 'Documentation', href: 'https://laravel.com/docs/starter-kits', + component: null, icon: BookOpen, }, ]; @@ -79,16 +83,17 @@ const rightNavItems: NavItem[] = [