import React from 'react'; import classNames from 'classnames'; import { Avatar } from '../Avatar'; import { Spinner } from '../Spinner'; import { LocalizerType } from '../../types/Util'; import { ContactType, getName } from '../../types/Contact'; // This file starts with _ to keep it from showing up in the StyleGuide. export function renderAvatar({ contact, i18n, size, direction, }: { contact: ContactType; i18n: LocalizerType; size: 28 | 52 | 80; direction?: 'outgoing' | 'incoming'; }) { const { avatar } = contact; const avatarPath = avatar && avatar.avatar && avatar.avatar.path; const pending = avatar && avatar.avatar && avatar.avatar.pending; const title = getName(contact) || ''; const spinnerSvgSize = size < 50 ? 'small' : 'normal'; const spinnerSize = size < 50 ? '24px' : undefined; if (pending) { return (