@@ -17,24 +17,9 @@ export default function DocsLayout({
1717 const [ open , setOpen ] = useState ( false )
1818 const [ showTopFade , setShowTopFade ] = useState ( false )
1919 const [ showBottomFade , setShowBottomFade ] = useState ( false )
20- const [ isFixed , setIsFixed ] = useState ( false )
2120 const sidebarRef = useRef < HTMLDivElement > ( null )
22-
23- // Track scroll position to determine if sidebar should be fixed
24- useEffect ( ( ) => {
25- const handleScroll = ( ) => {
26- // The header with logo is approximately 72px tall (p-4 = 16px top/bottom + content height)
27- // Fix the sidebar when the user scrolls past the header
28- if ( window . scrollY > 72 ) {
29- setIsFixed ( true )
30- } else {
31- setIsFixed ( false )
32- }
33- }
34-
35- window . addEventListener ( 'scroll' , handleScroll )
36- return ( ) => window . removeEventListener ( 'scroll' , handleScroll )
37- } , [ ] )
21+ const containerRef = useRef < HTMLDivElement > ( null )
22+ const stickyTop = 64 // navbar height
3823
3924 // Handle sidebar scroll for dynamic fade effects
4025 useEffect ( ( ) => {
@@ -59,31 +44,35 @@ export default function DocsLayout({
5944
6045 return (
6146 < div className = "pt-8" >
62- < div className = "container flex md:space-x-8 overflow-x-hidden " >
47+ < div ref = { containerRef } className = "container flex md:space-x-8" >
6348 < div className = "hidden lg:block w-64 shrink-0" >
6449 < div
65- className = { `w-64 z-40 transition-all duration-200 ease-in-out ${
66- isFixed ? 'fixed top-4 h-[calc(100vh-2rem)]' : 'relative'
67- } `}
50+ className = "w-64 sticky z-40"
51+ style = { {
52+ top : `${ stickyTop } px` ,
53+ height : `calc(100vh - ${ stickyTop } px - 3rem)` ,
54+ } }
6855 >
6956 { /* Dynamic gradient fade indicators */ }
7057 { showTopFade && (
71- < div className = "absolute top-0 left-0 right-0 h-6 bg-gradient-to-b from-background to-transparent pointer-events-none z-10 rounded-t-lg transition-opacity duration-200" />
58+ < div className = "absolute top-0 left-0 right-0 h-12 bg-gradient-to-b from-background via-background/60 to-transparent pointer-events-none z-10 rounded-t-lg transition-opacity duration-200" />
7259 ) }
7360 { showBottomFade && (
74- < div className = "absolute bottom-0 left-0 right-0 h-6 bg-gradient-to-t from-background to-transparent pointer-events-none z-10 rounded-b-lg transition-opacity duration-200" />
61+ < div className = "absolute bottom-0 left-0 right-0 h-12 bg-gradient-to-t from-background via-background/60 to-transparent pointer-events-none z-10 rounded-b-lg transition-opacity duration-200" />
7562 ) }
7663
7764 { /* Enhanced scrollable container */ }
7865 < div
7966 ref = { sidebarRef }
80- className = "relative h-full overflow-y-auto pr-4 pl-4 pt-6 pb-6 custom-scrollbar bg-background/95 backdrop-blur-sm rounded-lg border border-border/50 shadow-lg"
67+ className = "relative h-full overflow-y-auto pr-4 pl-4 pt-4 pb-6 custom-scrollbar bg-background/95 backdrop-blur-sm rounded-lg border border-border/50 shadow-lg"
8168 >
8269 < DocSidebar className = "" onNavigate = { ( ) => setOpen ( false ) } />
8370 </ div >
8471 </ div >
8572 </ div >
86- < main className = "flex-1 mx-auto pb-36 md:px-8 min-w-0" > { children } </ main >
73+ < main className = "flex-1 mx-auto pb-36 md:px-8 min-w-0 pt-8" >
74+ { children }
75+ </ main >
8776 </ div >
8877 < div className = "flex items-center lg:hidden sticky bottom-0 z-50 bg-background/80 backdrop-blur-sm container p-4 rounded-t-lg border-t" >
8978 < Sheet
0 commit comments