import { useState, useEffect } from "react"; import { AnimatePresence, motion } from "motion/react"; export const Avatar = ({ uri, className = "outline-accent h-10 rounded-full min-w-10 outline", }: { uri: string | undefined; className?: string; }) => { const [loaded, setLoaded] = useState(false); useEffect(() => { setLoaded(false); }, [uri]); return (
{(!loaded || !uri) && ( )} setLoaded(true)} className="size-full object-cover" initial={{ opacity: 0 }} animate={{ opacity: loaded ? 1 : 0 }} transition={{ duration: 0.2 }} alt={`Your profile picture found at ${uri}`} />
); };