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

93 lines
2.2 KiB
TypeScript
Raw Normal View History

2021-05-07 22:21:10 +00:00
// Copyright 2018-2021 Signal Messenger, LLC
2020-10-30 20:34:04 +00:00
// SPDX-License-Identifier: AGPL-3.0-only
import type { ReactElement } from 'react';
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 type { LocalizerType, ThemeType } from '../../types/Util';
import type { ConversationType } from '../../state/ducks/conversations';
import type { BadgeType } from '../../badges/types';
2018-11-14 19:10:32 +00:00
2021-05-07 22:21:10 +00:00
export type Props = Pick<
ConversationType,
| 'acceptedMessageRequest'
| 'avatarPath'
| 'color'
| 'isMe'
| 'name'
| 'phoneNumber'
| 'profileName'
| 'sharedGroupNames'
| 'title'
> & {
badge: undefined | BadgeType;
conversationType: 'group' | 'direct';
2019-01-14 21:49:58 +00:00
i18n: LocalizerType;
theme: ThemeType;
};
2018-11-14 19:10:32 +00:00
export function TypingBubble({
acceptedMessageRequest,
avatarPath,
badge,
color,
conversationType,
i18n,
isMe,
name,
phoneNumber,
profileName,
sharedGroupNames,
theme,
title,
}: Props): ReactElement {
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
)}
>
{isGroup && (
<div className="module-message__author-avatar-container">
<Avatar
acceptedMessageRequest={acceptedMessageRequest}
avatarPath={avatarPath}
badge={badge}
color={color}
conversationType="direct"
i18n={i18n}
isMe={isMe}
name={name}
phoneNumber={phoneNumber}
profileName={profileName}
theme={theme}
title={title}
sharedGroupNames={sharedGroupNames}
size={28}
/>
</div>
)}
<div className="module-message__container-outer">
<div
className={classNames(
'module-message__container',
'module-message__container--incoming'
)}
>
<div className="module-message__typing-container">
<TypingAnimation color="light" i18n={i18n} />
2018-11-14 19:10:32 +00:00
</div>
</div>
</div>
</div>
);
2018-11-14 19:10:32 +00:00
}