signal-desktop/ts/components/GlobalModalContainer.tsx

54 lines
1.1 KiB
TypeScript
Raw Normal View History

2021-05-28 16:15:17 +00:00
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React from 'react';
import { Modal } from './Modal';
import { LocalizerType } from '../types/Util';
type PropsType = {
i18n: LocalizerType;
2021-07-19 19:26:06 +00:00
// ChatColorPicker
2021-05-28 16:15:17 +00:00
isChatColorEditorVisible: boolean;
2021-06-03 21:34:36 +00:00
renderChatColorPicker: () => JSX.Element;
2021-05-28 16:15:17 +00:00
toggleChatColorEditor: () => unknown;
2021-07-19 19:26:06 +00:00
// ProfileEditor
isProfileEditorVisible: boolean;
renderProfileEditor: () => JSX.Element;
2021-05-28 16:15:17 +00:00
};
export const GlobalModalContainer = ({
i18n,
2021-07-19 19:26:06 +00:00
// ChatColorPicker
2021-05-28 16:15:17 +00:00
isChatColorEditorVisible,
renderChatColorPicker,
toggleChatColorEditor,
2021-07-19 19:26:06 +00:00
// ProfileEditor
isProfileEditorVisible,
renderProfileEditor,
2021-05-28 16:15:17 +00:00
}: PropsType): JSX.Element | null => {
if (isChatColorEditorVisible) {
return (
<Modal
hasXButton
i18n={i18n}
2021-06-01 23:37:12 +00:00
moduleClassName="ChatColorPicker__modal"
2021-05-28 16:15:17 +00:00
noMouseClose
onClose={toggleChatColorEditor}
title={i18n('ChatColorPicker__global-chat-color')}
>
2021-06-03 21:34:36 +00:00
{renderChatColorPicker()}
2021-05-28 16:15:17 +00:00
</Modal>
);
}
2021-07-19 19:26:06 +00:00
if (isProfileEditorVisible) {
return renderProfileEditor();
}
2021-05-28 16:15:17 +00:00
return null;
};