({
src,
alt = 'Post cover image',
className,
loading = 'lazy',
fetchPriority,
}: PostImageProps)
| 13 | } |
| 14 | |
| 15 | export function PostImage({ |
| 16 | src, |
| 17 | alt = 'Post cover image', |
| 18 | className, |
| 19 | loading = 'lazy', |
| 20 | fetchPriority, |
| 21 | }: PostImageProps): ReactElement | null { |
| 22 | const openImage = useImageViewer(); |
| 23 | |
| 24 | if (!src || isPlaceholderImage(src)) { |
| 25 | return null; |
| 26 | } |
| 27 | |
| 28 | return ( |
| 29 | <button |
| 30 | type="button" |
| 31 | aria-label="Open image" |
| 32 | className={classNames( |
| 33 | 'block w-fit max-w-full cursor-zoom-in overflow-hidden rounded-12 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-cabbage-default', |
| 34 | className, |
| 35 | )} |
| 36 | onClick={(event) => { |
| 37 | event.stopPropagation(); |
| 38 | openImage(src, alt, event.currentTarget); |
| 39 | }} |
| 40 | > |
| 41 | <Image |
| 42 | src={src} |
| 43 | alt={alt} |
| 44 | loading={loading} |
| 45 | fetchPriority={fetchPriority} |
| 46 | className="block h-auto max-h-img-mobile w-auto max-w-full object-contain tablet:max-h-img-desktop" |
| 47 | /> |
| 48 | </button> |
| 49 | ); |
| 50 | } |
nothing calls this directly
no test coverage detected