From f861e6a269ba9f62700776d3cd13b644a9e836d4 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Wed, 20 Sep 2023 16:38:54 +0200 Subject: refactor: use named export for everything except pages Next expect a default export for pages so only those components should use default exports. Everything else should use named exports to reduce the number of import statements. --- src/components/templates/sectioned/index.ts | 1 + .../templates/sectioned/sectioned-layout.stories.tsx | 2 +- .../templates/sectioned/sectioned-layout.test.tsx | 2 +- src/components/templates/sectioned/sectioned-layout.tsx | 17 ++++++----------- 4 files changed, 9 insertions(+), 13 deletions(-) create mode 100644 src/components/templates/sectioned/index.ts (limited to 'src/components/templates/sectioned') diff --git a/src/components/templates/sectioned/index.ts b/src/components/templates/sectioned/index.ts new file mode 100644 index 0000000..a8c6045 --- /dev/null +++ b/src/components/templates/sectioned/index.ts @@ -0,0 +1 @@ +export * from './sectioned-layout'; diff --git a/src/components/templates/sectioned/sectioned-layout.stories.tsx b/src/components/templates/sectioned/sectioned-layout.stories.tsx index 689f9a7..7c97400 100644 --- a/src/components/templates/sectioned/sectioned-layout.stories.tsx +++ b/src/components/templates/sectioned/sectioned-layout.stories.tsx @@ -1,6 +1,6 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; import { LayoutBase } from '../layout/layout.stories'; -import SectionedLayoutComponent from './sectioned-layout'; +import { SectionedLayout as SectionedLayoutComponent } from './sectioned-layout'; /** * SectionedLayout - Storybook Meta diff --git a/src/components/templates/sectioned/sectioned-layout.test.tsx b/src/components/templates/sectioned/sectioned-layout.test.tsx index a7f19cc..204f0d4 100644 --- a/src/components/templates/sectioned/sectioned-layout.test.tsx +++ b/src/components/templates/sectioned/sectioned-layout.test.tsx @@ -1,6 +1,6 @@ import { render, screen } from '../../../../tests/utils'; import { BreadcrumbList } from 'schema-dts'; -import SectionedLayout from './sectioned-layout'; +import { SectionedLayout } from './sectioned-layout'; const breadcrumbSchema: BreadcrumbList['itemListElement'][] = []; const sections = [ diff --git a/src/components/templates/sectioned/sectioned-layout.tsx b/src/components/templates/sectioned/sectioned-layout.tsx index 7fcad63..a307688 100644 --- a/src/components/templates/sectioned/sectioned-layout.tsx +++ b/src/components/templates/sectioned/sectioned-layout.tsx @@ -1,12 +1,9 @@ import Script from 'next/script'; import { FC } from 'react'; import { BreadcrumbList } from 'schema-dts'; -import Section, { - type SectionProps, - type SectionVariant, -} from '../../atoms/layout/section'; +import { Section, type SectionProps, type SectionVariant } from '../../atoms'; -export type Section = Pick; +export type PageSection = Pick; export type SectionedLayoutProps = { /** @@ -16,7 +13,7 @@ export type SectionedLayoutProps = { /** * An array of objects describing each section. */ - sections: Section[]; + sections: PageSection[]; }; /** @@ -24,7 +21,7 @@ export type SectionedLayoutProps = { * * Render a sectioned layout. */ -const SectionedLayout: FC = ({ +export const SectionedLayout: FC = ({ breadcrumbSchema, sections, }) => { @@ -35,9 +32,9 @@ const SectionedLayout: FC = ({ return (
@@ -48,13 +45,11 @@ const SectionedLayout: FC = ({ return ( <>