1
1
"use client" ;
2
2
3
- import { Accordion , Badge , Navbar , Sidebar } from "flowbite-react" ;
3
+ import { Navbar } from "flowbite-react" ;
4
4
import Image from "next/image" ;
5
5
import Link from "next/link" ;
6
6
import { usePathname } from "next/navigation" ;
7
7
import type { PropsWithChildren } from "react" ;
8
8
import { useEffect , useState } from "react" ;
9
9
import { HiMenuAlt1 , HiX } from "react-icons/hi" ;
10
10
import { twMerge } from "tailwind-merge" ;
11
- import { Banner } from "~/components/banner" ;
12
11
import { DocSearchInput } from "~/components/docsearch-input" ;
13
12
import { NavbarIcons , NavbarLinks } from "~/components/navbar" ;
14
13
import { DOCS_SIDEBAR , type DocsSidebarItem } from "~/data/docs-sidebar" ;
@@ -31,9 +30,9 @@ export default function DocsLayout({ children }: PropsWithChildren) {
31
30
return (
32
31
< div className = "w-full min-w-0 flex-auto" >
33
32
< div className = "relative" >
34
- < Banner />
33
+ { /* <Banner /> */ }
35
34
< DocsNavbar { ...state } />
36
- < div className = "lg:flex" >
35
+ < div className = "mx-auto w-full max-w-8xl px-4 lg:flex" >
37
36
< DocsSidebar { ...state } />
38
37
< div className = "w-full min-w-0" > { children } </ div >
39
38
</ div >
@@ -48,9 +47,9 @@ function DocsNavbar({ isCollapsed, setCollapsed }: DocsLayoutState) {
48
47
fluid
49
48
theme = { {
50
49
root : {
51
- base : "sticky top-0 z-[60] mx-auto flex w-full items-center justify-between border-b border-gray-200 bg-white px-4 py-2.5 text-gray-500 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-400" ,
50
+ base : "sticky top-0 z-[60] mx-auto flex w-full items-center justify-between border-b border-gray-200 bg-white text-gray-500 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-400" ,
52
51
inner : {
53
- base : "mx-auto flex w-full flex-wrap items-center justify-between" ,
52
+ base : "mx-auto flex w-full max-w-8xl flex-wrap items-center justify-between px-4 py-2.5 lg:px-4 " ,
54
53
} ,
55
54
} ,
56
55
} }
@@ -80,7 +79,7 @@ function DocsNavbar({ isCollapsed, setCollapsed }: DocsLayoutState) {
80
79
< Image alt = "" height = { 32 } src = "/favicon.svg" width = { 32 } className = "size-8" />
81
80
< span > Flowbite React</ span >
82
81
</ Link >
83
- < div className = "ml-4 hidden lg:flex xl:ml-14 " >
82
+ < div className = "hidden lg: ml-[4.5rem] lg:flex" >
84
83
< DocSearchInput />
85
84
</ div >
86
85
</ div >
@@ -106,29 +105,28 @@ function DocsSidebar({ isCollapsed, setCollapsed }: DocsLayoutState) {
106
105
< >
107
106
< div
108
107
className = { twMerge (
109
- "fixed inset-0 z-50 h -full w-64 flex-none border-r border-gray-200 lg:static lg:block lg:h-auto lg:overflow-y-visible lg:pt-6 dark:border -gray-600 " ,
108
+ "fixed inset-0 z-50 size -full max- w-64 overflow-y-auto bg-white lg:sticky lg:top-[61px] lg:block lg:h-[calc(100vh-4rem)] dark:bg -gray-900 " ,
110
109
isCollapsed && "hidden" ,
111
110
) }
112
111
>
113
- < Sidebar
114
- theme = { {
115
- root : {
116
- base : "h-full border-r border-gray-200 dark:border-gray-600" ,
117
- inner :
118
- "top-20 h-full overflow-y-auto bg-white px-4 pt-20 text-base font-normal lg:sticky lg:mr-0 lg:block lg:h-[calc(100vh-8rem)] lg:pt-0 lg:text-sm dark:bg-gray-900" ,
119
- } ,
120
- } }
112
+ < nav
113
+ aria-label = "Docs navigation"
114
+ className = "px-1 pb-8 pl-3 pt-16 text-base font-normal lg:pl-0 lg:pt-2 lg:text-sm"
121
115
>
122
- < Sidebar . Items className = "grid grid-cols-1 gap-2" >
116
+ < ul >
123
117
{ DOCS_SIDEBAR . map ( ( section ) => (
124
- < SidebarSection key = { section . title } title = { section . title } href = { section . href } >
118
+ < SidebarSection key = { section . title } title = { section . title } >
125
119
{ section . items . map ( ( item ) => (
126
- < SidebarItem key = { `section-${ section . title } _item-${ item . title } ` } { ...item } />
120
+ < SidebarItem
121
+ key = { `section-${ section . title } _item-${ item . title } ` }
122
+ onClick = { ( ) => setCollapsed ( true ) }
123
+ { ...item }
124
+ />
127
125
) ) }
128
126
</ SidebarSection >
129
127
) ) }
130
- </ Sidebar . Items >
131
- </ Sidebar >
128
+ </ ul >
129
+ </ nav >
132
130
</ div >
133
131
{ ! isCollapsed && (
134
132
< div
@@ -141,70 +139,59 @@ function DocsSidebar({ isCollapsed, setCollapsed }: DocsLayoutState) {
141
139
) ;
142
140
}
143
141
144
- function SidebarSection ( { title, href, children } : PropsWithChildren < { title : string ; href : string } > ) {
145
- const pathname = usePathname ( ) ;
146
-
142
+ function SidebarSection ( { title, children } : PropsWithChildren < { title : string } > ) {
147
143
return (
148
- < Accordion className = "border-none" collapseAll = { ! pathname . includes ( href ) } flush >
149
- < Accordion . Panel >
150
- < Accordion . Title
151
- theme = { {
152
- open : {
153
- on : "mb-2 text-primary-700 hover:text-primary-700 dark:text-primary-500 dark:hover:text-primary-500" ,
154
- off : "mb-1 text-gray-900 hover:text-primary-700 dark:text-white dark:hover:text-primary-500" ,
155
- } ,
156
- } }
157
- className = { twMerge (
158
- "flex w-full items-center justify-between bg-transparent p-0 text-sm font-semibold uppercase tracking-wide" ,
159
- pathname . includes ( href ) &&
160
- "text-primary-700 hover:text-primary-700 dark:text-primary-500 dark:hover:text-primary-500" ,
161
- ) }
162
- >
163
- { title }
164
- </ Accordion . Title >
165
- < Accordion . Content className = "mb-2 border-none p-0" >
166
- < Sidebar . ItemGroup className = "space-y-3 border-none" > { children } </ Sidebar . ItemGroup >
167
- </ Accordion . Content >
168
- </ Accordion . Panel >
169
- </ Accordion >
144
+ < li className = "mt-8" >
145
+ < h5 className = "mb-2 text-sm font-semibold uppercase tracking-wide text-gray-900 lg:text-xs dark:text-white" >
146
+ { title }
147
+ </ h5 >
148
+ < ul className = "py-1" > { children } </ ul >
149
+ </ li >
170
150
) ;
171
151
}
172
152
173
- function SidebarItem ( { title, href, isNew, isExternal } : DocsSidebarItem ) {
153
+ function SidebarItem ( { title, href, isNew, isExternal, onClick } : DocsSidebarItem & { onClick ( ) : void } ) {
174
154
return (
175
- < SidebarLink href = { href } isExternal = { isExternal } >
176
- { isNew ? < NewBadge > { title } </ NewBadge > : title }
177
- </ SidebarLink >
155
+ < li >
156
+ < SidebarLink href = { href } isExternal = { isExternal } onClick = { onClick } >
157
+ { isNew ? < NewBadge > { title } </ NewBadge > : title }
158
+ </ SidebarLink >
159
+ </ li >
178
160
) ;
179
161
}
180
162
181
- function SidebarLink ( { children, href, isExternal } : PropsWithChildren < { href : string ; isExternal ?: boolean } > ) {
163
+ function SidebarLink ( {
164
+ children,
165
+ href,
166
+ isExternal,
167
+ onClick,
168
+ } : PropsWithChildren < { href : string ; isExternal ?: boolean ; onClick ( ) : void } > ) {
182
169
const pathname = usePathname ( ) ;
183
170
184
171
return (
185
- < Sidebar . Item
186
- as = { Link }
172
+ < Link
187
173
href = { href }
188
- target = { isExternal && "_blank" }
174
+ target = { isExternal ? "_blank" : undefined }
189
175
className = { twMerge (
190
- "p-0 font-medium transition-all hover:bg-transparent lg:text-sm dark:hover:bg-transparent [&>*]:px-0 " ,
176
+ "flex flex-wrap items-center py-2 font-medium " ,
191
177
pathname === href
192
178
? "text-primary-700 hover:text-primary-700 dark:text-primary-500"
193
179
: "text-gray-500 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white" ,
194
180
) }
181
+ onClick = { onClick }
195
182
>
196
183
{ children }
197
- </ Sidebar . Item >
184
+ </ Link >
198
185
) ;
199
186
}
200
187
201
188
function NewBadge ( { children } : PropsWithChildren ) {
202
189
return (
203
190
< span className = "flex items-center gap-2" >
204
191
{ children }
205
- < Badge color = "cyan" className = "h-4 px-1.5" >
206
- New
207
- </ Badge >
192
+ < span className = "ml-2 inline-flex h-[1.1rem] items-center rounded border border-cyan-100 bg-cyan-100 px-1.5 text-[10px] font-semibold uppercase text-cyan-800 dark:border-cyan-400 dark:bg-gray-700 dark:text-cyan-400 " >
193
+ new
194
+ </ span >
208
195
</ span >
209
196
) ;
210
197
}
0 commit comments