From c153f93dc8691a71dc76aad3dd618298da9d238a Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Tue, 17 Oct 2023 19:46:08 +0200 Subject: refactor(components): rewrite Card component * make the component more generic * merge `` and `` styles into card component to avoid repeating the same structure * remove most of the props to use composition However the CSS is a bit complex because of the two variants... Also, the component should be refactored when the CSS pseudo-class `:has` has enough support: the provider and the `cover` and `meta` props should be removed. --- src/components/molecules/layout/card.tsx | 88 -------------------------------- 1 file changed, 88 deletions(-) delete mode 100644 src/components/molecules/layout/card.tsx (limited to 'src/components/molecules/layout/card.tsx') diff --git a/src/components/molecules/layout/card.tsx b/src/components/molecules/layout/card.tsx deleted file mode 100644 index d90cba2..0000000 --- a/src/components/molecules/layout/card.tsx +++ /dev/null @@ -1,88 +0,0 @@ -import NextImage, { type ImageProps as NextImageProps } from 'next/image'; -import type { FC } from 'react'; -import { ButtonLink, Figure, Heading, type HeadingLevel } from '../../atoms'; -import { MetaList, type MetaItemData } from '../meta-list'; -import styles from './card.module.scss'; - -export type CardProps = { - /** - * Set additional classnames to the card wrapper. - */ - className?: string; - /** - * The card cover. - */ - cover?: Pick; - /** - * The card id. - */ - id: string; - /** - * The card meta. - */ - meta?: MetaItemData[]; - /** - * The card tagline. - */ - tagline?: string; - /** - * The card title. - */ - title: string; - /** - * The title level (hn). - */ - titleLevel: HeadingLevel; - /** - * The card target. - */ - url: string; -}; - -/** - * Card component - * - * Render a link with minimal information about its content. - */ -export const Card: FC = ({ - className = '', - cover, - id, - meta, - tagline, - title, - titleLevel, - url, -}) => { - const cardClass = `${styles.wrapper} ${className}`; - const headingId = `${id}-heading`; - - return ( - -
-
- {cover ? ( -
- -
- ) : null} - - {title} - -
- {tagline ?
{tagline}
: null} - {meta ? ( - - ) : null} -
-
- ); -}; -- cgit v1.2.3