This repository has been archived by the owner on Jul 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Modal.js
64 lines (53 loc) · 1.67 KB
/
Modal.js
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
'use strict';
import React, {Component, PropTypes} from 'react';
import classnames from 'classnames';
class Modal extends Component {
constructor(props) {
super(props);
}
handleOnOutsideClick() {
if (this.props.options.closeOnOutsideClick || false) {
this.props.removeModal(this.props.id);
}
}
render() {
return (
<div className="rrm-holder"
style={{zIndex: `999${this.props.index}`}}
onClick={this.handleOnOutsideClick.bind(this)}>
<div className="scroll">
<div className={classnames('rrm-content', `m-${this.props.options.size}` || 'm-medium')}>
<div className="rrm-title">
<h2>{this.props.options.title}</h2>
<div className="rr-title-actions">
{this.props.options.hideCloseButton ? null :
<button
type="button"
className="rr-close rrm-icon-cancel"
onClick={this.props.removeModal.bind(this, this.props.id)}>X</button>
}
</div>
</div>
<div className="rrm-body">
<this.props.component {...this.props.options} removeModal={() => this.props.removeModal(this.props.id)}/>
</div>
</div>
</div>
<div className="rrm-shadow"></div>
</div>
);
}
}
Modal.displayName = 'rrModal';
Modal.propTypes = {
id: PropTypes.string,
index: PropTypes.number,
removeModal: PropTypes.func.isRequired,
options: PropTypes.shape({
size: PropTypes.string,
title: PropTypes.string,
hideCloseButton: PropTypes.bool,
closeOnOutsideClick: PropTypes.bool
}).isRequired
};
export default Modal;