a tool for shared writing and social publishing
at update/reader 50 lines 1.3 kB view raw
1import { AccountTiny } from "./Icons/AccountTiny"; 2 3export const Avatar = (props: { 4 src: string | undefined; 5 displayName: string | undefined; 6 className?: string; 7 size?: "tiny" | "small" | "medium" | "large" | "giant"; 8}) => { 9 let sizeClassName = 10 props.size === "tiny" 11 ? "w-4 h-4" 12 : props.size === "small" 13 ? "w-5 h-5" 14 : props.size === "medium" 15 ? "h-6 w-6" 16 : props.size === "large" 17 ? "w-8 h-8" 18 : props.size === "giant" 19 ? "h-16 w-16" 20 : "w-6 h-6"; 21 22 if (props.src) 23 return ( 24 <img 25 className={`${sizeClassName} relative rounded-full shrink-0 border border-border-light ${props.className}`} 26 src={props.src} 27 alt={ 28 props.displayName 29 ? `${props.displayName}'s avatar` 30 : "someone's avatar" 31 } 32 /> 33 ); 34 else 35 return ( 36 <div 37 className={` relative bg-[var(--accent-light)] flex rounded-full shrink-0 border border-border-light place-items-center justify-center text-accent-1 ${sizeClassName}`} 38 > 39 <AccountTiny 40 className={ 41 props.size === "tiny" 42 ? "scale-80" 43 : props.size === "small" 44 ? "scale-90" 45 : "" 46 } 47 /> 48 </div> 49 ); 50};