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/layout/layout.tsx | 50 +++++++++++++++++------------- 1 file changed, 28 insertions(+), 22 deletions(-) (limited to 'src/components/templates/layout/layout.tsx') 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 & { * * Render the base layout used by all pages. */ -const Layout: FC = ({ +export const Layout: FC = ({ children, withExtraPadding = false, isHome, @@ -203,14 +211,14 @@ const Layout: FC = ({ return ( <>