mirror of
https://github.com/shadcn-ui/taxonomy
synced 2026-05-24 09:48:32 +00:00
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
import * as React from "react"
|
|
import Link from "next/link"
|
|
|
|
import { MainNavItem } from "types"
|
|
import { cn } from "@/lib/utils"
|
|
import { useLockBody } from "@/hooks/use-lock-body"
|
|
import { Icons } from "./icons"
|
|
import { siteConfig } from "@/config/site"
|
|
|
|
interface MobileNavProps {
|
|
items: MainNavItem[]
|
|
children?: React.ReactNode
|
|
}
|
|
|
|
export function MobileNav({ items, children }: MobileNavProps) {
|
|
useLockBody()
|
|
|
|
return (
|
|
<div
|
|
className={cn(
|
|
"fixed inset-0 top-16 z-50 grid h-[calc(100vh-4rem)] grid-flow-row auto-rows-max overflow-auto p-6 pb-32 shadow-md animate-in slide-in-from-bottom-80 md:hidden"
|
|
)}
|
|
>
|
|
<div className="relative z-20 grid gap-6 rounded-md bg-white p-4 shadow-md">
|
|
<Link href="/" className="flex items-center space-x-2">
|
|
<Icons.logo />
|
|
<span className="font-bold">{siteConfig.name}</span>
|
|
</Link>
|
|
<nav className="grid grid-flow-row auto-rows-max text-sm">
|
|
{items.map((item, index) => (
|
|
<Link
|
|
key={index}
|
|
href={item.disabled ? "#" : item.href}
|
|
className={cn(
|
|
"flex w-full items-center rounded-md px-2 py-2 text-sm font-medium hover:underline",
|
|
item.disabled && "cursor-not-allowed opacity-60"
|
|
)}
|
|
>
|
|
{item.title}
|
|
</Link>
|
|
))}
|
|
</nav>
|
|
{children}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|