From 9aeb82269d7c74c4566b7ca254782a4dfbd69a6e Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Wed, 25 Oct 2023 18:33:22 +0200 Subject: refactor(components): remove SiteHeader and SiteFooter components They do not help to make the layout more readable (on the contrary I think...) so the props drilling is useless. --- src/components/templates/layout/layout.tsx | 151 ++++++++++++++++------------- 1 file changed, 86 insertions(+), 65 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 2369669..bf9629c 100644 --- a/src/components/templates/layout/layout.tsx +++ b/src/components/templates/layout/layout.tsx @@ -18,15 +18,25 @@ import { useScrollPosition, useSettings, } from '../../../utils/hooks'; -import { ButtonLink, Heading, Icon, Logo, Main } from '../../atoms'; import { - SiteFooter, - type SiteFooterProps, - SiteHeader, - type SiteHeaderProps, -} from '../../organisms'; + ButtonLink, + Footer, + Header, + Heading, + Icon, + Logo, + Main, +} from '../../atoms'; +import { + BackToTop, + Branding, + Colophon, + type ColophonLink, + Copyright, + FlippingLogo, +} from '../../molecules'; +import { type MainNavItem, Toolbar } from '../../organisms'; import styles from './layout.module.scss'; -import { FlippingLogo } from 'src/components/molecules'; export type QueryAction = SearchAction & { 'query-input': string; @@ -87,12 +97,6 @@ export const Layout: FC = ({ id: 'yB1SPF', }); - const copyrightData = { - from: copyright.start, - owner: name, - to: copyright.end, - }; - const homeLabel = intl.formatMessage({ defaultMessage: 'Home', description: 'Layout: main nav - home link', @@ -134,8 +138,13 @@ export const Layout: FC = ({ }, { website: name } ); + const backToTop = intl.formatMessage({ + defaultMessage: 'Back to top', + description: 'Layout: an accessible name for the back to top button', + id: 'Kjj1Zk', + }); - const mainNav: SiteHeaderProps['nav'] = [ + const mainNav: MainNavItem[] = [ { id: 'home', label: homeLabel, @@ -174,7 +183,7 @@ export const Layout: FC = ({ id: 'nwbzKm', }); - const footerNav: SiteFooterProps['navItems'] = [ + const footerNav: ColophonLink[] = [ { id: 'legal-notice', label: legalNoticeLabel, href: ROUTES.LEGAL_NOTICE }, ]; @@ -215,14 +224,14 @@ export const Layout: FC = ({ }; const [backToTopClassName, setBackToTopClassName] = useState( - styles['back-to-top--hidden'] + `${styles['back-to-top']} ${styles['back-to-top--hidden']}` ); const updateBackToTopClassName = () => { const visibleBreakpoint = 300; setBackToTopClassName( window.scrollY > visibleBreakpoint - ? styles['back-to-top--visible'] - : styles['back-to-top--hidden'] + ? `${styles['back-to-top']} ${styles['back-to-top--visible']}` + : `${styles['back-to-top']} ${styles['back-to-top--hidden']}` ); }; @@ -265,48 +274,54 @@ export const Layout: FC = ({ {skipToContent} - - {baseline} - - } - className={styles.header} - logo={ - } - className={styles.brand__logo} - front={ - +
+ + {baseline} +
+ } + logo={ + } + className={styles.brand__logo} + front={ + + } /> } + name={ + + {name} + + } + url="/" /> - } - // eslint-disable-next-line react/jsx-no-literals -- Storage key allowed - motionStorageKey="reduced-motion" - name={ - - {name} - - } - nav={mainNav} - searchPage={ROUTES.SEARCH} - url="/" - /> + + +
= ({ {children}
- } - navItems={footerNav} - topId="top" - /> +
+ + } + license={} + links={footerNav} + /> + +
-- cgit v1.2.3