From 30f21ee78eab576224b0ca0829628b464b5a9aa3 Mon Sep 17 00:00:00 2001 From: Your Actual Name Date: Mon, 23 Mar 2026 22:53:11 +0100 Subject: [PATCH] feat(nav): standardize nav pill style and active state --- components/navbar.tsx | 88 ++++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 43 deletions(-) diff --git a/components/navbar.tsx b/components/navbar.tsx index fbd01dc..9a18dd6 100644 --- a/components/navbar.tsx +++ b/components/navbar.tsx @@ -1,6 +1,7 @@ 'use client' import { useState, useRef } from 'react' +import { usePathname } from 'next/navigation' import { motion } from 'framer-motion' import { Menu, X, ArrowRight } from 'lucide-react' import Link from 'next/link' @@ -9,14 +10,17 @@ import { ThemeToggle } from '@/components/theme-toggle' import { ConnectButton } from '@/components/Wallet' const navItems = [ - { label: 'Features', href: '#features' }, - { label: 'How it Works', href: '#how-it-works' }, + { label: 'Dashboard', href: '/dashboard' }, + { label: 'Transactions', href: '/dashboard/transactions' }, + { label: 'Wallets', href: '/dashboard/wallets' }, + { label: 'Settings', href: '/dashboard/settings' }, ] export function Navbar() { const [hoveredIndex, setHoveredIndex] = useState(null) const [mobileMenuOpen, setMobileMenuOpen] = useState(false) const navRef = useRef(null) + const pathname = usePathname() return ( - {navItems.map((item, index) => ( - setHoveredIndex(index)} - onMouseLeave={() => setHoveredIndex(null)} - > - {hoveredIndex === index && ( - - )} - {item.label} - - ))} - - Onramp - - - Offramp - + {navItems.map((item, index) => { + const isActive = pathname === item.href || (item.href !== '/' && pathname.startsWith(item.href)) + return ( + setHoveredIndex(index)} + onMouseLeave={() => setHoveredIndex(null)} + > + {hoveredIndex === index && !isActive && ( + + )} + {item.label} + + ) + })} {/* Right side: Theme Toggle and Connect Button */} @@ -96,16 +93,21 @@ export function Navbar() { className="absolute top-full left-0 right-0 mt-2 p-4 rounded-2xl bg-card/95 backdrop-blur-md border border-border shadow-lg" >
- {navItems.map((item) => ( - setMobileMenuOpen(false)} - > - {item.label} - - ))} + {navItems.map((item) => { + const isActive = pathname === item.href || (item.href !== '/' && pathname.startsWith(item.href)) + return ( + setMobileMenuOpen(false)} + > + {item.label} + + ) + })}