forked from firefox-devtools/debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModal.js
More file actions
72 lines (63 loc) · 1.57 KB
/
Modal.js
File metadata and controls
72 lines (63 loc) · 1.57 KB
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
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// @flow
import PropTypes from "prop-types";
import React from "react";
import type { Node as ReactNode } from "react";
import classnames from "classnames";
import Transition from "react-transition-group/Transition";
import "./Modal.css";
type ModalProps = {
status: string,
children?: ReactNode,
additionalClass?: string,
handleClose: () => any
};
export class Modal extends React.Component<ModalProps> {
onClick = (e: SyntheticEvent<HTMLElement>) => {
e.stopPropagation();
};
render() {
const { status } = this.props;
return (
<div className="modal-wrapper" onClick={this.props.handleClose}>
<div
className={classnames("modal", this.props.additionalClass, status)}
onClick={this.onClick}
>
{this.props.children}
</div>
</div>
);
}
}
Modal.contextTypes = {
shortcuts: PropTypes.object
};
type SlideProps = {
in: boolean,
children?: ReactNode,
additionalClass?: string,
handleClose: () => any
};
export default function Slide({
in: inProp,
children,
additionalClass,
handleClose
}: SlideProps) {
return (
<Transition in={inProp} timeout={175} appear>
{status => (
<Modal
status={status}
additionalClass={additionalClass}
handleClose={handleClose}
>
{children}
</Modal>
)}
</Transition>
);
}