First-class profile name rendering

This commit is contained in:
Scott Nonnenberg 2020-07-23 18:35:32 -07:00
parent 632cd0e87e
commit d07b8e82b2
63 changed files with 1044 additions and 454 deletions

View file

@ -1,32 +1,25 @@
import React from 'react';
import { Emojify } from './Emojify';
import { LocalizerType } from '../../types/Util';
export interface Props {
title: string;
phoneNumber?: string;
name?: string;
profileName?: string;
module?: string;
i18n: LocalizerType;
}
export class ContactName extends React.Component<Props> {
public render() {
const { phoneNumber, name, profileName, module } = this.props;
const { module, title } = this.props;
const prefix = module ? module : 'module-contact-name';
const title = name ? name : phoneNumber;
const shouldShowProfile = Boolean(profileName && !name);
const profileElement = shouldShowProfile ? (
<span className={`${prefix}__profile-name`}>
~<Emojify text={profileName || ''} />
</span>
) : null;
return (
<span className={prefix} dir="auto">
<Emojify text={title || ''} />
{shouldShowProfile ? ' ' : null}
{profileElement}
</span>
);
}