19 lines
446 B
TypeScript
19 lines
446 B
TypeScript
import type { JSX } from "solid-js";
|
|
|
|
type ImageProps = JSX.IntrinsicElements["img"] & { src: string; alt: string };
|
|
|
|
export function Image(props: ImageProps) {
|
|
const isDecorationImage = props.alt === "";
|
|
|
|
return (
|
|
<img
|
|
{...props}
|
|
src={props.src}
|
|
role={isDecorationImage ? "presentation" : "img"}
|
|
aria-hidden={isDecorationImage ? "true" : undefined}
|
|
alt={isDecorationImage ? undefined : props.alt}
|
|
loading="lazy"
|
|
/>
|
|
);
|
|
}
|