mirror of
https://github.com/supabase/supabase.git
synced 2026-10-11 20:35:07 +03:00
- move navigation components to `apps/studio/components/layouts/Navigation` - add [FloatingMobileToolbar](https://github.com/supabase/supabase/pull/43444/changes#diff-3dffe47fd51ca851d612d8728e03b2dc344ec213d4f3a46a824d3fa32a7cc851) as quick access to tools such as search, assistant, inline editor, etc - behind feature flag and feature preview (true by default as it's a bit annoying to have to enable it all the time as previews are stored in local-storage) - fix sidebar panels closing on viewport resizing (regression from previous pr) https://github.com/user-attachments/assets/d6881e3b-5128-4306-bb82-3ca39c755dba <img width="986" height="697" alt="Screenshot 2026-03-12 at 12 40 11" src="https://github.com/user-attachments/assets/da8511e2-7d01-4237-b814-596031c747c5" />
68 lines
1.9 KiB
TypeScript
68 lines
1.9 KiB
TypeScript
import { useBreakpoint } from 'common'
|
|
import { useMobileSheet } from 'components/layouts/Navigation/NavigationBar/MobileSheetContext'
|
|
import { useEffect } from 'react'
|
|
import { useSidebarManagerSnapshot } from 'state/sidebar-manager-state'
|
|
import { cn, ResizableHandle, ResizablePanel } from 'ui'
|
|
|
|
import { SIDEBAR_KEYS, type TYPEOF_SIDEBAR_KEYS } from './LayoutSidebarProvider'
|
|
|
|
function isSidebarId(content: unknown): content is TYPEOF_SIDEBAR_KEYS {
|
|
return (
|
|
typeof content === 'string' &&
|
|
Object.values(SIDEBAR_KEYS).includes(content as TYPEOF_SIDEBAR_KEYS)
|
|
)
|
|
}
|
|
|
|
interface LayoutSidebarProps {
|
|
minSize?: string | number
|
|
maxSize?: string | number
|
|
defaultSize?: string | number
|
|
}
|
|
|
|
export const LayoutSidebar = ({
|
|
minSize = '30',
|
|
maxSize = '50',
|
|
defaultSize = '30',
|
|
}: LayoutSidebarProps) => {
|
|
const { activeSidebar } = useSidebarManagerSnapshot()
|
|
const isMobile = useBreakpoint('md')
|
|
const { content: sheetContent, setContent: setMobileSheetContent } = useMobileSheet()
|
|
|
|
useEffect(() => {
|
|
if (!isMobile) {
|
|
setMobileSheetContent(null)
|
|
return
|
|
}
|
|
if (activeSidebar?.component) {
|
|
setMobileSheetContent(activeSidebar.id)
|
|
} else if (isSidebarId(sheetContent)) {
|
|
setMobileSheetContent(null)
|
|
}
|
|
}, [isMobile, activeSidebar, sheetContent, setMobileSheetContent])
|
|
|
|
if (!activeSidebar?.component) return null
|
|
if (isMobile) return null
|
|
|
|
return (
|
|
<>
|
|
<ResizableHandle withHandle />
|
|
<ResizablePanel
|
|
id="panel-side"
|
|
key={activeSidebar?.id ?? 'default'}
|
|
defaultSize={defaultSize}
|
|
minSize={minSize}
|
|
maxSize={maxSize}
|
|
className={cn(
|
|
'border-l bg fixed z-40 right-0 top-0 bottom-0',
|
|
'h-[100dvh]',
|
|
'md:absolute md:h-auto md:w-1/2',
|
|
'lg:w-2/5',
|
|
'xl:relative xl:border-l-0'
|
|
)}
|
|
>
|
|
{activeSidebar?.component()}
|
|
</ResizablePanel>
|
|
</>
|
|
)
|
|
}
|