-
Notifications
You must be signed in to change notification settings - Fork 2
/
ModalFrontstage.tsx
82 lines (76 loc) · 2.85 KB
/
ModalFrontstage.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
* @module Frontstage
*/
import type { CommonProps } from "@itwin/core-react";
import { Icon } from "@itwin/core-react";
import { SvgProgressBackwardCircular } from "@itwin/itwinui-icons-react";
import { Text } from "@itwin/itwinui-react";
import classnames from "classnames";
import * as React from "react";
import { UiFramework } from "../UiFramework";
import { BackButton } from "../layout/widget/tools/button/Back";
import "./ModalFrontstage.scss";
/** Properties for the [[ModalFrontstage]] React component
* @public
*/
export interface ModalFrontstageProps extends CommonProps {
/** Title displayed at the top of the modal Frontstage */
title: string;
/** Indicates whether the modal Frontstage is open */
isOpen?: boolean;
/** Callback for navigating back from the modal Frontstage. This is normally connected to Redux. */
navigateBack?: () => any;
/** Callback for closing the modal Frontstage. This is normally connected to Redux. */
closeModal: () => any;
/** An optional React node displayed in the upper right of the modal Frontstage. */
appBarRight?: React.ReactNode;
/** Content */
children?: React.ReactNode;
}
/** ModalFrontstage React component
* @public
*/
export class ModalFrontstage extends React.Component<ModalFrontstageProps> {
constructor(props: ModalFrontstageProps) {
super(props);
}
private _onGoBack = () => {
if (this.props.navigateBack) this.props.navigateBack();
this.props.closeModal();
};
public override render() {
const classNames = classnames(
"uifw-modal-frontstage",
this.props.isOpen && "uifw-modal-open",
this.props.className
);
return (
<>
<div className={classNames} style={this.props.style}>
<div className="uifw-modal-app-bar">
<BackButton
className="nz-toolbar-button-app"
onClick={this._onGoBack}
icon={<Icon iconSpec={<SvgProgressBackwardCircular />} />}
title={UiFramework.translate("modalFrontstage.backButtonTitle")}
/>
<Text variant="headline" className="uifw-headline">
{this.props.title}
</Text>
{this.props.appBarRight && (
<span className="uifw-modal-app-bar-right">
{this.props.appBarRight}
</span>
)}
</div>
<div className="uifw-modal-stage-content">{this.props.children}</div>
</div>
<div className="uifw-modal-frontstage-overlay" />
</>
);
}
}