File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ export const TableOfContents = ({
2121 if ( visibleItems . length === 0 ) return null
2222
2323 return (
24- < div className = "flex flex-col gap-3 rounded-custom border border-subtle bg-subtle/20 px-5 py-4 transition-height " >
24+ < div className = "flex flex-col rounded-custom border border-subtle bg-subtle/20 px-5 py-4" >
2525 < button
2626 type = "button"
2727 className = "flex w-full items-center justify-between gap-4 text-left focus:outline-none"
@@ -32,17 +32,28 @@ export const TableOfContents = ({
3232 className = { cn ( 'size-4 text-secondary transition-transform' , open ? 'rotate-180' : '' ) }
3333 />
3434 </ button >
35- { open ? (
36- < ul className = "space-y-2 p-0" >
37- { visibleItems . map ( item => (
38- < li key = { item . id } className = { cn ( 'list-none text-sm' , item . level === 3 ? 'pl-6' : '' ) } >
39- < a href = { `#${ item . id } ` } className = "flex items-start gap-3 no-underline hover:underline" >
40- < span className = "leading-6" > { item . title } </ span >
41- </ a >
42- </ li >
43- ) ) }
44- </ ul >
45- ) : null }
35+ < div
36+ className = "grid transition-[grid-template-rows] duration-300 ease-in-out"
37+ style = { { gridTemplateRows : open ? '1fr' : '0fr' } }
38+ >
39+ < div className = "overflow-hidden" >
40+ < ul className = "mt-3 space-y-2 p-0" >
41+ { visibleItems . map ( item => (
42+ < li
43+ key = { item . id }
44+ className = { cn ( 'list-none text-sm' , item . level === 3 ? 'pl-6' : '' ) }
45+ >
46+ < a
47+ href = { `#${ item . id } ` }
48+ className = "flex items-start gap-3 no-underline hover:underline"
49+ >
50+ < span className = "leading-6" > { item . title } </ span >
51+ </ a >
52+ </ li >
53+ ) ) }
54+ </ ul >
55+ </ div >
56+ </ div >
4657 </ div >
4758 )
4859}
You can’t perform that action at this time.
0 commit comments