This commit is contained in:
2024-10-15 21:37:55 +00:00
parent e677a45ecd
commit 7302b27dc3
10 changed files with 233 additions and 28 deletions

View File

@@ -0,0 +1,49 @@
"use client";
import React from "react";
interface PopupProps extends React.HTMLAttributes<HTMLDivElement> {
show?: boolean;
title?: string;
children: React.ReactNode;
onClickClose?: React.MouseEventHandler<HTMLButtonElement>;
onClickOk?: React.MouseEventHandler<HTMLButtonElement>;
}
const Popup: React.FC<PopupProps> = ({
show = false,
title,
children,
...props
}) => {
if (!show) return null;
return (
<>
<div className="fixed top-0 left-0 w-full h-full bg-black opacity-75 z-10"></div>
<div className="fixed top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 z-20">
<div className="bg-base-100 p-8 rounded-lg">
{title && (
<h2 className="text-xl font-bold mb-4 text-base-content">
{title}
</h2>
)}
{children}
<div className="flex justify-between">
<button onClick={props.onClickClose} className="btn btn-sm">
Close
</button>
<button
onClick={props.onClickOk}
className="btn btn-sm btn-success"
>
Ok
</button>
</div>
</div>
</div>
</>
);
};
export default Popup;