|
| 1 | +"use client"; |
| 2 | + |
| 3 | +import Link from 'next/link'; |
| 4 | +import { usePathname } from 'next/navigation'; |
| 5 | +import { cn } from '@/lib/utils'; |
| 6 | +import { |
| 7 | + LayoutDashboard, |
| 8 | + Link as LinkIcon, |
| 9 | + ListOrdered, |
| 10 | + Wallet, |
| 11 | + Settings |
| 12 | +} from 'lucide-react'; |
| 13 | + |
| 14 | +const mobileNavItems = [ |
| 15 | + { href: '/dashboard', label: 'Overview', icon: LayoutDashboard }, |
| 16 | + { href: '/payments', label: 'Payments', icon: LinkIcon }, |
| 17 | + { href: '/transactions', label: 'History', icon: ListOrdered }, |
| 18 | + { href: '/wallet', label: 'Wallet', icon: Wallet }, |
| 19 | + { href: '/settings', label: 'Settings', icon: Settings }, |
| 20 | +]; |
| 21 | + |
| 22 | +export const MobileBottomNav = () => { |
| 23 | + const pathname = usePathname(); |
| 24 | + |
| 25 | + return ( |
| 26 | + <div className="fixed bottom-0 md:hidden left-0 right-0 z-40 bg-white border-t border-slate-200 px-2 pt-2 pb-safe sm:pb-3 flex items-center justify-around shadow-[0_-4px_10px_rgba(0,0,0,0.02)]"> |
| 27 | + {mobileNavItems.map((item) => { |
| 28 | + const isActive = pathname === item.href || pathname.startsWith(item.href + '/'); |
| 29 | + const Icon = item.icon; |
| 30 | + |
| 31 | + return ( |
| 32 | + <Link |
| 33 | + key={item.href} |
| 34 | + href={item.href} |
| 35 | + className={cn( |
| 36 | + "flex flex-col items-center justify-center w-[68px] gap-1 py-1.5 rounded-lg transition-all", |
| 37 | + isActive |
| 38 | + ? "text-amber-700 bg-amber-50" |
| 39 | + : "text-slate-500 hover:bg-slate-50 hover:text-slate-800" |
| 40 | + )} |
| 41 | + > |
| 42 | + <Icon className={cn("w-5 h-5", isActive ? "text-amber-600" : "text-slate-400")} /> |
| 43 | + <span className="text-[10px] font-medium tracking-tight">{item.label}</span> |
| 44 | + </Link> |
| 45 | + ); |
| 46 | + })} |
| 47 | + </div> |
| 48 | + ); |
| 49 | +}; |
0 commit comments