import clsx from 'clsx'; import React, { useState } from 'react'; import StillImage, { IStillImage } from 'soapbox/components/still-image'; import Icon from '../icon/icon'; const AVATAR_SIZE = 42; interface IAvatar extends Pick { /** Width and height of the avatar in pixels. */ size?: number } /** Round profile avatar for accounts. */ const Avatar = (props: IAvatar) => { const { src, size = AVATAR_SIZE, className } = props; const [isAvatarMissing, setIsAvatarMissing] = useState(false); const handleLoadFailure = () => setIsAvatarMissing(true); const style: React.CSSProperties = React.useMemo(() => ({ width: size, height: size, }), [size]); if (isAvatarMissing) { return (
); } return ( ); }; export { Avatar as default, AVATAR_SIZE };