@@ -80,20 +80,34 @@ export const PostTableOfContents: React.FC<PostTableOfContentProps> = ({
8080 return ( ) => window . removeEventListener ( "scroll" , onScroll ) ;
8181 } , [ idsInOrder , mobileExpanded ] ) ;
8282
83+ // Prevent body scroll when mobile TOC is expanded
84+ useEffect ( ( ) => {
85+ if ( mobileExpanded ) {
86+ document . body . style . overflow = "hidden" ;
87+ } else {
88+ document . body . style . overflow = "" ;
89+ }
90+
91+ // Cleanup on unmount
92+ return ( ) => {
93+ document . body . style . overflow = "" ;
94+ } ;
95+ } , [ mobileExpanded ] ) ;
96+
8397 if ( ! toc ?. length ) return null ;
8498
8599 return (
86100 < >
87101 { /* Desktop: fixed right, sticky-like, always visible and expanded by default */ }
88102 < div className = "hidden lg:block" >
89- < div className = "fixed right-6 top-[160px] z-30 w-72 max-h-[70vh] overflow-auto rounded-lg border bg-primary-foreground p-4 shadow-sm" >
103+ < div className = "fixed right-6 top-[160px] z-30 w-56 max-h-[70vh] overflow-auto rounded-lg border bg-primary-foreground p-3 shadow-sm" >
90104 < Collapsible
91105 open = { desktopOpen }
92106 onOpenChange = { setDesktopOpen }
93107 className = "w-full"
94108 >
95109 < div className = "flex items-center justify-between" >
96- < h2 className = "text-lg font-semibold " > { locales . title } </ h2 >
110+ < h2 className = "text-sm font-medium " > { locales . title } </ h2 >
97111 < CollapsibleTrigger asChild >
98112 < Button
99113 variant = "ghost"
@@ -109,7 +123,7 @@ export const PostTableOfContents: React.FC<PostTableOfContentProps> = ({
109123 </ Button >
110124 </ CollapsibleTrigger >
111125 </ div >
112- < CollapsibleContent className = "mt-4 " >
126+ < CollapsibleContent className = "mt-3 " >
113127 < nav aria-label = "Table of contents" >
114128 < ListOfContent nodes = { toc } activeId = { activeId } />
115129 </ nav >
@@ -130,15 +144,15 @@ export const PostTableOfContents: React.FC<PostTableOfContentProps> = ({
130144 } `}
131145 aria-label = "Open table of contents"
132146 >
133- < span className = "text-sm font-medium" > { locales . title } </ span >
147+ < span className = "text-xs font-medium" > { locales . title } </ span >
134148 </ button >
135149
136150 { /* Expanded overlay */ }
137151 { mobileExpanded && (
138- < div className = "fixed inset-x-0 bottom-0 z-50 flex items-end justify-center" >
152+ < div className = "fixed inset-0 z-50 flex items-end justify-center bg-black/20 backdrop-blur-sm " >
139153 < div className = "mb-4 w-[min(92vw,28rem)] max-h-[75vh] overflow-auto rounded-xl border bg-primary-foreground p-4 shadow-xl" >
140154 < div className = "flex items-center justify-between" >
141- < h2 className = "text-lg font-semibold " > { locales . title } </ h2 >
155+ < h2 className = "text-sm font-medium " > { locales . title } </ h2 >
142156 < Button
143157 variant = "ghost"
144158 size = "sm"
@@ -202,7 +216,7 @@ const TOCLink: React.FC<{
202216 activeId ?: string | null ;
203217 onNavigate ?: ( ) => void ;
204218} > = ( { node, ch, activeId, onNavigate } ) => {
205- const fontSizes : Record < number , string > = { 2 : "base " , 3 : "sm " , 4 : "xs" } ;
219+ const fontSizes : Record < number , string > = { 2 : "sm " , 3 : "xs " , 4 : "xs" } ;
206220 const padding : Record < number , string > = { 2 : "pl-0" , 3 : "pl-7" , 4 : "pl-10" } ;
207221 const id = node . id ;
208222 const isActive = id && activeId === id ;
0 commit comments