ui(components): New Dialog and Modal components for ui-next (#4772)

Co-authored-by: sedghi <ar.sedghi@gmail.com>
This commit is contained in:
Dan Rukasandsedghi authored and GitHub committed 2025-02-28 15:17:55 -05:00
1 parent 62b4fa3e89
commit a3b51aa8db
90 files changed
+3459 -1357

No files matched your search

@@ -0,0 +1,44 @@
import React from 'react';
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '../Dialog';
import { cn } from '../../lib/utils';
export interface ModalProps {
isOpen: boolean;
onClose: () => void;
title?: string;
children: React.ReactNode;
contentClassName?: string;
shouldCloseOnEsc?: boolean;
shouldCloseOnOverlayClick?: boolean;
containerClassName?: string;
}
const Modal: React.FC<ModalProps> = ({
isOpen,
onClose,
title,
children,
shouldCloseOnEsc = true,
shouldCloseOnOverlayClick = true,
containerClassName,
}) => {
return (
<Dialog
open={isOpen}
onOpenChange={open => !open && onClose()}
shouldCloseOnEsc={shouldCloseOnEsc}
shouldCloseOnOverlayClick={shouldCloseOnOverlayClick}
>
<DialogContent className={containerClassName}>
{title && (
<DialogHeader>
<DialogTitle>{title}</DialogTitle>
</DialogHeader>
)}
<div className={cn('mt-2')}>{children}</div>
</DialogContent>
</Dialog>
);
};
export default Modal;