import clsx from "clsx" import React, { useMemo } from "react" import { IPFS_GATEWAY } from "~/lib/env" import { toGateway } from "~/lib/ipfs-parser" export const Avatar: React.FC< { images: (string | null | undefined)[] name?: string | null size?: number rounded?: boolean } & React.HTMLAttributes > = ({ images, size, name, className, rounded, ...props }) => { size = size || 60 const fontSize = size * 0.5 const nameAbbr = (name || "") .split(" ") .slice(0, 2) .map((word) => word[0]) .join("") const image = useMemo(() => { for (const image of images) { if (image) return toGateway(image) } }, [images]) const borderRadius = rounded === false ? "rounded-lg" : "rounded-full" if (!image) { return ( {nameAbbr} ) } return ( {/* eslint-disable-next-line @next/next/no-img-element */} {name ) }