-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathModals.tsx
More file actions
83 lines (78 loc) · 2.56 KB
/
Modals.tsx
File metadata and controls
83 lines (78 loc) · 2.56 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
82
83
import React, { useState } from 'react';
import { BasicModal, Button, Checkbox } from '@deephaven/components';
import SampleSection from './SampleSection';
function Modals(): React.ReactElement {
const [openModal, setOpenModal] = useState<number>(0);
const [check1, setCheck1] = useState<boolean>(true);
const closeModals = (): void => {
setOpenModal(0);
};
function renderBasicModal(buttonCount: number): JSX.Element {
return (
<React.Fragment key={buttonCount}>
<Button
kind="primary"
style={{ marginBottom: '1rem', marginRight: '1rem' }}
onClick={() => {
setOpenModal(buttonCount);
}}
>
{buttonCount} {buttonCount > 1 ? 'Actions' : 'Action'}
</Button>
<BasicModal
isOpen={openModal === buttonCount}
headerText="Header Text"
bodyText="This is where the body text goes"
onConfirm={closeModals}
onCancel={buttonCount >= 2 ? closeModals : undefined}
onDiscard={buttonCount >= 3 ? closeModals : undefined}
/>
</React.Fragment>
);
}
return (
<SampleSection name="modals">
<h2 className="ui-title">Basic Modals</h2>
<div style={{ padding: '1rem' }}>
{[1, 2, 3].map(buttonCount => renderBasicModal(buttonCount))}
</div>
<h2 className="ui-title">Custom Modal</h2>
<div style={{ padding: '1rem' }}>
<div className="modal-dialog" role="dialog">
<div className="modal-content">
<div className="modal-header">
<h5 className="modal-title">Modal title</h5>
<button
type="button"
className="close"
data-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true">×</span>
</button>
</div>
<div className="modal-body">
<p>Modal body text goes here.</p>
<Checkbox checked={check1} onChange={() => setCheck1(!check1)}>
Checked checkbox
</Checkbox>
</div>
<div className="modal-footer">
<Button
kind="secondary"
data-dismiss="modal"
onClick={() => undefined}
>
Close
</Button>
<Button kind="primary" onClick={() => undefined}>
Save changes
</Button>
</div>
</div>
</div>
</div>
</SampleSection>
);
}
export default Modals;