import { getImageProxyUrl } from "@follow/utils/img-proxy" import { cn } from "@follow/utils/utils" import * as Avatar from "@radix-ui/react-avatar" import type { MouseEvent, PropsWithChildren } from "react" import { forwardRef, useMemo } from "react" import { Blurhash } from "react-blurhash" type LazyImageProps = PropsWithChildren<{ src?: string blurhash?: string className?: string height?: number width?: number proxy?: { width: number height: number } onClick?: (e: MouseEvent) => void }> export const LazyImage = forwardRef( ({ src, blurhash, className, height, width, proxy, onClick }, ref) => { const nextSrc = useMemo(() => { if (!src) return src if (!proxy?.height && !proxy?.width) { return src } return getImageProxyUrl({ url: src, width: proxy?.width, height: proxy?.height, }) }, [src, proxy?.height, proxy?.width]) return (
{blurhash && ( )}
) }, )