import { DetailedHTMLProps, ImgHTMLAttributes } from "react"; import { UploadImageFragment } from "graphql/generated"; import { getAssetURL, ImageQuality } from "helpers/img"; /* * ╭─────────────╮ * ────────────────────────────────────────╯ CONSTANTS ╰────────────────────────────────────────── */ interface Props extends Omit< DetailedHTMLProps, HTMLImageElement>, "src" > { src: UploadImageFragment | string; quality?: ImageQuality; } // ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ export const Img = ({ className, src: rawSrc, quality = ImageQuality.Small, alt, loading = "lazy", ...otherProps }: Props): JSX.Element => { const src = typeof rawSrc === "string" ? rawSrc : getAssetURL(rawSrc.url, quality); return ( {alt} ); };