forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReactModalExample.js
More file actions
81 lines (74 loc) · 2.75 KB
/
Copy pathReactModalExample.js
File metadata and controls
81 lines (74 loc) · 2.75 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
73
74
75
76
77
78
79
80
81
import React from 'react'
import Modal from 'react-modal'
const modalOverrides = {
overlay : {
backgroundColor: 'rgba(0,0,0,0.5)'
},
content : {
position: 'static',
top: '0',
left: '0',
right: 'auto',
bottom: 'auto',
borderRadius: '0',
border: 'none',
padding: '0'
}
};
var ReactModalExample = React.createClass({
getInitialState() {
return {
modalIsOpen: false
}
},
openModal() {
this.setState({modalIsOpen: true});
},
closeModal() {
this.setState({modalIsOpen: false});
},
handleSubmit(e) {
e.preventDefault();
this.setState({modalIsOpen: false});
alert('Submitted');
},
render() {
return (
<div className="ReactModalExample">
<button type="button" className="btn btn-primary" onClick={this.openModal}>{this.props.label || 'Trigger Modal'}</button>
<Modal isOpen={this.state.modalIsOpen}
onRequestClose={this.closeModal}
className={this.props.className}
overlayClassName={this.props.overlayClassName}
style={modalOverrides}>
<div className="ReactModal__Layout">
<div className="ReactModal__Header">
<div className="ReactModal__Header-Title">
<h4>Modal Title Goes Here</h4>
</div>
<div className="ReactModal__Header-Actions">
<button className="Button Button--icon-action" type="button" onClick={this.closeModal}>
<i className="icon-x"></i>
<span className="screenreader-only">Close</span>
</button>
</div>
</div>
<div className="ReactModal__Body">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus deserunt doloremque, explicabo illo
ipsum libero magni odio officia optio perferendis ratione repellat suscipit tempore. Commodi hic sed.
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus deserunt doloremque, explicabo illo
ipsum libero magni odio officia optio perferendis ratione repellat suscipit tempore. Commodi hic sed.
</div>
<div className="ReactModal__Footer">
<div className="ReactModal__Footer-Actions">
<button type="button" className="btn btn-default" onClick={this.closeModal}>Cancel</button>
<button type="submit" className="btn btn-primary" onClick={this.handleSubmit}>Submit</button>
</div>
</div>
</div>
</Modal>
</div>
);
}
});
export default ReactModalExample