2021-12-20 04:06:30 +00:00
|
|
|
import clsx from 'clsx'
|
2022-05-26 21:41:24 +00:00
|
|
|
import { ReactNode } from 'react'
|
2022-03-31 05:35:20 +00:00
|
|
|
import { BottomNavBar } from './nav/nav-bar'
|
|
|
|
import Sidebar from './nav/sidebar'
|
2022-05-24 06:44:16 +00:00
|
|
|
import { Toaster } from 'react-hot-toast'
|
2021-12-20 04:06:30 +00:00
|
|
|
|
2022-01-27 22:37:43 +00:00
|
|
|
export function Page(props: {
|
2022-05-26 21:41:24 +00:00
|
|
|
rightSidebar?: ReactNode
|
2022-04-11 21:13:26 +00:00
|
|
|
suspend?: boolean
|
2022-07-11 23:40:25 +00:00
|
|
|
className?: string
|
2022-07-17 20:56:39 +00:00
|
|
|
rightSidebarClassName?: string
|
2022-05-26 22:22:44 +00:00
|
|
|
children?: ReactNode
|
2022-01-27 22:37:43 +00:00
|
|
|
}) {
|
2022-07-17 20:56:39 +00:00
|
|
|
const { children, rightSidebar, suspend, className, rightSidebarClassName } =
|
|
|
|
props
|
2021-12-20 04:06:30 +00:00
|
|
|
|
2022-07-11 23:40:25 +00:00
|
|
|
const bottomBarPadding = 'pb-[58px] lg:pb-0 '
|
2021-12-20 04:06:30 +00:00
|
|
|
return (
|
2022-05-13 23:47:50 +00:00
|
|
|
<>
|
2021-12-20 04:06:30 +00:00
|
|
|
<div
|
2022-07-11 23:40:25 +00:00
|
|
|
className={clsx(
|
|
|
|
className,
|
|
|
|
bottomBarPadding,
|
|
|
|
'mx-auto w-full lg:grid lg:grid-cols-12 lg:gap-x-2 xl:max-w-7xl xl:gap-x-8'
|
|
|
|
)}
|
2022-04-11 21:13:26 +00:00
|
|
|
style={suspend ? visuallyHiddenStyle : undefined}
|
2021-12-20 04:06:30 +00:00
|
|
|
>
|
2022-05-24 06:44:16 +00:00
|
|
|
<Toaster />
|
2022-07-11 23:40:25 +00:00
|
|
|
<Sidebar className="sticky top-0 hidden divide-gray-300 self-start pl-2 lg:col-span-2 lg:block" />
|
2022-03-31 05:35:20 +00:00
|
|
|
<main
|
|
|
|
className={clsx(
|
2022-07-12 00:07:37 +00:00
|
|
|
'lg:col-span-8 lg:pt-6',
|
2022-03-31 05:35:20 +00:00
|
|
|
rightSidebar ? 'xl:col-span-7' : 'xl:col-span-8'
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
|
|
|
|
{/* If right sidebar is hidden, place its content at the bottom of the page. */}
|
2022-07-11 23:40:25 +00:00
|
|
|
<div className="block xl:hidden">{rightSidebar}</div>
|
2022-03-31 05:35:20 +00:00
|
|
|
</main>
|
|
|
|
<aside className="hidden xl:col-span-3 xl:block">
|
2022-07-17 20:56:39 +00:00
|
|
|
<div
|
|
|
|
className={clsx('sticky top-4 space-y-4', rightSidebarClassName)}
|
|
|
|
>
|
|
|
|
{rightSidebar}
|
|
|
|
</div>
|
2022-03-31 05:35:20 +00:00
|
|
|
</aside>
|
2021-12-20 04:06:30 +00:00
|
|
|
</div>
|
2022-03-31 05:35:20 +00:00
|
|
|
|
|
|
|
<BottomNavBar />
|
2022-05-13 23:47:50 +00:00
|
|
|
</>
|
2021-12-20 04:06:30 +00:00
|
|
|
)
|
|
|
|
}
|
2022-04-11 21:13:26 +00:00
|
|
|
|
|
|
|
const visuallyHiddenStyle = {
|
|
|
|
clip: 'rect(0 0 0 0)',
|
|
|
|
clipPath: 'inset(50%)',
|
|
|
|
height: 1,
|
|
|
|
margin: -1,
|
|
|
|
overflow: 'hidden',
|
|
|
|
padding: 0,
|
|
|
|
position: 'absolute',
|
|
|
|
width: 1,
|
|
|
|
whiteSpace: 'nowrap',
|
|
|
|
} as const
|