blob: 80d482e1b08c885dfa2f08e2afdd5aa9254c07ad (
plain)
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
|
import React from "react";
import Button from "./Button";
export interface ModalProps {
title: string | React.ReactNode;
children: React.ReactNode;
open: boolean;
okText?: string;
cancelText?: string;
onOk?: () => void;
onCancel?: () => void;
}
export default function Modal({
title,
children,
open,
okText = "OK",
cancelText,
onOk = () => {},
onCancel = () => {},
}: ModalProps) {
return (
open && (
<div
className="z-999 fixed left-0 top-0 flex h-full w-full items-center justify-center bg-black bg-opacity-50 py-10"
onClick={() => onOk()}
>
<div className="max-h-full w-full max-w-xl overflow-y-auto sm:rounded-2xl bg-white">
<div className="w-full">
<div className="mx-auto my-20 max-w-[400px] flex flex-col gap-5">
<h1 className="text-5xl font-extrabold text-center">{title}</h1>
<div className="text-xl leading-relaxed text-center">
{children}
</div>
<div className="flex flex-row items-stretch gap-4">
{cancelText && (
<Button
color="red"
className="grow"
onClick={() => onCancel()}
>
<h3>{cancelText}</h3>
</Button>
)}
{okText && (
<Button className="grow" onClick={() => onOk()}>
<h3>{okText}</h3>
</Button>
)}
</div>
</div>
</div>
</div>
</div>
)
);
}
|