-
Notifications
You must be signed in to change notification settings - Fork 96
/
demo-six.js
85 lines (75 loc) · 2.18 KB
/
demo-six.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 { createRoot } = require('react-dom/client');
const AriaModal = require('../../src/react-aria-modal');
class DemoSix extends React.Component {
constructor(props) {
super(props);
this.state = {
modalActive: false
};
this.activateModal = this.activateModal.bind(this);
this.deactivateModal = this.deactivateModal.bind(this);
this.getApplicationNode = this.getApplicationNode.bind(this);
}
activateModal = () => {
this.setState({ modalActive: true });
};
deactivateModal = () => {
this.setState({ modalActive: false });
};
getApplicationNode = () => {
return document.getElementById('application');
};
render() {
const AlternateLocationAriaModal = AriaModal.renderTo(
'#demo-six-container'
);
const modal = this.state.modalActive
? <AlternateLocationAriaModal
titleText="demo six"
onExit={this.deactivateModal}
initialFocus="#demo-six-deactivate"
getApplicationNode={this.getApplicationNode}
underlayProps={{
'data-foo': 'foo'
}}
underlayStyle={{
zIndex: 100,
background: 'rgba(255, 192, 203, 0.5)',
position: 'absolute',
paddingTop: '4em'
}}
>
<div id="demo-six-modal" className="modal">
<div className="modal-body">
<p>
Here is a modal
{' '}
<a href="#">with</a>
{' '}
<a href="#">some</a>
{' '}
<a href="#">focusable</a>
{' '}
parts.
</p>
</div>
<footer className="modal-footer">
<button id="demo-six-deactivate" onClick={this.deactivateModal}>
deactivate modal
</button>
</footer>
</div>
</AlternateLocationAriaModal>
: false;
return (
<div>
<button onClick={this.activateModal}>
activate modal
</button>
{modal}
</div>
);
}
}
createRoot(document.getElementById('demo-six')).render(<DemoSix/>);