xtablo-source/apps/external/src/CustomModal.tsx

46 lines
1.2 KiB
TypeScript
Raw Normal View History

2025-10-23 09:54:45 +00:00
import { cn } from "@xtablo/shared";
2025-10-23 19:36:21 +00:00
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@xtablo/ui/components/dialog";
2025-10-14 20:27:17 +00:00
// Custom Modal Component - now using shadcn/ui Dialog
2025-09-15 07:01:08 +00:00
interface CustomModalProps {
isOpen: boolean;
onClose: () => void;
title: string;
children: React.ReactNode;
width?: "sm" | "md" | "lg" | "xl" | "2xl" | "full" | "auto";
2025-09-15 07:01:08 +00:00
}
2025-10-10 06:21:56 +00:00
export function CustomModal({ isOpen, onClose, title, children, width = "md" }: CustomModalProps) {
const getWidthClasses = () => {
switch (width) {
case "sm":
2025-10-14 20:27:17 +00:00
return "max-w-sm";
case "md":
2025-10-14 20:27:17 +00:00
return "max-w-md";
case "lg":
2025-10-14 20:27:17 +00:00
return "max-w-lg";
case "xl":
2025-10-14 20:27:17 +00:00
return "max-w-xl";
case "2xl":
2025-10-14 20:27:17 +00:00
return "max-w-2xl";
case "full":
2025-10-14 20:27:17 +00:00
return "max-w-full mx-4";
case "auto":
return "w-auto min-w-80 max-w-[90vw]";
default:
2025-10-14 20:27:17 +00:00
return "max-w-md";
}
};
2025-09-15 07:01:08 +00:00
return (
2025-10-14 20:27:17 +00:00
<Dialog open={isOpen} onOpenChange={onClose}>
<DialogContent className={cn("max-h-[90vh] flex flex-col", getWidthClasses())}>
<DialogHeader>
<DialogTitle>{title}</DialogTitle>
</DialogHeader>
<div className="overflow-y-auto flex-1">{children}</div>
</DialogContent>
</Dialog>
2025-09-15 07:01:08 +00:00
);
}