Files
supabase/apps/studio/components/layouts/DefaultLayout.tsx
T
Jonathan Summers-MuirandJoshen Lim 51beca756d Feat/sidebar studio (#33612)
* add sidebar

* sidebar docs added

* add sidebar

* fixed issues

* fix mobile

* move settings icon back down

* remove old stuff

* Delete SideBar.tsx

* use ProfileImage component

* spelling

* Update ThemeSettings.tsx

* Update ThemeSettings.tsx

* Update Sidebar.tsx

* layout udpate

* Update Sidebar.tsx

* fixes

* Minor lints

* Update Sidebar.tsx

* create a alt user dropdown for self hosting and local

* add fragment back in

* Adds Theme Selector for local/self hosting

* Update UserDropdown.tsx

* fix theme selector for local self host

* Update index.ts

* move dropdown and fix

* Update LayoutHeader.tsx

* update const

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2025-03-05 15:39:01 +01:00

56 lines
2.2 KiB
TypeScript

import { PropsWithChildren } from 'react'
import { useParams } from 'common'
import { AppBannerWrapper } from 'components/interfaces/App'
import { AppBannerContextProvider } from 'components/interfaces/App/AppBannerWrapperContext'
import { Sidebar } from 'components/interfaces/Sidebar'
import { SidebarProvider } from 'ui'
import { LayoutHeader } from './ProjectLayout/LayoutHeader'
import MobileNavigationBar from './ProjectLayout/NavigationBar/MobileNavigationBar'
import { ProjectContextProvider } from './ProjectLayout/ProjectContext'
export interface DefaultLayoutProps {
showProductMenu?: boolean
}
/**
* Base layout for all project pages in the dashboard, rendered as the first child on all page files within a project.
*
* A second layout as the child to this is required, and the layout depends on which section of the dashboard the page is on. (e.g Auth - AuthLayout)
*
* The base layout handles rendering the following UI components:
* - App banner (e.g for notices or incidents)
* - Mobile navigation bar
* - First level side navigation bar (e.g For navigating to Table Editor, SQL Editor, Database page, etc)
* @param showProductMenu - (Mobile only) Show button to toggle visiblity of product menu (Default: true)
*/
const DefaultLayout = ({ children, showProductMenu }: PropsWithChildren<DefaultLayoutProps>) => {
const { ref } = useParams()
return (
<SidebarProvider defaultOpen={false}>
<ProjectContextProvider projectRef={ref}>
<AppBannerContextProvider>
<div className="flex flex-col h-screen w-screen">
{/* Top Banner */}
<AppBannerWrapper />
<div className="flex-shrink-0">
<MobileNavigationBar />
<LayoutHeader showProductMenu={showProductMenu} />
</div>
{/* Main Content Area */}
<div className="flex flex-1 w-full overflow-y-hidden">
{/* Sidebar */}
<Sidebar />
{/* Main Content */}
<div className="flex-grow h-full overflow-y-auto">{children}</div>
</div>
</div>
</AppBannerContextProvider>
</ProjectContextProvider>
</SidebarProvider>
)
}
export default DefaultLayout