pleroma/app/soapbox/components/ui/layout/layout.tsx

65 lines
1.5 KiB
TypeScript
Raw Normal View History

2023-02-06 10:01:03 -08:00
import clsx 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
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
}
/** 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>
);
/** 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'>
<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
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,
}, className)}
2022-03-21 11:09:01 -07:00
>
{children}
</main>
);
/** 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'>
<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;