aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/templates/layout
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2023-09-20 16:38:54 +0200
committerArmand Philippot <git@armandphilippot.com>2023-09-20 16:38:54 +0200
commitf861e6a269ba9f62700776d3cd13b644a9e836d4 (patch)
treea5a107e7a6e4ff8b4261fe04349357bc00b783ee /src/components/templates/layout
parent03331c44276ec56e9f235e4d5ee75030455a753f (diff)
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.
Diffstat (limited to 'src/components/templates/layout')
-rw-r--r--src/components/templates/layout/index.ts1
-rw-r--r--src/components/templates/layout/layout.stories.tsx2
-rw-r--r--src/components/templates/layout/layout.test.tsx2
-rw-r--r--src/components/templates/layout/layout.tsx50
4 files changed, 31 insertions, 24 deletions
diff --git a/src/components/templates/layout/index.ts b/src/components/templates/layout/index.ts
new file mode 100644
index 0000000..5d15fe1
--- /dev/null
+++ b/src/components/templates/layout/index.ts
@@ -0,0 +1 @@
+export * from './layout';
diff --git a/src/components/templates/layout/layout.stories.tsx b/src/components/templates/layout/layout.stories.tsx
index 4666b07..67ad008 100644
--- a/src/components/templates/layout/layout.stories.tsx
+++ b/src/components/templates/layout/layout.stories.tsx
@@ -1,5 +1,5 @@
import { ComponentMeta, ComponentStory } from '@storybook/react';
-import LayoutComponent from './layout';
+import { Layout as LayoutComponent } from './layout';
/**
* Layout - Storybook Meta
diff --git a/src/components/templates/layout/layout.test.tsx b/src/components/templates/layout/layout.test.tsx
index 6b3818e..53d16e3 100644
--- a/src/components/templates/layout/layout.test.tsx
+++ b/src/components/templates/layout/layout.test.tsx
@@ -1,5 +1,5 @@
import { render, screen } from '../../../../tests/utils';
-import Layout from './layout';
+import { Layout } from './layout';
const body =
'Sit dolorem eveniet. Sit sit odio nemo vitae corrupti modi sint est rerum. Pariatur quidem maiores distinctio. Quia et illum aspernatur est cum.';
diff --git a/src/components/templates/layout/layout.tsx b/src/components/templates/layout/layout.tsx
index cf35b5c..beb6562 100644
--- a/src/components/templates/layout/layout.tsx
+++ b/src/components/templates/layout/layout.tsx
@@ -2,21 +2,29 @@ import Script from 'next/script';
import { FC, ReactElement, ReactNode, useRef, useState } from 'react';
import { useIntl } from 'react-intl';
import { Person, SearchAction, WebSite, WithContext } from 'schema-dts';
-import { type NextPageWithLayoutOptions } from '../../../types/app';
-import useRouteChange from '../../../utils/hooks/use-route-change';
-import useScrollPosition from '../../../utils/hooks/use-scroll-position';
-import useSettings from '../../../utils/hooks/use-settings';
-import ButtonLink from '../../atoms/buttons/button-link';
-import Career from '../../atoms/icons/career';
-import CCBySA from '../../atoms/icons/cc-by-sa';
-import ComputerScreen from '../../atoms/icons/computer-screen';
-import Envelop from '../../atoms/icons/envelop';
-import Home from '../../atoms/icons/home';
-import PostsStack from '../../atoms/icons/posts-stack';
-import Main from '../../atoms/layout/main';
-import NoScript from '../../atoms/layout/no-script';
-import Footer, { type FooterProps } from '../../organisms/layout/footer';
-import Header, { type HeaderProps } from '../../organisms/layout/header';
+import { type NextPageWithLayoutOptions } from '../../../types';
+import {
+ useRouteChange,
+ useScrollPosition,
+ useSettings,
+} from '../../../utils/hooks';
+import {
+ ButtonLink,
+ Career,
+ CCBySA,
+ ComputerScreen,
+ Envelop,
+ Home,
+ Main,
+ NoScript,
+ PostsStack,
+} from '../../atoms';
+import {
+ Footer,
+ type FooterProps,
+ Header,
+ type HeaderProps,
+} from '../../organisms';
import photo from '/public/armand-philippot.jpg';
import styles from './layout.module.scss';
@@ -44,7 +52,7 @@ export type LayoutProps = Pick<HeaderProps, 'isHome'> & {
*
* Render the base layout used by all pages.
*/
-const Layout: FC<LayoutProps> = ({
+export const Layout: FC<LayoutProps> = ({
children,
withExtraPadding = false,
isHome,
@@ -203,14 +211,14 @@ const Layout: FC<LayoutProps> = ({
return (
<>
<Script
+ dangerouslySetInnerHTML={{ __html: JSON.stringify(schemaJsonLd) }}
id="schema-layout"
type="application/ld+json"
- dangerouslySetInnerHTML={{ __html: JSON.stringify(schemaJsonLd) }}
/>
<Script
+ dangerouslySetInnerHTML={{ __html: JSON.stringify(brandingSchema) }}
id="schema-branding"
type="application/ld+json"
- dangerouslySetInnerHTML={{ __html: JSON.stringify(brandingSchema) }}
/>
<noscript>
<div className={styles['noscript-spacing']}></div>
@@ -239,11 +247,11 @@ const Layout: FC<LayoutProps> = ({
</article>
</Main>
<Footer
+ backToTopClassName={backToTopClassName}
+ className={styles.footer}
copyright={copyrightData}
navItems={footerNav}
topId="top"
- backToTopClassName={backToTopClassName}
- className={styles.footer}
/>
<noscript>
<NoScript message={noScript} position="top" />
@@ -265,5 +273,3 @@ export const getLayout = (
) => {
return <Layout {...props}>{page}</Layout>;
};
-
-export default Layout;