2021-04-05 17:44:13 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
2021-01-29 21:19:24 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import React from 'react';
|
2021-04-05 17:44:13 +00:00
|
|
|
import classNames from 'classnames';
|
2021-01-29 21:19:24 +00:00
|
|
|
|
|
|
|
import { bemGenerator } from './util';
|
|
|
|
|
2021-10-20 23:46:41 +00:00
|
|
|
export enum IconType {
|
|
|
|
'block' = 'block',
|
|
|
|
'color' = 'color',
|
|
|
|
'down' = 'down',
|
|
|
|
'invites' = 'invites',
|
|
|
|
'leave' = 'leave',
|
|
|
|
'link' = 'link',
|
|
|
|
'lock' = 'lock',
|
|
|
|
'mention' = 'mention',
|
|
|
|
'mute' = 'mute',
|
|
|
|
'notifications' = 'notifications',
|
|
|
|
'reset' = 'reset',
|
|
|
|
'share' = 'share',
|
|
|
|
'timer' = 'timer',
|
|
|
|
'trash' = 'trash',
|
|
|
|
'verify' = 'verify',
|
|
|
|
}
|
|
|
|
|
2021-01-29 21:19:24 +00:00
|
|
|
export type Props = {
|
|
|
|
ariaLabel: string;
|
2021-04-05 17:44:13 +00:00
|
|
|
disabled?: boolean;
|
2021-10-20 23:46:41 +00:00
|
|
|
icon: IconType;
|
2021-01-29 21:19:24 +00:00
|
|
|
onClick?: () => void;
|
|
|
|
};
|
|
|
|
|
2021-10-20 23:46:41 +00:00
|
|
|
const bem = bemGenerator('ConversationDetails-icon');
|
2021-01-29 21:19:24 +00:00
|
|
|
|
|
|
|
export const ConversationDetailsIcon: React.ComponentType<Props> = ({
|
|
|
|
ariaLabel,
|
2021-04-05 17:44:13 +00:00
|
|
|
disabled,
|
2021-01-29 21:19:24 +00:00
|
|
|
icon,
|
|
|
|
onClick,
|
|
|
|
}) => {
|
2021-04-05 17:44:13 +00:00
|
|
|
const iconClassName = bem('icon', icon);
|
|
|
|
const content = (
|
|
|
|
<div
|
|
|
|
className={classNames(
|
|
|
|
iconClassName,
|
|
|
|
disabled && `${iconClassName}--disabled`
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
);
|
2021-01-29 21:19:24 +00:00
|
|
|
|
|
|
|
if (onClick) {
|
|
|
|
return (
|
|
|
|
<button
|
|
|
|
aria-label={ariaLabel}
|
|
|
|
className={bem('button')}
|
2021-04-05 17:44:13 +00:00
|
|
|
disabled={disabled}
|
2021-01-29 21:19:24 +00:00
|
|
|
type="button"
|
|
|
|
onClick={onClick}
|
|
|
|
>
|
|
|
|
{content}
|
|
|
|
</button>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return content;
|
|
|
|
};
|