aboutsummaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/components')
-rw-r--r--src/components/Button.tsx9
-rw-r--r--src/components/Dialog.tsx15
-rw-r--r--src/components/Modal.tsx55
3 files changed, 70 insertions, 9 deletions
diff --git a/src/components/Button.tsx b/src/components/Button.tsx
index 8d2d6db..90d44f6 100644
--- a/src/components/Button.tsx
+++ b/src/components/Button.tsx
@@ -15,19 +15,23 @@ type ButtonType = {
| "cyan"
| "";
disabled?: boolean;
+ onClick?: () => void;
+ className?: string;
};
const Button = ({
children,
- rounded = "none",
+ onClick = () => {},
+ rounded = "full",
size = "md",
color = "cyan",
disabled,
+ className,
}: ButtonType) => {
return (
<button
className={classNames(
- "border-black border-2 text-black",
+ "border-black border-2 text-black " + className,
{
"bg-violet-200 hover:bg-violet-300 active:bg-violet-400":
@@ -68,6 +72,7 @@ const Button = ({
disabled,
}
)}
+ onClick={onClick}
disabled={disabled}
>
{children}
diff --git a/src/components/Dialog.tsx b/src/components/Dialog.tsx
index 0258e88..b10ed5f 100644
--- a/src/components/Dialog.tsx
+++ b/src/components/Dialog.tsx
@@ -3,7 +3,7 @@ import Button from "./Button";
import classNames from "classnames";
type DialogType = {
- message: string;
+ children?: React.ReactNode;
width?: "fit" | "full" | "1/2" | "1/3";
cancelButtonText?: string;
actionButtonText?: string;
@@ -18,7 +18,7 @@ type DialogType = {
};
const Dialog = ({
- message,
+ children,
width,
cancelButtonText,
actionButtonText,
@@ -27,25 +27,26 @@ const Dialog = ({
return (
<div
className={classNames(
- "px-8 py-4 dark:bg-slate-850 bg-white border-4 border-black shadow-[8px_8px_0px_rgba(0,0,0,1)] grid place-content-center",
+ "p-9 dark:bg-slate-850 bg-white border-4 border-black shadow-[8px_8px_0px_rgba(0,0,0,1)] grid place-content-center",
{ "w-fit": width === "fit" },
{ "w-full": width === "full" },
{ "w-1/2": width === "1/2" },
{ "w-1/3": width === "1/3" }
)}
>
- <div>
- <h1 className="text-2xl mb-4">{message}</h1>
+ <div className="flex flex-col gap-4">
+ {children}
<div className="flex space-x-2 mx-auto">
{cancelButtonText && (
<button className="text-base">{cancelButtonText}</button>
)}
{actionButtonText && (
<Button
- buttonText={actionButtonText}
rounded="full"
color={actionButtonColor && actionButtonColor}
- />
+ >
+ <h3>{actionButtonText}</h3>
+ </Button>
)}
</div>
</div>
diff --git a/src/components/Modal.tsx b/src/components/Modal.tsx
new file mode 100644
index 0000000..55ad174
--- /dev/null
+++ b/src/components/Modal.tsx
@@ -0,0 +1,55 @@
+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">
+ <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>
+ )
+ );
+}