// Copyright 2019-2020 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import * as React from 'react'; import classNames from 'classnames'; import { Avatar, Props as AvatarProps } from './Avatar'; import { useRestoreFocus } from '../util/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): JSX.Element => { const focusRef = React.useRef(null); const { i18n, name, profileName, phoneNumber, title, onViewPreferences, onViewArchive, style, } = props; const shouldShowNumber = Boolean(name || 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 (
{profileName || title}
{shouldShowNumber ? (
{phoneNumber}
) : null}

); };