Files
gruperly/apps/web/src/components/layout/BottomNav.tsx
2026-09-29 09:19:29 -03:00

41 lines
1.5 KiB
TypeScript

import { Link, useLocation } from '@tanstack/react-router'
import { cn } from '../../lib/utils'
import { isNavItemActive, NAV_ITEMS } from './nav-items'
export function BottomNav() {
const location = useLocation()
return (
<nav className="fixed inset-x-0 bottom-0 z-40 border-t border-border bg-surface/95 pb-[env(safe-area-inset-bottom)] backdrop-blur lg:hidden">
<div className="mx-auto grid max-w-md grid-cols-4">
{NAV_ITEMS.map(({ label, to, icon: Icon }) => {
const isActive = isNavItemActive(location.pathname, to)
return (
<Link
key={to}
to={to}
aria-current={isActive ? 'page' : undefined}
className={cn(
'flex min-h-14 flex-col items-center justify-center gap-1 py-2 text-[11px] font-medium transition-colors',
isActive ? 'text-accent-fg' : 'text-foreground/80 hover:text-primary',
)}
>
{/* Pastilla suave detrás del ícono: el estado activo se lee por
color + fondo, no solo por el tono del texto. */}
<span
className={cn(
'flex size-8 items-center justify-center rounded-lg transition-colors duration-150',
isActive && 'bg-accent-soft',
)}
>
<Icon className="size-5" strokeWidth={isActive ? 2.25 : 2} />
</span>
<span className="leading-none">{label}</span>
</Link>
)
})}
</div>
</nav>
)
}