Repository navigation
Expand file tree
/
Copy pathDialog.jsx
More file actions
68 lines (64 loc) · 2.23 KB
/
Copy pathDialog.jsx
File metadata and controls
68 lines (64 loc) · 2.23 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
import PropTypes from 'prop-types';
import ReactModal from 'react-modal';
import { ClipLoader as Loader } from 'react-spinners';
const Dialog = (props) => (
<ReactModal
isOpen={props.isOpen}
contentLabel="Modal"
ariaHideApp={false}
overlayClassName="ReactModal__Overlay react-modal-overlay p-4 flex"
className={`ReactModal__Content dialog mx-auto my-0 flex flex-col self-center bg-primary-100 overflow-hidden max-h-full transition p-4 ${props.className}`}
>
{props.isLoading ? (
<div className="flex">
<Loader size={14} color="currentColor" />
{props.loadingText && <div className="ml-4">{props.loadingText}</div>}
</div>
) : (
<>
<div className="py-4 leading-normal">{props.text}</div>
<div className="flex justify-center">
{props.onCancel && (
<button type="button" className="btn btn-base" onClick={props.onCancel}>
{props.cancelText}
</button>
)}
{props.onConfirm && (
<button
type="button"
className={`btn btn-success ml-4 ${
props.isDestructive ? 'btn-alert' : 'btn-success'
}`}
onClick={props.onConfirm}
>
{props.confirmText}
</button>
)}
</div>
</>
)}
</ReactModal>
);
Dialog.propTypes = {
className: PropTypes.string,
isOpen: PropTypes.bool.isRequired,
text: PropTypes.string.isRequired,
onCancel: PropTypes.func,
cancelText: PropTypes.string,
onConfirm: PropTypes.func,
confirmText: PropTypes.string,
isDestructive: PropTypes.bool,
isLoading: PropTypes.bool,
loadingText: PropTypes.string,
};
Dialog.defaultProps = {
className: '',
onCancel: null,
cancelText: 'Cancel',
onConfirm: null,
confirmText: 'Confirm',
isDestructive: false,
isLoading: false,
loadingText: null,
};
export default Dialog;