bigbuffet-rw/app/soapbox/components/ui/layout/layout.tsx

54 lines
1.4 KiB
TypeScript
Raw Normal View History

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