signal-desktop/ts/components/ContactPill.tsx

85 lines
1.9 KiB
TypeScript
Raw Normal View History

2021-03-03 20:09:58 +00:00
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React, { FunctionComponent } from 'react';
import { ConversationType } from '../state/ducks/conversations';
2021-03-03 20:09:58 +00:00
import { LocalizerType } from '../types/Util';
import { ContactName } from './conversation/ContactName';
import { Avatar, AvatarSize } from './Avatar';
export type PropsType = {
i18n: LocalizerType;
onClickRemove: (id: string) => void;
} & Pick<
ConversationType,
| 'about'
| 'acceptedMessageRequest'
| 'avatarPath'
| 'color'
| 'firstName'
| 'id'
| 'isMe'
| 'name'
| 'phoneNumber'
| 'profileName'
| 'sharedGroupNames'
| 'title'
| 'unblurredAvatarPath'
>;
2021-03-03 20:09:58 +00:00
export const ContactPill: FunctionComponent<PropsType> = ({
acceptedMessageRequest,
2021-03-03 20:09:58 +00:00
avatarPath,
color,
firstName,
i18n,
2021-05-07 22:21:10 +00:00
isMe,
2021-03-03 20:09:58 +00:00
id,
name,
phoneNumber,
profileName,
sharedGroupNames,
2021-03-03 20:09:58 +00:00
title,
unblurredAvatarPath,
2021-03-03 20:09:58 +00:00
onClickRemove,
}) => {
const removeLabel = i18n('ContactPill--remove');
return (
<div className="module-ContactPill">
<Avatar
acceptedMessageRequest={acceptedMessageRequest}
2021-03-03 20:09:58 +00:00
avatarPath={avatarPath}
color={color}
noteToSelf={false}
conversationType="direct"
i18n={i18n}
2021-05-07 22:21:10 +00:00
isMe={isMe}
2021-03-03 20:09:58 +00:00
name={name}
phoneNumber={phoneNumber}
profileName={profileName}
title={title}
sharedGroupNames={sharedGroupNames}
2021-03-03 20:09:58 +00:00
size={AvatarSize.TWENTY_EIGHT}
unblurredAvatarPath={unblurredAvatarPath}
2021-03-03 20:09:58 +00:00
/>
<ContactName
firstName={firstName}
module="module-ContactPill__contact-name"
preferFirstName
title={title}
/>
<button
aria-label={removeLabel}
className="module-ContactPill__remove"
onClick={() => {
onClickRemove(id);
}}
title={removeLabel}
type="button"
/>
</div>
);
};