2025-04-01 16:15:20 +02:00
|
|
|
import React from 'react'
|
|
|
|
import { Breadcrumbs } from '@freesewing/react/components/Breadcrumbs'
|
|
|
|
import { Link as DefaultLink } from '@freesewing/react/components/Link'
|
|
|
|
|
2025-05-24 13:11:06 +02:00
|
|
|
/**
|
2025-04-01 16:15:20 +02:00
|
|
|
* This is the default layout, including title and breadcrumbs
|
|
|
|
*
|
2025-05-24 13:11:06 +02:00
|
|
|
* @component
|
|
|
|
* @param {object} props - All component props
|
|
|
|
* @param {function} [props.Link = false] - An optional framework specific Link component
|
|
|
|
* @param {JSX.Element} [props.children = []] - The component children to render inside the layout
|
|
|
|
* @param {array} [props.crumbs = []] - Data for the breadcrumbs, see Breadcrumbs
|
2025-04-01 16:15:20 +02:00
|
|
|
* @param {string} props.title - The page title
|
2025-05-24 13:11:06 +02:00
|
|
|
* @returns {JSX.Element}
|
2025-04-01 16:15:20 +02:00
|
|
|
*/
|
2025-05-30 11:29:55 +02:00
|
|
|
export const Layout = ({ children = [], crumbs = [], Link = false, title }) => {
|
2025-04-01 16:15:20 +02:00
|
|
|
if (!Link) Link = DefaultLink
|
|
|
|
|
|
|
|
return (
|
|
|
|
<BaseLayout>
|
2025-04-18 08:07:13 +00:00
|
|
|
<div className="tw:max-w-xl tw:w-full tw:mx-auto">
|
2025-04-01 16:15:20 +02:00
|
|
|
<Breadcrumbs {...{ crumbs, title, Link }} />
|
2025-04-18 08:07:13 +00:00
|
|
|
<h1 className="tw:break-words">{title}</h1>
|
|
|
|
<div className="tw:xl:pl-4">{children}</div>
|
2025-04-01 16:15:20 +02:00
|
|
|
</div>
|
|
|
|
</BaseLayout>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2025-05-24 13:11:06 +02:00
|
|
|
/**
|
2025-04-01 16:15:20 +02:00
|
|
|
* This is the base layout
|
|
|
|
*
|
2025-05-24 13:11:06 +02:00
|
|
|
* @component
|
|
|
|
* @param {object} props - All component props
|
|
|
|
* @param {JSX.Element} [props.children = []] - The component children to render inside the layout
|
|
|
|
* @returns {JSX.Element}
|
2025-04-01 16:15:20 +02:00
|
|
|
*/
|
|
|
|
export const BaseLayout = ({ children }) => (
|
2025-04-18 08:07:13 +00:00
|
|
|
<div className="tw:flex tw:flex-row tw:items-start tw:w-full tw:justify-between tw:2xl:px-36 tw:xl:px-12 tw:px-4 tw:gap-0 tw:lg:gap-4 tw:xl:gap-8 3xl:tw:gap-12">
|
2025-04-01 16:15:20 +02:00
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
|
2025-05-24 13:11:06 +02:00
|
|
|
/**
|
2025-04-01 16:15:20 +02:00
|
|
|
* The left column of the base layout
|
|
|
|
*
|
2025-05-24 13:11:06 +02:00
|
|
|
* @component
|
|
|
|
* @param {object} props - All component props
|
|
|
|
* @param {JSX.Element} [props.children = []] - The component children to render inside the layout
|
|
|
|
* @returns {JSX.Element}
|
2025-04-01 16:15:20 +02:00
|
|
|
*/
|
|
|
|
export const BaseLayoutLeft = ({ children = [] }) => (
|
2025-04-18 08:07:13 +00:00
|
|
|
<div className="tw:max-w-96 tw:w-1/4 tw:hidden tw:lg:block tw:shrink-0 tw:my-8 tw:sticky tw:top-4 tw:max-h-screen tw:overflow-scroll">
|
2025-04-01 16:15:20 +02:00
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
|
2025-05-24 13:11:06 +02:00
|
|
|
/**
|
2025-04-01 16:15:20 +02:00
|
|
|
* The right column of the base layout
|
|
|
|
*
|
2025-05-24 13:11:06 +02:00
|
|
|
* @component
|
|
|
|
* @param {object} props - All component props
|
|
|
|
* @param {JSX.Element} [props.children = []] - The component children to render inside the layout
|
|
|
|
* @returns {JSX.Element}
|
2025-04-01 16:15:20 +02:00
|
|
|
*/
|
|
|
|
export const BaseLayoutRight = ({ children = [] }) => (
|
2025-04-18 08:07:13 +00:00
|
|
|
<div className="tw:max-w-96 tw:w-1/4 tw:hidden tw:xl:block tw:my-8 tw:sticky tw:top-2">
|
2025-04-01 16:15:20 +02:00
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
|
2025-05-24 13:11:06 +02:00
|
|
|
/**
|
2025-04-01 16:15:20 +02:00
|
|
|
* The main column for prose (text like docs and so on)
|
|
|
|
*
|
2025-05-24 13:11:06 +02:00
|
|
|
* @component
|
|
|
|
* @param {object} props - All component props
|
|
|
|
* @param {JSX.Element} [props.children = []] - The component children to render inside the layout
|
|
|
|
* @param {boolean} [props.wide false] - Set this to true to render a full-width prose layout
|
|
|
|
* @returns {JSX.Element}
|
2025-04-01 16:15:20 +02:00
|
|
|
*/
|
|
|
|
export const BaseLayoutProse = ({ children = [], wide = false }) => (
|
2025-04-18 08:07:13 +00:00
|
|
|
<div className={`tw:grow tw:w-full tw:m-auto tw:max-w-${wide ? 'full' : 'prose'} tw:my-8`}>
|
2025-04-01 16:15:20 +02:00
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
|
2025-05-24 13:11:06 +02:00
|
|
|
/**
|
2025-04-01 16:15:20 +02:00
|
|
|
* The central column for wide content (no max-width)
|
|
|
|
*
|
2025-05-24 13:11:06 +02:00
|
|
|
* @component
|
|
|
|
* @param {object} props - All component props
|
|
|
|
* @param {JSX.Element} [props.children = []] - The component children to render inside the layout
|
|
|
|
* @returns {JSX.Element}
|
2025-04-01 16:15:20 +02:00
|
|
|
*/
|
|
|
|
export const BaseLayoutWide = ({ children = [] }) => (
|
2025-04-18 08:07:13 +00:00
|
|
|
<div className="tw:grow tw:w-full tw:m-auto tw:my-8 tw:grow">{children}</div>
|
2025-04-01 16:15:20 +02:00
|
|
|
)
|
|
|
|
|
2025-05-24 13:11:06 +02:00
|
|
|
/**
|
2025-04-01 16:15:20 +02:00
|
|
|
* A layout for pages that do their own title/layout, like the sign in page
|
|
|
|
*
|
2025-05-24 13:11:06 +02:00
|
|
|
* @component
|
|
|
|
* @param {object} props - All component props
|
|
|
|
* @param {JSX.Element} [props.children = []] - The component children to render inside the layout
|
|
|
|
* @returns {JSX.Element}
|
2025-04-01 16:15:20 +02:00
|
|
|
*/
|
|
|
|
export const NoTitleLayout = ({ children }) => {
|
|
|
|
return (
|
|
|
|
<BaseLayout>
|
2025-04-18 08:07:13 +00:00
|
|
|
<div className="tw:max-w-xl tw:w-full tw:mx-auto">
|
2025-04-01 16:15:20 +02:00
|
|
|
<div>{children}</div>
|
|
|
|
</div>
|
|
|
|
</BaseLayout>
|
|
|
|
)
|
|
|
|
}
|