forked from davidtheclark/react-aria-modal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo-two.js
85 lines (77 loc) · 2.55 KB
/
demo-two.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
const React = require('react');
const ReactDOM = require('react-dom');
const AriaModal = require('../../src/react-aria-modal');
class DemoTwo extends React.Component {
constructor(props) {
super(props);
this.state = {
modalActive: false
};
this.activateModal = this.activateModal.bind(this);
this.deactivateModal = this.deactivateModal.bind(this);
}
activateModal = () => {
this.setState({ modalActive: true });
};
deactivateModal = () => {
this.setState({ modalActive: false });
};
render() {
const modal = this.state.modalActive
? <AriaModal
titleId="demo-two-title"
onExit={this.deactivateModal}
underlayClickExits={false}
verticallyCenter={true}
>
<div id="demo-two-modal" className="modal">
<header className="modal-header">
<h2 id="demo-two-title" className="modal-title">
This modal has a title
</h2>
</header>
<div className="modal-body">
<p>
Here is a modal
{' '}
<a href="#">with</a>
{' '}
<a href="#">some</a>
{' '}
<a href="#">focusable</a>
{' '}
parts.
</p>
<div style={{ height: 200, overflow: 'scroll' }}>
<h3>
Internally Scrolling Region
</h3>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt
mollit anim id est laborum.
</p>
</div>
</div>
<footer className="modal-footer">
<button id="demo-two-deactivate" onClick={this.deactivateModal}>
deactivate modal
</button>
</footer>
</div>
</AriaModal>
: false;
return (
<div>
<button onClick={this.activateModal}>
activate modal
</button>
{modal}
</div>
);
}
}
ReactDOM.render(<DemoTwo />, document.getElementById('demo-two'));