2020-10-30 20:34:04 +00:00
|
|
|
// Copyright 2019-2020 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2019-12-17 20:25:57 +00:00
|
|
|
import * as React from 'react';
|
|
|
|
import * as styles from './ConfirmDialog.scss';
|
|
|
|
import { useI18n } from '../util/i18n';
|
|
|
|
|
|
|
|
export type Props = {
|
|
|
|
readonly title: string;
|
|
|
|
readonly children: React.ReactNode;
|
|
|
|
readonly confirm: string;
|
|
|
|
readonly onConfirm: () => unknown;
|
|
|
|
readonly cancel?: string;
|
|
|
|
readonly onCancel: () => unknown;
|
|
|
|
};
|
|
|
|
|
2020-09-14 21:56:35 +00:00
|
|
|
export const ConfirmDialog: React.ComponentType<Props> = ({
|
2019-12-17 20:25:57 +00:00
|
|
|
title,
|
|
|
|
children,
|
|
|
|
confirm,
|
|
|
|
cancel,
|
|
|
|
onConfirm,
|
|
|
|
onCancel,
|
2020-09-14 21:56:35 +00:00
|
|
|
}) => {
|
2019-12-17 20:25:57 +00:00
|
|
|
const i18n = useI18n();
|
|
|
|
const cancelText = cancel || i18n('StickerCreator--ConfirmDialog--cancel');
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={styles.base}>
|
|
|
|
<h1 className={styles.title}>{title}</h1>
|
|
|
|
<p className={styles.text}>{children}</p>
|
|
|
|
<div className={styles.bottom}>
|
2020-09-14 21:56:35 +00:00
|
|
|
<button type="button" className={styles.button} onClick={onCancel}>
|
2019-12-17 20:25:57 +00:00
|
|
|
{cancelText}
|
|
|
|
</button>
|
2020-09-14 21:56:35 +00:00
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
className={styles.buttonPrimary}
|
|
|
|
onClick={onConfirm}
|
|
|
|
>
|
2019-12-17 20:25:57 +00:00
|
|
|
{confirm}
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|