@@ -7,26 +7,28 @@ import { useSearchContext } from 'fumadocs-ui/contexts/search';
77import { useSidebar } from 'fumadocs-ui/contexts/sidebar' ;
88import { usePathname } from 'fumadocs-core/framework' ;
99import * as stylex from '@stylexjs/stylex' ;
10- import { StyleXComponentProps } from './shared' ;
10+ import { BaseLayoutProps , StyleXComponentProps } from './shared' ;
11+ import { activeLinkMarker } from '../../theming/vars.stylex' ;
1112
12- export interface DocsLayoutProps {
13+ export interface DocsLayoutProps extends BaseLayoutProps {
1314 tree : PageTree . Root ;
1415 children : ReactNode ;
1516}
1617
17- export function DocsLayout ( { tree, children } : DocsLayoutProps ) {
18+ export function DocsLayout ( { tree, children, ... props } : DocsLayoutProps ) {
1819 return (
1920 < TreeContextProvider tree = { tree } >
2021 < header { ...stylex . props ( layoutStyles . header ) } >
2122 < nav { ...stylex . props ( layoutStyles . nav ) } >
23+ < NavbarSidebarTrigger
24+ { ...stylex . props ( layoutStyles . sidebarTrigger ) }
25+ />
2226 < Link href = "/" { ...stylex . props ( layoutStyles . title ) } >
23- My Docs
27+ { props . nav ?. title ?? ' My Docs' }
2428 </ Link >
2529
30+ < div { ...stylex . props ( layoutStyles . gap ) } />
2631 < SearchToggle />
27- < NavbarSidebarTrigger
28- { ...stylex . props ( layoutStyles . sidebarTrigger ) }
29- />
3032 </ nav >
3133 </ header >
3234 < main id = "nd-docs-layout" { ...stylex . props ( layoutStyles . main ) } >
@@ -40,10 +42,14 @@ const layoutStyles = stylex.create({
4042 header : {
4143 // sticky top-0 bg-fd-background h-14 z-20
4244 position : 'sticky' ,
45+ display : 'flex' ,
4346 top : 0 ,
4447 backgroundColor : 'var(--bg-fd-background)' ,
45- height : 14 ,
48+ height : '56px' ,
4649 zIndex : 20 ,
50+ borderBottomWidth : 1 ,
51+ borderBottomStyle : 'solid' ,
52+ borderBottomColor : 'var(--color-fd-border)' ,
4753 } ,
4854 nav : {
4955 // flex flex-row items-center gap-2 size-full px-4
@@ -54,21 +60,20 @@ const layoutStyles = stylex.create({
5460 width : '100%' ,
5561 paddingInline : 4 * 4 ,
5662 } ,
57- title : {
58- // font-medium mr-auto
59- fontWeight : 500 ,
60- marginInlineEnd : 'auto' ,
63+ title : { } ,
64+ gap : {
65+ flexGrow : 1 ,
6166 } ,
6267 sidebarTrigger : {
6368 // md:hidden
64- display : { default : 'none' , '@media (min-width: 768px)' : 'block' } ,
69+ // display: { default: 'none', '@media (min-width: 768px)': 'block' },
6570 } ,
6671 main : {
6772 // flex flex-1 flex-row [--fd-nav-height:56px]
6873 display : 'flex' ,
6974 flexGrow : 1 ,
7075 flexDirection : 'row' ,
71- [ '--fd-nav-height' as any ] : 56 * 4 ,
76+ [ '--fd-nav-height' as any ] : '56px' ,
7277 } ,
7378} ) ;
7479
@@ -170,7 +175,7 @@ const sidebarStyles = stylex.create({
170175 } ,
171176 } ,
172177 notOpen : {
173- display : { default : 'flex' , '@media (max-width: 767px)' : ' none' } ,
178+ display : ' none',
174179 } ,
175180} ) ;
176181
@@ -190,6 +195,7 @@ function SidebarItem({
190195 { ...stylex . props (
191196 linkVariants . base ,
192197 pathname === item . url ? linkVariants . active : linkVariants . inactive ,
198+ pathname === item . url && activeLinkMarker ,
193199 ) }
194200 >
195201 { item . icon }
@@ -207,29 +213,39 @@ function SidebarItem({
207213 ) ;
208214 }
209215
216+ // type "folder"
210217 return (
211- < div >
212- { item . index ? (
213- < Link
214- { ...stylex . props (
215- linkVariants . base ,
216- pathname === item . index . url
217- ? linkVariants . active
218- : linkVariants . inactive ,
219- ) }
220- href = { item . index . url }
221- >
222- { item . index . icon }
223- { item . index . name }
224- </ Link >
225- ) : (
226- < p { ...stylex . props ( linkVariants . base , sidebarItemStyles . textStart ) } >
227- { item . icon }
228- { item . name }
229- </ p >
230- ) }
218+ < details { ...stylex . props ( sidebarItemStyles . details ) } >
219+ < summary >
220+ { item . index ? (
221+ < Link
222+ { ...stylex . props (
223+ linkVariants . base ,
224+ sidebarItemStyles . summaryLink ,
225+ pathname === item . index . url
226+ ? linkVariants . active
227+ : linkVariants . inactive ,
228+ ) }
229+ href = { item . index . url }
230+ >
231+ { item . index . icon }
232+ { item . index . name }
233+ </ Link >
234+ ) : (
235+ < p
236+ { ...stylex . props (
237+ linkVariants . base ,
238+ sidebarItemStyles . summaryLink ,
239+ sidebarItemStyles . textStart ,
240+ ) }
241+ >
242+ { item . icon }
243+ { item . name }
244+ </ p >
245+ ) }
246+ </ summary >
231247 < div { ...stylex . props ( sidebarItemStyles . childContainer ) } > { children } </ div >
232- </ div >
248+ </ details >
233249 ) ;
234250}
235251const sidebarItemStyles = stylex . create ( {
@@ -239,31 +255,41 @@ const sidebarItemStyles = stylex.create({
239255 marginTop : { default : 6 * 4 , ':first-child' : 0 } ,
240256 marginBottom : 2 * 4 ,
241257 } ,
258+ details : {
259+ [ '--summary-color' as any ] : {
260+ default : null ,
261+ [ stylex . when . descendant ( ':is(*)' , activeLinkMarker ) ] : 'hotpink' ,
262+ } ,
263+ } ,
264+ summaryLink : {
265+ color :
266+ 'var(--summary-color, color-mix(in oklab, var(--text-fd-foreground) 80%, transparent))' ,
267+ } ,
242268 textStart : { textAlign : 'start' } ,
243269 childContainer : {
244270 paddingInlineStart : 4 * 4 ,
245271 borderInlineStartWidth : 1 ,
246272 borderInlineStartStyle : 'solid' ,
247- borderInlineStartColor : 'var(--border -fd-border)' ,
273+ borderInlineStartColor : 'var(--color -fd-border)' ,
248274 display : 'flex' ,
249275 flexDirection : 'column' ,
276+ [ '--summary-color' as any ] : 'initial' ,
250277 } ,
251278} ) ;
252279
253280const linkVariants = stylex . create ( {
254281 base : {
255- display : 'flex' ,
282+ display : 'inline- flex' ,
256283 alignItems : 'center' ,
257284 gap : 2 * 4 ,
258- width : '100%' ,
285+ // width: '100%',
259286 padding : 1.5 * 4 ,
260287 borderRadius : '8px' ,
261288 color : 'color-mix(in oklab, var(--text-fd-foreground) 80%, transparent)' ,
262- [ '--svg-size' as any ] : '4px' ,
263289 } ,
264290 active : {
265291 fontWeight : 500 ,
266- color : 'var(--text-fd-primary) ' ,
292+ color : 'hotpink ' ,
267293 } ,
268294 inactive : {
269295 color : {
0 commit comments