import { PhotoIcon, UserIcon } from '@heroicons/react/24/outline' import { useImageLoadStatus } from '../../hooks/useImageLoadStatus' type ImageWithFallbackProps = React.ImgHTMLAttributes & { fallback: 'avatar' | 'image' alt: string } export function ImageWithFallback({ fallback, className = '', onError, onLoad, src, alt, ...props }: ImageWithFallbackProps) { const { imageRef, failed, loaded, handleLoad, handleError } = useImageLoadStatus(src) if (failed || !src) { const Icon = fallback === 'avatar' ? UserIcon : PhotoIcon const isDecorative = alt === '' return ( ) } return ( {alt} { handleLoad() onLoad?.(event) }} onError={(event) => { handleError() onError?.(event) }} /> ) }