2023-02-06 10:01:03 -08:00
|
|
|
import clsx from 'clsx';
|
2022-03-21 11:09:01 -07:00
|
|
|
import React from 'react';
|
2022-04-06 08:04:06 -07:00
|
|
|
import StickyBox from 'react-sticky-box';
|
2022-03-21 11:09:01 -07:00
|
|
|
|
2023-01-10 15:03:15 -08:00
|
|
|
interface ISidebar {
|
|
|
|
children: React.ReactNode
|
|
|
|
}
|
|
|
|
interface IAside {
|
|
|
|
children?: React.ReactNode
|
|
|
|
}
|
|
|
|
|
|
|
|
interface ILayout {
|
|
|
|
children: React.ReactNode
|
|
|
|
}
|
|
|
|
|
|
|
|
interface LayoutComponent extends React.FC<ILayout> {
|
|
|
|
Sidebar: React.FC<ISidebar>,
|
2022-04-26 10:01:57 -07:00
|
|
|
Main: React.FC<React.HTMLAttributes<HTMLDivElement>>,
|
2023-01-10 15:03:15 -08:00
|
|
|
Aside: React.FC<IAside>,
|
2022-04-26 10:01:57 -07:00
|
|
|
}
|
|
|
|
|
2022-04-30 21:39:58 -07:00
|
|
|
/** Layout container, to hold Sidebar, Main, and Aside. */
|
|
|
|
const Layout: LayoutComponent = ({ children }) => (
|
2023-02-01 14:13:42 -08:00
|
|
|
<div className='relative sm:pt-4'>
|
|
|
|
<div className='mx-auto max-w-3xl sm:px-6 md:grid md:max-w-7xl md:grid-cols-12 md:gap-8 md:px-8'>
|
2022-03-21 11:09:01 -07:00
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
2022-04-30 21:39:58 -07:00
|
|
|
/** Left sidebar container in the UI. */
|
2023-01-10 15:03:15 -08:00
|
|
|
const Sidebar: React.FC<ISidebar> = ({ children }) => (
|
2023-02-01 14:13:42 -08:00
|
|
|
<div className='hidden lg:col-span-3 lg:block'>
|
2022-04-06 08:04:06 -07:00
|
|
|
<StickyBox offsetTop={80} className='pb-4'>
|
2022-03-21 11:09:01 -07:00
|
|
|
{children}
|
2022-04-06 08:04:06 -07:00
|
|
|
</StickyBox>
|
2022-03-21 11:09:01 -07:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
2022-04-30 21:39:58 -07:00
|
|
|
/** Center column container in the UI. */
|
2022-04-05 16:06:30 -07:00
|
|
|
const Main: React.FC<React.HTMLAttributes<HTMLDivElement>> = ({ children, className }) => (
|
2022-03-21 11:09:01 -07:00
|
|
|
<main
|
2023-02-06 10:01:03 -08:00
|
|
|
className={clsx({
|
2022-06-04 13:58:41 -07:00
|
|
|
'md:col-span-12 lg:col-span-9 xl:col-span-6 pb-36': true,
|
2022-04-05 16:06:30 -07:00
|
|
|
}, className)}
|
2022-03-21 11:09:01 -07:00
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</main>
|
|
|
|
);
|
|
|
|
|
2022-04-30 21:39:58 -07:00
|
|
|
/** Right sidebar container in the UI. */
|
2023-01-10 15:03:15 -08:00
|
|
|
const Aside: React.FC<IAside> = ({ children }) => (
|
2023-02-01 14:13:42 -08:00
|
|
|
<aside className='hidden xl:col-span-3 xl:block'>
|
2022-09-08 14:25:02 -07:00
|
|
|
<StickyBox offsetTop={80} className='space-y-6 pb-12'>
|
2022-03-21 11:09:01 -07:00
|
|
|
{children}
|
2022-04-06 08:04:06 -07:00
|
|
|
</StickyBox>
|
2022-03-21 11:09:01 -07:00
|
|
|
</aside>
|
|
|
|
);
|
|
|
|
|
|
|
|
Layout.Sidebar = Sidebar;
|
|
|
|
Layout.Main = Main;
|
|
|
|
Layout.Aside = Aside;
|
|
|
|
|
|
|
|
export default Layout;
|