Files
prowler/ui/components/shadcn/modal/modal.tsx

68 lines
1.4 KiB
TypeScript

import { ReactNode } from "react";
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
} from "@/components/shadcn/dialog";
import { cn } from "@/lib/utils";
const SIZE_CLASSES = {
sm: "sm:max-w-sm",
md: "sm:max-w-md",
lg: "sm:max-w-lg",
xl: "sm:max-w-xl",
"2xl": "sm:max-w-2xl",
"3xl": "sm:max-w-3xl",
"4xl": "sm:max-w-4xl",
"5xl": "sm:max-w-5xl",
} as const;
type ModalSize = keyof typeof SIZE_CLASSES;
interface ModalProps {
open: boolean;
onOpenChange: (open: boolean) => void;
title?: string;
description?: string;
children: ReactNode;
size?: ModalSize;
className?: string;
}
export const Modal = ({
open,
onOpenChange,
title,
description,
children,
size = "xl",
className,
}: ModalProps) => {
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent
className={cn(
"border-border-neutral-secondary bg-bg-neutral-secondary",
SIZE_CLASSES[size],
className,
)}
>
{title && (
<DialogHeader>
<DialogTitle>{title}</DialogTitle>
{description && (
<DialogDescription className="text-small text-gray-600 dark:text-gray-300">
{description}
</DialogDescription>
)}
</DialogHeader>
)}
{children}
</DialogContent>
</Dialog>
);
};