From 271ef6debaca7ed9a01829dcef3a37e90a2dff05 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Tue, 17 May 2022 22:48:41 +0200 Subject: chore: use persistent layout It prevents to rerender the common components between pages (header, footer...). --- .../sectioned/sectioned-layout.stories.tsx | 8 +++++++ .../templates/sectioned/sectioned-layout.tsx | 25 ++++++++++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) (limited to 'src/components/templates/sectioned') diff --git a/src/components/templates/sectioned/sectioned-layout.stories.tsx b/src/components/templates/sectioned/sectioned-layout.stories.tsx index ce31a83..689f9a7 100644 --- a/src/components/templates/sectioned/sectioned-layout.stories.tsx +++ b/src/components/templates/sectioned/sectioned-layout.stories.tsx @@ -1,4 +1,5 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; +import { LayoutBase } from '../layout/layout.stories'; import SectionedLayoutComponent from './sectioned-layout'; /** @@ -31,6 +32,13 @@ export default { }, }, }, + decorators: [ + (Story) => ( + + + + ), + ], parameters: { layout: 'fullscreen', }, diff --git a/src/components/templates/sectioned/sectioned-layout.tsx b/src/components/templates/sectioned/sectioned-layout.tsx index 58d5ad0..f91c354 100644 --- a/src/components/templates/sectioned/sectioned-layout.tsx +++ b/src/components/templates/sectioned/sectioned-layout.tsx @@ -2,12 +2,17 @@ import Section, { type SectionProps, type SectionVariant, } from '@components/atoms/layout/section'; +import Script from 'next/script'; import { FC } from 'react'; -import Layout, { type LayoutProps } from '../layout/layout'; +import { BreadcrumbList } from 'schema-dts'; export type Section = Pick; -export type SectionedLayoutProps = Pick & { +export type SectionedLayoutProps = { + /** + * The breadcrumb JSON schema. + */ + breadcrumbSchema: BreadcrumbList['itemListElement'][]; /** * An array of objects describing each section. */ @@ -19,7 +24,10 @@ export type SectionedLayoutProps = Pick & { * * Render a sectioned layout. */ -const SectionedLayout: FC = ({ sections, ...props }) => { +const SectionedLayout: FC = ({ + breadcrumbSchema, + sections, +}) => { const getSections = (items: SectionProps[]) => { return items.map((section, index) => { const variant: SectionVariant = index % 2 ? 'light' : 'dark'; @@ -37,7 +45,16 @@ const SectionedLayout: FC = ({ sections, ...props }) => { }); }; - return {getSections(sections)}; + return ( + <> +