54 lines
1.5 KiB
TypeScript
54 lines
1.5 KiB
TypeScript
'use client'
|
|
|
|
import Link from 'next/link'
|
|
import { LogOut } from 'lucide-react'
|
|
import { isActivePath, type NavItem } from './nav-items'
|
|
import { cx } from '@/components/ui/cx'
|
|
|
|
export function MobileShell({
|
|
items,
|
|
pathname,
|
|
onLogout,
|
|
}: {
|
|
items: NavItem[]
|
|
pathname: string
|
|
onLogout: () => void
|
|
}) {
|
|
const tabs = items.slice(0, 4)
|
|
return (
|
|
<nav
|
|
aria-label="Mobile"
|
|
className="md:hidden fixed bottom-0 left-0 right-0 z-40 flex bg-surface border-t border-rule pb-[env(safe-area-inset-bottom)]"
|
|
>
|
|
{tabs.map(item => {
|
|
const active = isActivePath(item.href, pathname)
|
|
const Icon = item.icon
|
|
return (
|
|
<Link
|
|
key={item.href}
|
|
href={item.href}
|
|
aria-current={active ? 'page' : undefined}
|
|
className={cx(
|
|
'flex-1 flex flex-col items-center gap-1 pt-2 pb-1.5 text-[10.5px] font-medium',
|
|
active ? 'text-accent' : 'text-faint',
|
|
)}
|
|
>
|
|
<Icon size={22} strokeWidth={1.8} aria-hidden />
|
|
<span className="leading-none">{item.label}</span>
|
|
</Link>
|
|
)
|
|
})}
|
|
{items.length <= 4 && (
|
|
<button
|
|
type="button"
|
|
onClick={onLogout}
|
|
className="flex-1 flex flex-col items-center gap-1 pt-2 pb-1.5 text-[10.5px] font-medium text-faint cursor-pointer"
|
|
>
|
|
<LogOut size={22} strokeWidth={1.8} aria-hidden />
|
|
<span className="leading-none">Log out</span>
|
|
</button>
|
|
)}
|
|
</nav>
|
|
)
|
|
}
|