import clsx from 'clsx'; import Card from '../Card/index.js'; import IconBlock from '../IconBlock/index.js'; import Icon from '../Icon/index.js'; import { useImageStatus } from '../../hooks/useImageStatus.js'; import styles from './styles.module.css'; export type LinkCardLinkProps = { to: string; href?: never } | { href: string; to?: never }; export type LinkCardProps = LinkCardLinkProps & { title: string; description?: string; image?: string; fallbackIcon?: string; /** 'icon' = small centered glyph (e.g. favicon); 'avatar' = fills the block (e.g. profile photo). */ imageVariant?: 'icon' | 'avatar'; }; const ICON_BOX_SIZE = 48; const FALLBACK_ICON_SIZE = 24; export default function LinkCard({ title, description, image, fallbackIcon, imageVariant = 'icon', ...linkProps }: LinkCardProps) { const { imgRef, status, onLoad, onError } = useImageStatus(image); const shouldLoadImage = !!image && status !== 'error'; const imageLoaded = status === 'loaded'; return ( {fallbackIcon && (

{title}

{description &&

{description}

}
); }