diff --git a/src/components/Img.tsx b/src/components/Img.tsx index 3ee57a4..ac73aff 100644 --- a/src/components/Img.tsx +++ b/src/components/Img.tsx @@ -2,41 +2,40 @@ import { UploadImageFragment } from "graphql/generated"; import { getAssetURL, getImgSizesByQuality, ImageQuality } from "helpers/img"; import { Immutable } from "helpers/types"; import { ImageProps } from "next/image"; +import { MouseEventHandler } from "react"; interface Props { className?: string; image?: UploadImageFragment | string; quality?: ImageQuality; alt?: ImageProps["alt"]; + onClick?: MouseEventHandler; } export default function Img(props: Immutable): JSX.Element { - if (typeof props.image === "string") { + const { + className, + image, + quality = ImageQuality.Small, + alt, + onClick, + } = props; + + if (typeof image === "string") { + return ( + {alt + ); + } else if (image?.width && image.height) { + const imgSize = getImgSizesByQuality(image.width, image.height, quality); return ( {props.alt - ); - } else if (props.image?.width && props.image.height) { - const imgSize = getImgSizesByQuality( - props.image.width, - props.image.height, - props.quality ?? ImageQuality.Small - ); - return ( - {props.alt ); }