import * as React from 'react'; import classNames from 'classnames'; import { isEmpty } from 'lodash'; import { Avatar, Props as AvatarProps } from './Avatar'; import { useRestoreFocus } from './hooks'; import { LocalizerType } from '../types/Util'; export type Props = { readonly i18n: LocalizerType; onViewPreferences: () => unknown; onViewArchive: () => unknown; // Matches Popper's RefHandler type innerRef?: React.Ref; style: React.CSSProperties; } & AvatarProps; export const AvatarPopup = (props: Props) => { const focusRef = React.useRef(null); const { i18n, profileName, phoneNumber, onViewPreferences, onViewArchive, style, } = props; const hasProfileName = !isEmpty(profileName); // Note: mechanisms to dismiss this view are all in its host, MainHeader // Focus first button after initial render, restore focus on teardown useRestoreFocus(focusRef); return (
{hasProfileName ? profileName : phoneNumber}
{hasProfileName ? (
{phoneNumber}
) : null}

); };