-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnav-main.tsx
65 lines (61 loc) · 1.67 KB
/
nav-main.tsx
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
"use client"
import { MoreHorizontal, type LucideIcon } from "lucide-react"
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu"
import {
SidebarGroup,
SidebarMenu,
SidebarMenuButton,
SidebarMenuItem,
useSidebar,
} from "@/components/ui/sidebar"
export function NavMain({
items,
}: {
items: {
title: string
url: string
icon?: LucideIcon
isActive?: boolean
items?: {
title: string
url: string
}[]
}[]
}) {
const { isMobile } = useSidebar()
return (
<SidebarGroup>
<SidebarMenu>
{items.map((item) => (
<DropdownMenu key={item.title}>
<SidebarMenuItem>
<DropdownMenuTrigger asChild>
<SidebarMenuButton className="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground">
{item.title} <MoreHorizontal className="ml-auto" />
</SidebarMenuButton>
</DropdownMenuTrigger>
{item.items?.length ? (
<DropdownMenuContent
side={isMobile ? "bottom" : "right"}
align={isMobile ? "end" : "start"}
className="min-w-56 rounded-lg"
>
{item.items.map((item) => (
<DropdownMenuItem asChild key={item.title}>
<a href={item.url}>{item.title}</a>
</DropdownMenuItem>
))}
</DropdownMenuContent>
) : null}
</SidebarMenuItem>
</DropdownMenu>
))}
</SidebarMenu>
</SidebarGroup>
)
}