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

83 lines
1.9 KiB
TypeScript
Raw Normal View History

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
interface Props {
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> {
2018-11-14 19:10:32 +00:00
public renderAvatar() {
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') {
return;
}
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>
);
}
public render() {
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>
);
}
}