import React from 'react' import classnames from 'classnames' /** * The available layout widths for the Layout component. * * Available options: * - inset-left - 5 columns (500 pixels), medium screens and above: 3 columns (300 pixels), float left * - inset-right - 5 columns (500 pixels), medium screens and above: 3 columns (300 pixels), float right * - `in-line` - [Default] 7 columns (700 pixels) * - `full-width` - Legacy alias for `in-line` * - `mid-grid` - 9 columns (900 pixels) * - `full-grid` - 12 columns of the grid (1200 pixels) * * @todo Existing layouts not currently supported by this component. To be implemented in the future: * @todo `full-bleed` - Edge to edge of the viewport, no padding * @todo The terminology in Spark doesn't align with our terminology. For instance, Editorial uses `full-width` that we map to `full-grid`. We should likely move towards an ubiquitous language prioritising the Editorial one. */ type LayoutWidth = | 'in-line' | 'mid-grid' | 'full-grid' | 'inset-left' | 'inset-right' interface ContentLayoutProps { dataLayout?: LayoutWidth dataComponent?: string className?: string children: React.ReactNode } /* * @description OverflowingLayout component prevent clashes with ads on the RHR (Righthand-rail) and share bar * via the usage of data-layout-width='full-grid' * See related code here: https://github.com/Financial-Times/next-article/blob/5766d82de6125ffc99fa6e3bc132311b3434f8f0/client/components/share/main.js#L8 */ const OverflowingLayout: React.FC<{ children: React.ReactNode }> = ({ children, }) => (
{children}
) const nonOverflowingLayoutModifiers = (dataLayout: LayoutWidth): string => { switch (dataLayout) { case 'inset-left': return '--inset-left' case 'inset-right': return '--inset-right' default: return '--in-line' } } /* * @description ContentLayout component is used to fulfill the legacy usage of n-layout. * @param dataLayout - The layout type of the content (e.g., 'full-grid', 'mid-grid', etc.). * @param dataComponent - The component type used as data-component attribute for client-side targeting. */ export const ContentLayout: React.FC< React.PropsWithChildren > = ({ dataLayout = 'in-line', children, dataComponent, className = '' }) => { const ContainerClassNames = classnames( 'n-content-layout__container', className ) if (dataLayout === 'full-grid') { return (
{children}
) } if (dataLayout === 'mid-grid') { return (
{children}
) } return (
{children}
) }