Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update contentlayout to centre content when there is no navigation (#282) #286

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: update contentlayout to centre content when there is no navigat…
…ion (#282)
Fran McDade authored and Fran McDade committed Nov 22, 2024
commit 8c8e6a78946f96a8e3ad41fbada1aa864f7de9f9
Original file line number Diff line number Diff line change
@@ -30,6 +30,7 @@ const COLOR: Record<
};

interface LayoutProps {
hasNavigation?: boolean;
panelColor?: PanelBackgroundColor;
}

@@ -49,10 +50,18 @@ export const ContentLayout = styled.div<LayoutProps>`
margin: 0 auto;
${mediaDesktopSmallUp} {
grid-template-areas: "navigation content";
grid-template-columns:
${NAV_GRID_WIDTH}px
1fr;
${({ hasNavigation }) =>
hasNavigation
? css`
grid-template-areas: "navigation content";
grid-template-columns:
${NAV_GRID_WIDTH}px
1fr;
`
: css`
grid-template-areas: "content";
grid-template-columns: 1fr;
`};
}
${media1366Up} {
10 changes: 7 additions & 3 deletions src/components/Layout/components/ContentLayout/contentLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useRouter } from "next/router";
import React, { ReactNode } from "react";
import { useLayoutState } from "../../../../hooks/useLayoutState";
import { BaseComponentProps } from "../../../types";
import { LayoutStyle } from "./common/entities";
import {
Content,
@@ -14,7 +15,6 @@ import {
} from "./contentLayout.styles";

export interface ContentLayoutProps {
className?: string;
content: ReactNode;
layoutStyle?: LayoutStyle;
navigation?: ReactNode;
@@ -27,13 +27,17 @@ export const ContentLayout = ({
layoutStyle,
navigation,
outline,
}: ContentLayoutProps): JSX.Element => {
}: BaseComponentProps & ContentLayoutProps): JSX.Element => {
const { asPath } = useRouter();
const {
layoutState: { headerHeight },
} = useLayoutState();
return (
<Layout className={className} panelColor={layoutStyle?.content}>
<Layout
className={className}
hasNavigation={Boolean(navigation)}
panelColor={layoutStyle?.content}
>
{navigation && (
<NavigationGrid
headerHeight={headerHeight}
5 changes: 4 additions & 1 deletion src/views/ContentView/contentView.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { ReactNode } from "react";
import { LayoutStyle } from "../../components/Layout/components/ContentLayout/common/entities";
import { ContentLayout } from "../../components/Layout/components/ContentLayout/contentLayout";
import { BaseComponentProps } from "../../components/types";

export interface ContentViewProps {
content: ReactNode;
@@ -10,13 +11,15 @@ export interface ContentViewProps {
}

export const ContentView = ({
className,
content,
layoutStyle,
navigation,
outline,
}: ContentViewProps): JSX.Element => {
}: BaseComponentProps & ContentViewProps): JSX.Element => {
return (
<ContentLayout
className={className}
content={content}
layoutStyle={layoutStyle}
navigation={navigation}