diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-05-09 18:19:38 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-05-09 19:41:02 +0200 |
| commit | 0d59a6d2995b4119865271ed1908ede0bb96497c (patch) | |
| tree | 67688e41b7aa253aa58cc08aa360431b07382f9d /src/components/molecules/layout/page-header.tsx | |
| parent | 339c6957fe92c4ec1809159f09c55201d3794c18 (diff) | |
refactor: rewrite DescriptionList and Meta components
The meta can have different layout. The previous implementation was not
enough to easily change the layout. Also, I prefer to restrict the meta
types and it prevents me to repeat myself for the labels.
Diffstat (limited to 'src/components/molecules/layout/page-header.tsx')
| -rw-r--r-- | src/components/molecules/layout/page-header.tsx | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/components/molecules/layout/page-header.tsx b/src/components/molecules/layout/page-header.tsx index 1663085..9abe9af 100644 --- a/src/components/molecules/layout/page-header.tsx +++ b/src/components/molecules/layout/page-header.tsx @@ -1,7 +1,7 @@ import Heading from '@components/atoms/headings/heading'; -import styles from './page-header.module.scss'; -import Meta, { type MetaMap } from './meta'; import { FC } from 'react'; +import Meta, { type MetaData } from './meta'; +import styles from './page-header.module.scss'; export type PageHeaderProps = { /** @@ -15,7 +15,7 @@ export type PageHeaderProps = { /** * The page metadata. */ - meta?: MetaMap; + meta?: MetaData; /** * The page title. */ @@ -33,14 +33,29 @@ const PageHeader: FC<PageHeaderProps> = ({ meta, title, }) => { + const getIntro = () => { + return typeof intro === 'string' ? ( + <div dangerouslySetInnerHTML={{ __html: intro }} /> + ) : ( + <div>{intro}</div> + ); + }; + return ( <header className={`${styles.wrapper} ${className}`}> <div className={styles.body}> <Heading level={1} className={styles.title} withMargin={false}> {title} </Heading> - {meta && <Meta data={meta} className={styles.meta} layout="inline" />} - {intro && <div>{intro}</div>} + {meta && ( + <Meta + data={meta} + className={styles.meta} + layout="column" + itemsLayout="inline" + /> + )} + {intro && getIntro()} </div> </header> ); |
