UNPKG

analytica-frontend-lib

Version:

Repositório público dos componentes utilizados nas plataformas da Analytica Ensino

52 lines (50 loc) 1.15 kB
import { UserIcon } from "./chunk-LGYNGKFL.mjs"; import { cn } from "./chunk-53ICLDGS.mjs"; // src/components/Avatar/Avatar.tsx import { useState } from "react"; import { jsx } from "react/jsx-runtime"; var Avatar = ({ src, alt, name, size = 40, className = "", ...props }) => { const [failedSrc, setFailedSrc] = useState(null); const showImage = Boolean(src) && failedSrc !== src; return /* @__PURE__ */ jsx( "div", { "data-component": "Avatar", className: cn( "relative shrink-0 overflow-hidden rounded-full", "flex items-center justify-center", className ), style: { width: size, height: size }, ...props, children: showImage ? /* @__PURE__ */ jsx( "img", { src, alt: alt ?? name ?? "", width: size, height: size, className: "h-full w-full object-cover", onError: () => setFailedSrc(src ?? null) } ) : /* @__PURE__ */ jsx(UserIcon, { size }) } ); }; var Avatar_default = Avatar; export { Avatar, Avatar_default }; //# sourceMappingURL=chunk-D6TC7CJV.mjs.map