2021-01-29 21:19:24 +00:00
|
|
|
// Copyright 2020 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import classNames from 'classnames';
|
|
|
|
import { bemGenerator } from './util';
|
|
|
|
|
|
|
|
export type Props = {
|
|
|
|
alwaysShowActions?: boolean;
|
|
|
|
className?: string;
|
|
|
|
icon?: React.ReactNode;
|
2021-02-01 22:57:42 +00:00
|
|
|
label: string | React.ReactNode;
|
2021-01-29 21:19:24 +00:00
|
|
|
info?: string;
|
|
|
|
right?: string | React.ReactNode;
|
|
|
|
actions?: React.ReactNode;
|
|
|
|
onClick?: () => void;
|
|
|
|
};
|
|
|
|
|
|
|
|
const bem = bemGenerator('module-conversation-details-panel-row');
|
|
|
|
|
|
|
|
export const PanelRow: React.ComponentType<Props> = ({
|
|
|
|
alwaysShowActions,
|
|
|
|
className,
|
|
|
|
icon,
|
|
|
|
label,
|
|
|
|
info,
|
|
|
|
right,
|
|
|
|
actions,
|
|
|
|
onClick,
|
|
|
|
}) => {
|
|
|
|
const content = (
|
|
|
|
<>
|
2021-02-01 22:57:42 +00:00
|
|
|
{icon !== undefined ? <div className={bem('icon')}>{icon}</div> : null}
|
2021-01-29 21:19:24 +00:00
|
|
|
<div className={bem('label')}>
|
|
|
|
<div>{label}</div>
|
2021-02-01 22:57:42 +00:00
|
|
|
{info !== undefined ? <div className={bem('info')}>{info}</div> : null}
|
2021-01-29 21:19:24 +00:00
|
|
|
</div>
|
2021-02-01 22:57:42 +00:00
|
|
|
{right !== undefined ? <div className={bem('right')}>{right}</div> : null}
|
|
|
|
{actions !== undefined ? (
|
2021-01-29 21:19:24 +00:00
|
|
|
<div className={alwaysShowActions ? '' : bem('actions')}>{actions}</div>
|
2021-02-01 22:57:42 +00:00
|
|
|
) : null}
|
2021-01-29 21:19:24 +00:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
|
|
|
|
if (onClick) {
|
|
|
|
return (
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
className={classNames(bem('root', 'button'), className)}
|
|
|
|
onClick={onClick}
|
|
|
|
>
|
|
|
|
{content}
|
|
|
|
</button>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return <div className={classNames(bem('root'), className)}>{content}</div>;
|
|
|
|
};
|