mirror of
https://github.com/supabase/supabase.git
synced 2026-10-07 10:25:06 +03:00
## What kind of change does this PR introduce? bug fix to stop sidebar jump on scroll within docs ## What is the current behavior? the docs sidebar shifts up by 1px as soon as scrolling start as the top bar height include bottom border causing the jump as height token differ from the whole height ## What is the new behavior? favor box shadow instead of a border for the bottom line, so height matches the token and nothing needs to compensate any more which allows to remove some `+1px` elsewhere + also drops a nested `lg:sticky` in the sidebar that did nothing inside an already-sticky parent | state | preview | | -------|------| | before | <video src="https://github.com/user-attachments/assets/b4bbfa2d-6595-4711-bb2b-bd2bf3aded8a" /> | | after | <video src="https://github.com/user-attachments/assets/f044aebc-ef14-42c1-8564-3b290399d00b" /> | ## Additional context - header now uses the existing `subhighlight-border` utility, which was not used anywhere else it seems, could also be renamed? - could be down the other way by keeping border and fixing the jump <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved documentation navigation alignment by removing unnecessary spacing from sticky sidebars, table of contents, and section headings. * Updated desktop navigation behavior for more consistent scrolling and viewport layout. * Refined the top navigation bar’s border styling for a cleaner appearance. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
69 lines
2.0 KiB
TypeScript
69 lines
2.0 KiB
TypeScript
'use client'
|
|
|
|
import GuidesTableOfContents from '~/components/GuidesSidebar'
|
|
import { TocAnchorsProvider } from '~/features/docs/GuidesMdx.client'
|
|
import { type GuideFrontmatter } from '~/lib/docs'
|
|
import { createContext, useContext, type ReactNode } from 'react'
|
|
import { cn } from 'ui'
|
|
|
|
interface GuideContextValue {
|
|
meta?: GuideFrontmatter
|
|
}
|
|
|
|
const GuideContext = createContext<GuideContextValue | undefined>(undefined)
|
|
|
|
export const useGuide = () => {
|
|
const context = useContext(GuideContext)
|
|
if (!context) {
|
|
throw new Error('useGuide must be used within a GuideProvider')
|
|
}
|
|
return context
|
|
}
|
|
|
|
interface GuideProps {
|
|
meta?: GuideFrontmatter
|
|
children?: ReactNode
|
|
className?: string
|
|
}
|
|
|
|
export function Guide({ meta, children, className }: GuideProps) {
|
|
const hideToc = meta?.hideToc || meta?.hide_table_of_contents
|
|
|
|
return (
|
|
<GuideContext.Provider value={{ meta }}>
|
|
<TocAnchorsProvider>
|
|
<div className={cn('grid grid-cols-12 relative gap-4', className)}>
|
|
<div
|
|
className={cn(
|
|
'relative',
|
|
'transition-all ease-out',
|
|
'duration-100',
|
|
hideToc ? 'col-span-12' : 'col-span-12 md:col-span-8'
|
|
)}
|
|
>
|
|
{children}
|
|
</div>
|
|
{!hideToc && (
|
|
<GuidesTableOfContents
|
|
video={meta?.tocVideo}
|
|
className={cn(
|
|
'hidden md:flex',
|
|
'md:col-span-3 md:col-start-10',
|
|
'self-start',
|
|
'sticky',
|
|
/**
|
|
* --header-height: height of nav
|
|
* 3rem: content padding
|
|
*/
|
|
'top-[calc(var(--header-height)+3rem)]',
|
|
// 4rem accounts for 3rem of top padding + 1rem of extra breathing room
|
|
'max-h-[calc(100vh-var(--header-height)-4rem)]'
|
|
)}
|
|
/>
|
|
)}
|
|
</div>
|
|
</TocAnchorsProvider>
|
|
</GuideContext.Provider>
|
|
)
|
|
}
|