From c9c1c90b30e243563bb4f731da15b3fe657556d2 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Mon, 6 Nov 2023 18:08:04 +0100 Subject: refactor(components): replace Summary component with PostPreview * rename component to PostPreview because Summary is an HTML element and it could lead to confusion * replace `title` and `titleLevel` with `heading` and `headingLvl` because `title` is a native attribute * rename `intro` prop to `excerpt` * extract `cover` from `meta` prop * rewrite meta type * extract meta logic into a new component --- src/components/organisms/layout/summary.tsx | 235 ---------------------------- 1 file changed, 235 deletions(-) delete mode 100644 src/components/organisms/layout/summary.tsx (limited to 'src/components/organisms/layout/summary.tsx') diff --git a/src/components/organisms/layout/summary.tsx b/src/components/organisms/layout/summary.tsx deleted file mode 100644 index 0c95f90..0000000 --- a/src/components/organisms/layout/summary.tsx +++ /dev/null @@ -1,235 +0,0 @@ -import NextImage, { type ImageProps as NextImageProps } from 'next/image'; -import type { FC, ReactNode } from 'react'; -import { useIntl } from 'react-intl'; -import type { Article, Meta as MetaType } from '../../../types'; -import { useReadingTime } from '../../../utils/hooks'; -import { ButtonLink, type HeadingLevel, Icon, Link, Time } from '../../atoms'; -import { - Card, - CardActions, - CardBody, - CardCover, - CardFooter, - CardHeader, - CardMeta, - CardTitle, - type MetaItemData, -} from '../../molecules'; -import styles from './summary.module.scss'; - -export type Cover = Pick; - -export type SummaryMeta = Pick< - MetaType<'article'>, - | 'author' - | 'commentsCount' - | 'cover' - | 'dates' - | 'thematics' - | 'topics' - | 'wordsCount' ->; - -export type SummaryProps = Pick & { - /** - * The post metadata. - */ - meta: SummaryMeta; - /** - * The heading level (hn). - */ - titleLevel?: HeadingLevel; - /** - * The post url. - */ - url: string; -}; - -/** - * Summary component - * - * Render a page summary. - */ -export const Summary: FC = ({ - intro, - meta, - title, - titleLevel = 2, - url, -}) => { - const intl = useIntl(); - const figureLabel = intl.formatMessage( - { - defaultMessage: '{title} cover', - description: 'Summary: figure (cover) accessible name', - id: 'RNVe1W', - }, - { title } - ); - const readMore = intl.formatMessage( - { - defaultMessage: 'Read more about {title}', - description: 'Summary: read more link', - id: 'Zpgv+f', - }, - { - title, - a11y: (chunks: ReactNode) => ( - // eslint-disable-next-line react/jsx-no-literals -- SR class allowed - {chunks} - ), - } - ); - const readingTime = useReadingTime(meta.wordsCount, true); - - const getMetaItems = (): MetaItemData[] => { - const summaryMeta: MetaItemData[] = [ - { - id: 'publication-date', - label: intl.formatMessage({ - defaultMessage: 'Published on:', - description: 'Summary: publication date label', - id: 'TvQ2Ee', - }), - value: