import React from 'react'; import classNames from 'classnames'; import { isTruthyNativeHtmlStructure } from '../../utils/isTruthyNativeHtmlStructure'; import type { ImageProps } from '../Image/Image'; import { H2 } from '../Typography/H2/H2'; import { Paragraph } from '../Typography/Paragraph/Paragraph'; type HTMLImageProps = Pick; export const responsivePropEnum = Object.freeze([true, 'reversed', false] as const); export interface USPCardProps { /** * Content of the USP card. */ description?: React.ReactNode; /** * Image of the card. */ image?: string | HTMLImageProps; /** Whether the image should cover the entire area dedicated to the image or be contained within it * @default 'contain' */ imageFit?: 'cover' | 'contain'; /** * Controls whether and how the card responds to screen size. * * Card is responsive when set to `true` or `"reversed"`, in which case the card * will be displayed on the right side of the image. * * When set to `false`, the image and content will be displayed in a column. * * @default true */ responsive?: (typeof responsivePropEnum)[number]; /** * The title of the USP card. */ title: string; } export const USPCard: React.FC = ({ description, image, responsive = true, title, imageFit = 'contain', ...rest }) => { rest satisfies Record; const imgProps: ImageProps | undefined = image ? typeof image === 'string' ? { alt: '', src: image } : { ...image, alt: '' } : undefined; return (
{imgProps && ( )}

{title}

{isTruthyNativeHtmlStructure(description) ? {description} : description}
); };