-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu.tsx
More file actions
109 lines (104 loc) · 3.71 KB
/
menu.tsx
File metadata and controls
109 lines (104 loc) · 3.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
"use client";
import Link from "next/link";
import * as React from "react";
import {
NavigationMenu,
NavigationMenuContent,
NavigationMenuItem,
NavigationMenuLink,
NavigationMenuList,
NavigationMenuTrigger,
navigationMenuTriggerStyle,
} from "@/components/ui/navigation-menu";
import { siteConfig } from "@/lib/config";
import { cn } from "@/lib/utils";
export default function NavigationMenuDemo() {
return (
<NavigationMenu>
<NavigationMenuList>
{siteConfig.header.map((item, index) => (
<NavigationMenuItem key={index}>
{item.trigger ? (
<>
<NavigationMenuTrigger>{item.trigger}</NavigationMenuTrigger>
<NavigationMenuContent>
<ul
className={`grid gap-3 p-6 ${item.content.main
? "md:w-[400px] lg:w-[500px] lg:grid-cols-[.75fr_1fr]"
: "w-[400px] md:w-[500px] md:grid-cols-2 lg:w-[600px]"
}`}
>
{item.content.main && (
<li className="row-span-3">
<NavigationMenuLink asChild>
<Link
className="flex h-full w-full select-none flex-col justify-end rounded-md bg-primary/10 from-muted/50 to-muted p-6 no-underline outline-none focus:shadow-md"
href={item.content.main.href}
>
{item.content.main.icon}
<div className="mb-2 mt-4 text-lg font-medium">
{item.content.main.title}
</div>
<p className="text-sm leading-tight text-muted-foreground">
{item.content.main.description}
</p>
</Link>
</NavigationMenuLink>
</li>
)}
{item.content.items?.map((subItem, subIndex) => (
<ListItem
key={subIndex}
href={subItem.href}
title={subItem.title}
className="hover:bg-primary/10"
>
{subItem.description}
</ListItem>
))}
</ul>
</NavigationMenuContent>
</>
) : (
<Link
href={item.href || ""}
target="_arya"
legacyBehavior
passHref
>
<NavigationMenuLink className={navigationMenuTriggerStyle()}>
{item.label}
</NavigationMenuLink>
</Link>
)}
</NavigationMenuItem>
))}
</NavigationMenuList>
</NavigationMenu>
);
}
const ListItem = React.forwardRef<
React.ElementRef<"a">,
React.ComponentPropsWithoutRef<"a">
>(({ className, title, children, ...props }, ref) => {
return (
<li>
<NavigationMenuLink asChild>
<a
ref={ref}
className={cn(
"block select-none space-y-1 rounded-md p-3 leading-none no-underline outline-none transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground",
className
)}
{...props}
>
<div className="text-sm font-medium leading-none">{title}</div>
<p className="line-clamp-2 text-sm leading-snug text-muted-foreground">
{children}
</p>
</a>
</NavigationMenuLink>
</li>
);
});
ListItem.displayName = "ListItem";