import * as AvatarPrimitive from "@radix-ui/react-avatar"; import * as Tooltip from "@radix-ui/react-tooltip"; import classNames from "@calcom/lib/classNames"; import { defaultAvatarSrc } from "@calcom/lib/defaultAvatarImage"; import { Icon } from "@calcom/ui"; import { Maybe } from "@trpc/server"; export type AvatarProps = { className?: string; size: "xs" | "sm" | "md" | "mdLg" | "lg"; imageSrc?: Maybe; title?: string; alt: string; gravatarFallbackMd5?: string; fallback?: React.ReactNode; accepted?: boolean; asChild?: boolean; // Added to ignore the outer span on the fallback component - messes up styling }; const sizesPropsBySize = { xs: "w-4 h-4", // 16px sm: "w-6 h-6", // 24px md: "w-8 h-8", // 32px mdLg: "w-10 h-10", //40px lg: "w-16 h-16", // 64px } as const; export function Avatar(props: AvatarProps) { const { imageSrc, gravatarFallbackMd5, size, alt, title } = props; const sizeClassname = sizesPropsBySize[size]; const rootClass = classNames("rounded-full aspect-square ", sizeClassname); const avatar = ( <> <> {props.fallback && !gravatarFallbackMd5 && props.fallback} {gravatarFallbackMd5 && ( {alt} )} {props.accepted && (
{size === "lg" && }
)}
); return title ? ( {avatar} {title} ) : ( <>{avatar} ); }