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

74 lines
1.7 KiB
TypeScript
Raw Normal View History

2021-04-21 16:31:12 +00:00
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { ReactNode } from 'react';
import React from 'react';
2021-04-21 16:31:12 +00:00
import type { LocalizerType } from '../../types/Util';
2021-04-21 16:31:12 +00:00
const CLASS_NAME = 'module-TimelineWarning';
const ICON_CONTAINER_CLASS_NAME = `${CLASS_NAME}__icon-container`;
const GENERIC_ICON_CLASS_NAME = `${CLASS_NAME}__generic-icon`;
const TEXT_CLASS_NAME = `${CLASS_NAME}__text`;
const LINK_CLASS_NAME = `${TEXT_CLASS_NAME}__link`;
const CLOSE_BUTTON_CLASS_NAME = `${CLASS_NAME}__close-button`;
type PropsType = {
children: ReactNode;
i18n: LocalizerType;
onClose: () => void;
};
export function TimelineWarning({
children,
i18n,
onClose,
}: Readonly<PropsType>): JSX.Element {
return (
<div className={CLASS_NAME}>
{children}
<button
aria-label={i18n('close')}
className={CLOSE_BUTTON_CLASS_NAME}
onClick={onClose}
type="button"
/>
</div>
);
}
2022-11-18 00:45:19 +00:00
function IconContainer({
2021-04-21 16:31:12 +00:00
children,
2022-11-18 00:45:19 +00:00
}: Readonly<{ children: ReactNode }>): JSX.Element {
return <div className={ICON_CONTAINER_CLASS_NAME}>{children}</div>;
}
2021-04-21 16:31:12 +00:00
2022-11-18 00:45:19 +00:00
TimelineWarning.IconContainer = IconContainer;
2021-04-21 16:31:12 +00:00
2022-11-18 00:45:19 +00:00
function GenericIcon() {
return <div className={GENERIC_ICON_CLASS_NAME} />;
}
TimelineWarning.GenericIcon = GenericIcon;
function Text({ children }: Readonly<{ children: ReactNode }>): JSX.Element {
return <div className={TEXT_CLASS_NAME}>{children}</div>;
}
TimelineWarning.Text = Text;
2021-04-21 16:31:12 +00:00
type LinkProps = {
children: ReactNode;
onClick: () => void;
};
2022-11-18 00:45:19 +00:00
function Link({ children, onClick }: Readonly<LinkProps>): JSX.Element {
return (
<button className={LINK_CLASS_NAME} onClick={onClick} type="button">
{children}
</button>
);
}
TimelineWarning.Link = Link;