2020-05-22 15:29:53 +03:00
|
|
|
/*
|
2021-03-26 14:13:39 +03:00
|
|
|
Copyright 2020-2021 The Matrix.org Foundation C.I.C.
|
2020-05-22 15:29:53 +03:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2021-06-29 15:11:58 +03:00
|
|
|
import React, { ReactNode } from "react";
|
2021-06-21 16:16:37 +03:00
|
|
|
import AccessibleButton from "../elements/AccessibleButton";
|
2020-05-22 15:29:53 +03:00
|
|
|
|
2021-06-29 15:11:58 +03:00
|
|
|
import { XOR } from "../../../@types/common";
|
2020-05-22 15:29:53 +03:00
|
|
|
|
2020-06-29 13:38:50 +03:00
|
|
|
export interface IProps {
|
2020-07-03 01:15:08 +03:00
|
|
|
description: ReactNode;
|
2021-03-26 14:13:39 +03:00
|
|
|
detail?: ReactNode;
|
2020-05-22 15:29:53 +03:00
|
|
|
acceptLabel: string;
|
|
|
|
|
|
|
|
onAccept();
|
|
|
|
}
|
|
|
|
|
2020-05-29 21:13:59 +03:00
|
|
|
interface IPropsExtended extends IProps {
|
|
|
|
rejectLabel: string;
|
|
|
|
onReject();
|
|
|
|
}
|
|
|
|
|
2020-08-29 03:11:08 +03:00
|
|
|
const GenericToast: React.FC<XOR<IPropsExtended, IProps>> = ({
|
|
|
|
description,
|
2021-03-26 14:13:39 +03:00
|
|
|
detail,
|
2020-08-29 03:11:08 +03:00
|
|
|
acceptLabel,
|
|
|
|
rejectLabel,
|
|
|
|
onAccept,
|
|
|
|
onReject,
|
|
|
|
}) => {
|
2021-03-26 14:43:41 +03:00
|
|
|
const detailContent = detail ? <div className="mx_Toast_detail">
|
2021-03-26 14:13:39 +03:00
|
|
|
{detail}
|
2021-03-26 14:43:41 +03:00
|
|
|
</div> : null;
|
2021-03-26 14:13:39 +03:00
|
|
|
|
2020-05-22 15:29:53 +03:00
|
|
|
return <div>
|
|
|
|
<div className="mx_Toast_description">
|
2021-03-26 14:43:41 +03:00
|
|
|
{description}
|
|
|
|
{detailContent}
|
2020-05-22 15:29:53 +03:00
|
|
|
</div>
|
|
|
|
<div className="mx_Toast_buttons" aria-live="off">
|
2021-06-28 10:52:15 +03:00
|
|
|
{onReject && rejectLabel && <AccessibleButton kind="danger_outline" onClick={onReject}>
|
2021-06-22 12:06:31 +03:00
|
|
|
{ rejectLabel }
|
2021-06-21 16:16:37 +03:00
|
|
|
</AccessibleButton> }
|
|
|
|
<AccessibleButton onClick={onAccept} kind="primary">
|
2021-06-22 12:06:31 +03:00
|
|
|
{ acceptLabel }
|
2021-06-21 16:16:37 +03:00
|
|
|
</AccessibleButton>
|
2020-05-22 15:29:53 +03:00
|
|
|
</div>
|
|
|
|
</div>;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default GenericToast;
|