| 1 | import { ChevronRight, MoreHorizontal, Plus } from "lucide-react" |
| 2 | |
| 3 | import { |
| 4 | Collapsible, |
| 5 | CollapsibleContent, |
| 6 | CollapsibleTrigger, |
| 7 | } from "@/components/ui/collapsible" |
| 8 | import { |
| 9 | SidebarGroup, |
| 10 | SidebarGroupContent, |
| 11 | SidebarGroupLabel, |
| 12 | SidebarMenu, |
| 13 | SidebarMenuAction, |
| 14 | SidebarMenuButton, |
| 15 | SidebarMenuItem, |
| 16 | SidebarMenuSub, |
| 17 | SidebarMenuSubButton, |
| 18 | SidebarMenuSubItem, |
| 19 | } from "@/components/ui/sidebar" |
| 20 | |
| 21 | export function NavWorkspaces({ |
| 22 | workspaces, |
| 23 | }: { |
| 24 | workspaces: { |
| 25 | name: string |
| 26 | emoji: React.ReactNode |
| 27 | pages: { |
| 28 | name: string |
| 29 | emoji: React.ReactNode |
| 30 | }[] |
| 31 | }[] |
| 32 | }) { |
| 33 | return ( |
| 34 | <SidebarGroup> |
| 35 | <SidebarGroupLabel>Workspaces</SidebarGroupLabel> |
| 36 | <SidebarGroupContent> |
| 37 | <SidebarMenu> |
| 38 | {workspaces.map((workspace) => ( |
| 39 | <Collapsible key={workspace.name}> |
| 40 | <SidebarMenuItem> |
| 41 | <SidebarMenuButton asChild> |
| 42 | <a href="#"> |
| 43 | <span>{workspace.emoji}</span> |
| 44 | <span>{workspace.name}</span> |
| 45 | </a> |
| 46 | </SidebarMenuButton> |
| 47 | <CollapsibleTrigger asChild> |
| 48 | <SidebarMenuAction |
| 49 | className="bg-sidebar-accent text-sidebar-accent-foreground left-2 data-[state=open]:rotate-90" |
| 50 | showOnHover |
| 51 | > |
| 52 | <ChevronRight /> |
| 53 | </SidebarMenuAction> |
| 54 | </CollapsibleTrigger> |
| 55 | <SidebarMenuAction showOnHover> |
| 56 | <Plus /> |
| 57 | </SidebarMenuAction> |
| 58 | <CollapsibleContent> |
| 59 | <SidebarMenuSub> |
| 60 | {workspace.pages.map((page) => ( |
| 61 | <SidebarMenuSubItem key={page.name}> |
| 62 | <SidebarMenuSubButton asChild> |
| 63 | <a href="#"> |
| 64 | <span>{page.emoji}</span> |
| 65 | <span>{page.name}</span> |
| 66 | </a> |
| 67 | </SidebarMenuSubButton> |
| 68 | </SidebarMenuSubItem> |
| 69 | ))} |
| 70 | </SidebarMenuSub> |
| 71 | </CollapsibleContent> |
| 72 | </SidebarMenuItem> |
| 73 | </Collapsible> |
| 74 | ))} |
| 75 | <SidebarMenuItem> |
| 76 | <SidebarMenuButton className="text-sidebar-foreground/70"> |
| 77 | <MoreHorizontal /> |
| 78 | <span>More</span> |
| 79 | </SidebarMenuButton> |
| 80 | </SidebarMenuItem> |
| 81 | </SidebarMenu> |
| 82 | </SidebarGroupContent> |
| 83 | </SidebarGroup> |
| 84 | ) |
| 85 | } |