@@ -7,6 +7,7 @@ type Props = {
77 defaultOpen ?: boolean ;
88 currentPathname : string ;
99 item : any ;
10+ isNestedElement ?: boolean ;
1011} ;
1112
1213export default function Collapsible ( props : PropsWithChildren < Props > ) {
@@ -19,8 +20,39 @@ export default function Collapsible(props: PropsWithChildren<Props>) {
1920 className = "flex flex-col gap-2 w-full"
2021 >
2122 < CollapsiblePrimitives . CollapsibleTrigger asChild >
22- < div className = "flex items-center justify-between w-full px-2.5 gap-1.5 text-sm text-secondary-foreground font-medium cursor-pointer" >
23- < p className = "truncate" > { props . item . data . label } </ p >
23+ < div
24+ className = { clsx (
25+ "flex items-center w-full gap-1.5 text-sm font-medium cursor-pointer justify-between" ,
26+ isOpen
27+ ? "text-muted-foreground"
28+ : "text-muted/75 dark:text-neutral-400" ,
29+ ) }
30+ >
31+ < div className = "flex items-center gap-1.5" >
32+ { props . isNestedElement && (
33+ < Icon
34+ icon = { props . item . data . icon }
35+ className = { clsx (
36+ "shrink-0 size-4 mr-1" ,
37+ isOpen
38+ ? "text-muted-foreground"
39+ : "text-muted/75 dark:text-neutral-400" ,
40+ ) }
41+ />
42+ ) }
43+ < p className = "truncate" > { props . item . data . label } </ p >
44+ </ div >
45+ { props . isNestedElement && (
46+ < Icon
47+ icon = "lucide:chevron-down"
48+ className = { clsx (
49+ "shrink-0 size-4 mr-1" ,
50+ props . currentPathname . startsWith ( `/docs/${ props . item . id } ` )
51+ ? "text-primary"
52+ : "group-data-[state=open]:text-muted-foreground" ,
53+ ) }
54+ />
55+ ) }
2456 </ div >
2557 </ CollapsiblePrimitives . CollapsibleTrigger >
2658 < CollapsiblePrimitives . CollapsibleContent className = "flex flex-col pl-5 ml-1" >
@@ -29,11 +61,12 @@ export default function Collapsible(props: PropsWithChildren<Props>) {
2961 return (
3062 < div
3163 key = { item . id }
32- className = "group relative w-full px-2.5 py-1.5 flex items-center gap-1.5 text-sm after:absolute after:-left-1.5 after:inset-y-0 after:block after:w-px after:transition-colors after:bg-muted/25 dark:after:bg-neutral-700 text-muted/75 dark:text-neutral-400"
64+ className = "group relative w-full px-2.5 py-1.5 flex items-center gap-1.5 text-sm after:absolute after:-left-1.5 after:inset-y-0 after:block after:w-px after:transition-colors after:bg-muted/25 dark:after:bg-secondary text-muted/75 dark:text-neutral-400"
3365 >
3466 < Collapsible
3567 item = { item }
3668 currentPathname = { props . currentPathname }
69+ isNestedElement = { true }
3770 />
3871 </ div >
3972 ) ;
@@ -44,17 +77,18 @@ export default function Collapsible(props: PropsWithChildren<Props>) {
4477 key = { item . id }
4578 href = { `/docs/${ item . id } ` }
4679 className = { clsx (
47- "group relative w-full px-2.5 py-1.5 flex items-center gap-1.5 text-sm after:absolute after:-left-1.5 after:inset-y-0 after:block after:w-px after:transition-colors" ,
80+ "group relative w-full px-2.5 py-1.5 flex items-center gap-1.5 text-sm after:absolute after:inset-y-0 after:block after:w-px after:transition-colors" ,
81+ props . isNestedElement ? "after:-left-4" : "after:-left-1.5" ,
4882 props . currentPathname . startsWith ( `/docs/${ item . id } ` )
4983 ? "text-primary after:bg-primary after:z-1 after:rounded-full"
50- : "after:bg-muted/25 dark:after:bg-neutral-700 text-muted/75 dark:text-neutral-400" ,
84+ : "after:bg-muted/25 dark:after:bg-secondary text-muted/75 dark:text-neutral-400" ,
5185 ) }
5286 >
5387 < Icon
5488 icon = { item . data . icon }
5589 className = { clsx (
5690 "shrink-0 size-4 mr-1" ,
57- props . currentPathname . startsWith ( `/docs/${ item . href } ` )
91+ props . currentPathname . startsWith ( `/docs/${ item . id } ` )
5892 ? "text-primary"
5993 : "group-data-[state=open]:text-muted-foreground" ,
6094 ) }
0 commit comments