diff --git a/packages/components/layout/src/Layout.styles.ts b/packages/components/layout/src/Layout.styles.ts index 253bd6d4b6..537a381067 100644 --- a/packages/components/layout/src/Layout.styles.ts +++ b/packages/components/layout/src/Layout.styles.ts @@ -4,7 +4,7 @@ import type { LayoutProps } from './Layout'; import type { LayoutContextType } from './LayoutContext'; export const NAVBAR_HEIGHT = 60; -export const HEADER_HEIGHT = 56; +export const HEADER_HEIGHT = 57; // header plus border const getMainOffset = (withHeader: boolean) => withHeader ? HEADER_HEIGHT + NAVBAR_HEIGHT + 'px' : NAVBAR_HEIGHT + 'px'; @@ -53,7 +53,7 @@ const getContentContainerGridTemplateColumns = ({ } if (variant !== 'narrow' && withLeftSidebar && withRightSidebar) { - gridTemplateColumns = 'auto auto auto'; + gridTemplateColumns = `${sidebarWidth} auto ${sidebarWidth}`; } return css({ @@ -72,12 +72,6 @@ export const getLayoutStyles = ({ withLeftSidebar?: boolean; withRightSidebar?: boolean; }) => ({ - // this container will scroll if the content is too long and there is no sidebar - layoutWrapper: css({ - width: '100%', - height: '100vh', - overflowY: 'auto', - }), layoutMainContainer: css( getLayoutMaxWidthStyles({ variant, withBoxShadow }), { @@ -99,21 +93,13 @@ export const getLayoutStyles = ({ ), }); -export const getLayoutBodyStyles = ( - variant: LayoutContextType['variant'], - withSidebars: boolean, - withHeader: boolean, -) => ({ - layoutBodyContainer: css( - { - width: '100%', - padding: `${tokens.spacingL} ${tokens.spacingL} 0`, - }, - withSidebars && { - overflowY: 'auto', - height: `calc(100vh - ${getMainOffset(withHeader)})`, - }, - ), +export const getLayoutBodyStyles = (withHeader: boolean) => ({ + layoutBodyContainer: css({ + width: '100%', + padding: `${tokens.spacingL} ${tokens.spacingL} 0`, + overflowY: 'auto', + height: `calc(100vh - ${getMainOffset(withHeader)})`, + }), layoutBodyInner: css({ maxWidth: '900px', margin: '0 auto', diff --git a/packages/components/layout/src/Layout.tsx b/packages/components/layout/src/Layout.tsx index d8716aadcf..5a358cfac7 100644 --- a/packages/components/layout/src/Layout.tsx +++ b/packages/components/layout/src/Layout.tsx @@ -59,37 +59,32 @@ const _Layout = (props: LayoutProps, ref: Ref) => { const contextValue: LayoutContextType = useMemo( () => ({ variant, - withSidebars: Boolean(leftSidebar || rightSidebar), withHeader: Boolean(header), }), - [variant, leftSidebar, rightSidebar, header], + [variant, header], ); return ( - - - {header} + {header} - - {leftSidebar} - {children} - {rightSidebar} - - - + + {leftSidebar} + {children} + {rightSidebar} + + ); }; diff --git a/packages/components/layout/src/LayoutBody.tsx b/packages/components/layout/src/LayoutBody.tsx index 12d07d8bac..9c0aa0f6af 100644 --- a/packages/components/layout/src/LayoutBody.tsx +++ b/packages/components/layout/src/LayoutBody.tsx @@ -16,8 +16,8 @@ const _LayoutBody = (props: LayoutBodyProps, ref: Ref) => { testId = 'cf-layout-body', ...otherProps } = props; - const { variant, withSidebars, withHeader } = useLayoutContext(); - const styles = getLayoutBodyStyles(variant, withSidebars, withHeader); + const { variant, withHeader } = useLayoutContext(); + const styles = getLayoutBodyStyles(withHeader); return ( ; - withSidebars: boolean; withHeader: boolean; }; diff --git a/packages/components/layout/stories/Layout.stories.tsx b/packages/components/layout/stories/Layout.stories.tsx index ae2d2fb9c6..959b039d46 100644 --- a/packages/components/layout/stories/Layout.stories.tsx +++ b/packages/components/layout/stories/Layout.stories.tsx @@ -28,8 +28,19 @@ const ExampleWrapper = ({ children }) => ( height: '100vh', margin: '-1rem', backgroundColor: 'lavender', + flexDirection: 'column', })} > +
+ Navbar +
+ {children} ); @@ -58,15 +69,15 @@ const LayoutSidebarComp = ({ content }) => ( ); -export const withHeader: Story = (args) => { +export const basic: Story = (args) => { return ( - } {...args}> + @@ -78,7 +89,7 @@ export const withHeader: Story = (args) => { ); }; -export const withLongContent: Story = (args) => { +export const withHeader: Story = (args) => { return ( } {...args}>