1+ "use client"
2+
3+ import * as React from "react"
4+
5+ import { ChevronRight , type LucideIcon } from "lucide-react"
6+ import {
7+ Collapsible ,
8+ CollapsibleContent ,
9+ CollapsibleTrigger ,
10+ } from "@/components/ui/collapsible"
11+ import {
12+ Sidebar ,
13+ SidebarContent ,
14+ SidebarFooter ,
15+ SidebarHeader ,
16+ SidebarRail ,
17+ SidebarGroup ,
18+ SidebarGroupLabel ,
19+ SidebarMenu ,
20+ SidebarMenuButton ,
21+ SidebarMenuItem ,
22+ SidebarMenuSub ,
23+ SidebarMenuSubButton ,
24+ SidebarMenuSubItem ,
25+ } from "@/components/ui/sidebar"
26+
27+ // Here is where you can add pages to the sidebar. The structure is as follows:
28+ // - A sidebar is made up of groups, which have a title and contain items.
29+ // - An item can be:
30+ // - a page (with a title and target page)
31+ // - a collapsible item (with a title, url, and sub-pages).
32+ const data = {
33+ navGroups : [
34+
35+ {
36+ title : "About" ,
37+ items : [
38+ {
39+ title : "What is JavaBee?" ,
40+ url : "#" ,
41+ } ,
42+ {
43+ title : "Resources" ,
44+ url : "#" ,
45+ } ,
46+ {
47+ title : "Branding" ,
48+ url : "#" ,
49+ } ,
50+ ] ,
51+ } ,
52+
53+ {
54+ title : "Programming" ,
55+ items : [
56+ {
57+ title : "Robot" ,
58+ url : "#" ,
59+ } ,
60+ {
61+ title : "Hardware" ,
62+ url : "#" ,
63+ items : [
64+ {
65+ title : "Motor" ,
66+ url : "#" ,
67+ } ,
68+ {
69+ title : "Servo" ,
70+ url : "#" ,
71+ } ,
72+ ] ,
73+ } ,
74+ ] ,
75+ } ,
76+
77+ {
78+ title : "Examples" ,
79+ items : [
80+ {
81+ title : "Example Pedro Autonomous" ,
82+ url : "#" ,
83+ } ,
84+ {
85+ title : "Example Teleop" ,
86+ url : "#" ,
87+ } ,
88+ ] ,
89+ } ,
90+
91+ ] ,
92+ }
93+
94+ export function AppSidebar ( { ...props } : React . ComponentProps < typeof Sidebar > ) {
95+ return (
96+ < Sidebar { ...props } >
97+ < SidebarHeader />
98+ < SidebarContent >
99+ { data . navGroups . map ( ( group ) => (
100+ < SidebarGroup key = { group . title } >
101+ < SidebarGroupLabel > { group . title } </ SidebarGroupLabel >
102+ < SidebarMenu >
103+ { group . items . map ( ( item ) => {
104+ if ( item . items && item . items . length > 0 ) {
105+ return (
106+ < Collapsible
107+ key = { item . title }
108+ asChild
109+ className = "group/collapsible"
110+ >
111+ < SidebarMenuItem >
112+ < CollapsibleTrigger asChild >
113+ < SidebarMenuButton tooltip = { item . title } >
114+ < span > { item . title } </ span >
115+ < ChevronRight
116+ className = "ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90"
117+ />
118+ </ SidebarMenuButton >
119+ </ CollapsibleTrigger >
120+ < CollapsibleContent >
121+ < SidebarMenuSub >
122+ { item . items ?. map ( ( subItem ) => (
123+ < SidebarMenuSubItem key = { subItem . title } >
124+ < SidebarMenuSubButton asChild >
125+ < a href = { subItem . url } >
126+ < span > { subItem . title } </ span >
127+ </ a >
128+ </ SidebarMenuSubButton >
129+ </ SidebarMenuSubItem >
130+ ) ) }
131+ </ SidebarMenuSub >
132+ </ CollapsibleContent >
133+ </ SidebarMenuItem >
134+ </ Collapsible >
135+ )
136+ }
137+ return (
138+ < SidebarMenuItem key = { item . title } >
139+ < SidebarMenuButton asChild tooltip = { item . title } >
140+ < a href = { item . url } >
141+ < span > { item . title } </ span >
142+ </ a >
143+ </ SidebarMenuButton >
144+ </ SidebarMenuItem >
145+ )
146+ } ) }
147+ </ SidebarMenu >
148+ </ SidebarGroup >
149+ ) ) }
150+ </ SidebarContent >
151+ < SidebarFooter />
152+ < SidebarRail />
153+ </ Sidebar >
154+ )
155+ }
0 commit comments