From 7255d25f6834a208c0ed44636356cc260f6ab6ba Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Wed, 27 Sep 2023 17:38:23 +0200 Subject: refactor(components): rewrite Heading component * remove `alignment` and `withMargin` props (consumer should handle that) * move styles to Sass placeholders to avoid repeats with headings coming from WordPress * refactor some other components that depend on Heading to avoid ESlint errors --- src/components/molecules/layout/page-header.tsx | 41 +++++++++++++++---------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'src/components/molecules/layout/page-header.tsx') diff --git a/src/components/molecules/layout/page-header.tsx b/src/components/molecules/layout/page-header.tsx index 9c11feb..04f2966 100644 --- a/src/components/molecules/layout/page-header.tsx +++ b/src/components/molecules/layout/page-header.tsx @@ -1,4 +1,4 @@ -import { FC, ReactNode } from 'react'; +import type { FC, ReactNode } from 'react'; import { Heading } from '../../atoms'; import { Meta, type MetaData } from './meta'; import styles from './page-header.module.scss'; @@ -11,7 +11,7 @@ export type PageHeaderProps = { /** * The page introduction. */ - intro?: string | JSX.Element; + intro?: string | ReactNode; /** * The page metadata. */ @@ -33,32 +33,39 @@ export const PageHeader: FC = ({ meta, title, }) => { + const headerClass = `${styles.wrapper} ${className}`; + const getIntro = () => { - return typeof intro === 'string' ? ( -
- ) : ( -
{intro}
- ); + if (typeof intro === 'string') + return ( +
+ ); + + return
{intro}
; }; return ( -
+
- + {title} - {meta && ( + {meta ? ( - )} - {intro && getIntro()} + ) : null} + {intro ? getIntro() : null}
); -- cgit v1.2.3