-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathdemo.tsx
55 lines (51 loc) · 1.36 KB
/
demo.tsx
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
import { overlay } from 'overlay-kit';
import { useState } from 'react';
import { Modal } from './components/modal.tsx';
export function Demo() {
return (
<div>
<DemoWithState />
<DemoWithEsOverlay />
</div>
);
}
function DemoWithState() {
const [isOpen, setIsOpen] = useState(false);
return (
<div>
<p>Demo with useState</p>
<button onClick={() => setIsOpen(true)}>open modal</button>
<Modal isOpen={isOpen}>
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center' }}>
<p>MODAL CONTENT</p>
<button onClick={() => setIsOpen(false)}>close modal</button>
</div>
</Modal>
</div>
);
}
function DemoWithEsOverlay() {
return (
<div>
<p>Demo with overlay-kit</p>
<button
onClick={() => {
overlay.open(({ isOpen, close, unmount }) => {
return (
<Modal isOpen={isOpen} onExit={unmount}>
<div
style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center' }}
>
<p>MODAL CONTENT</p>
<button onClick={close}>close modal</button>
</div>
</Modal>
);
});
}}
>
open modal
</button>
</div>
);
}