import clsx from "clsx"; import type { User } from "~/db/types"; import * as React from "react"; import { BLANK_IMAGE_URL } from "~/utils/urls"; const dimensions = { xxs: 24, xs: 36, sm: 44, xsm: 62, md: 81, lg: 125, } as const; export function Avatar({ user, size = "sm", className, alt = "", ...rest }: { user: Pick; className?: string; alt?: string; size: keyof typeof dimensions; } & React.ButtonHTMLAttributes) { const [isErrored, setIsErrored] = React.useState(false); // TODO: just show text... my profile? // TODO: also show this if discordAvatar is stale and 404's React.useEffect(() => { setIsErrored(false); }, [user.discordAvatar]); return ( {alt} setIsErrored(true)} {...rest} /> ); }