signal-desktop/ts/components/conversation/TypingBubble.tsx

86 lines
2 KiB
TypeScript
Raw Normal View History

2020-10-30 20:34:04 +00:00
// Copyright 2018-2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
2018-11-14 19:10:32 +00:00
import React from 'react';
import classNames from 'classnames';
import { TypingAnimation } from './TypingAnimation';
import { Avatar } from '../Avatar';
import { LocalizerType } from '../../types/Util';
import { ColorType } from '../../types/Colors';
2018-11-14 19:10:32 +00:00
export interface Props {
2018-11-14 19:10:32 +00:00
avatarPath?: string;
color: ColorType;
name?: string;
2020-07-24 01:35:32 +00:00
phoneNumber?: string;
profileName?: string;
2020-07-24 01:35:32 +00:00
title: string;
conversationType: 'group' | 'direct';
2019-01-14 21:49:58 +00:00
i18n: LocalizerType;
2018-11-14 19:10:32 +00:00
}
export class TypingBubble extends React.PureComponent<Props> {
2020-09-14 19:51:27 +00:00
public renderAvatar(): JSX.Element | null {
2018-11-14 19:10:32 +00:00
const {
avatarPath,
color,
name,
phoneNumber,
profileName,
2020-07-24 01:35:32 +00:00
title,
2018-11-14 19:10:32 +00:00
conversationType,
i18n,
} = this.props;
if (conversationType !== 'group') {
2020-09-14 19:51:27 +00:00
return null;
2018-11-14 19:10:32 +00:00
}
return (
<div className="module-message__author-avatar">
<Avatar
avatarPath={avatarPath}
color={color}
conversationType="direct"
i18n={i18n}
name={name}
phoneNumber={phoneNumber}
profileName={profileName}
2020-07-24 01:35:32 +00:00
title={title}
2019-10-04 18:06:17 +00:00
size={28}
2018-11-14 19:10:32 +00:00
/>
</div>
);
}
2020-09-14 19:51:27 +00:00
public render(): JSX.Element {
const { i18n, color, conversationType } = this.props;
const isGroup = conversationType === 'group';
2018-11-14 19:10:32 +00:00
return (
<div
className={classNames(
'module-message',
'module-message--incoming',
isGroup ? 'module-message--group' : null
)}
>
2018-11-14 19:10:32 +00:00
<div
className={classNames(
'module-message__container',
'module-message__container--incoming',
`module-message__container--incoming-${color}`
)}
>
<div className="module-message__typing-container">
<TypingAnimation color="light" i18n={i18n} />
</div>
{this.renderAvatar()}
</div>
</div>
);
}
}