import React from 'react'; import clsx from 'clsx'; import { PageGrid } from '../PageGrid/page-grid'; import type { ResponsiveValue, PageGridSpanValue } from '../PageGrid/page-grid'; export interface CardTextIconCardProps { /** Icon image URL */ icon?: string; /** Alt text for the icon image */ iconAlt?: string; /** Card heading */ heading: string; /** Card description; accepts rich content (e.g., text with inline links) */ description: React.ReactNode | string; /** Optional aspect ratio for future use; applied via CSS variable */ aspectRatio?: number; /** When provided, renders as PageGrid.Col as="li" with this span—card becomes the grid column */ gridColSpan?: ResponsiveValue; /** Additional CSS classes */ className?: string; /** Optional height and width for the icon image */ height?: number; width?: number; } /** * CardTextIconCard Component * * A card component featuring an icon, heading, and description. * Built from Section Cards - Icon and Section Cards - Text Grid Figma designs. * * The description accepts ReactNode so it can include hyperlinks and other rich content. * * @example * // Basic usage * * * @example * // With inline link in description * * Learn more in our{' '} * documentation. * * } * /> */ const cardContent = ( heading: string, description: React.ReactNode | string, icon?: string, iconAlt?: string, iconHeight?: number, iconWidth?: number ) => ( <>
{icon && ( {iconAlt} )} {heading}

{description}

); export const CardTextIconCard: React.FC = ({ icon, iconAlt = '', heading, description, aspectRatio, gridColSpan, className, height, width }) => { const style = aspectRatio ? ({ '--bds-card-text-icon-aspect-ratio': aspectRatio } as React.CSSProperties) : undefined; if (gridColSpan) { return ( {cardContent(heading, description, icon, iconAlt, height, width)} ); } return (
{cardContent(heading, description, icon, iconAlt, height, width)}
); }; export default CardTextIconCard;