import * as DialogPrimitives from '@radix-ui/react-dialog'; import classNames from 'classnames'; import type { ReactNode } from 'react'; import type { Intent } from '../../utils/intent'; import { getIntentShadow, getIntentBorder } from '../../utils/intent'; import { Icon } from '../icon'; interface DialogProps { children: ReactNode; open: boolean; onChange?: (isOpen: boolean) => void; title?: string; intent?: Intent; titleClassNames?: string; contentClassNames?: string; } export function Dialog({ children, open, onChange, title, intent, titleClassNames, contentClassNames, }: DialogProps) { const contentClasses = classNames( // Positions the modal in the center of screen 'z-20 fixed w-full md:w-[720px] lg:w-[940px] px-28 py-24 top-[50%] left-[50%] translate-x-[-50%] translate-y-[-50%]', // Need to apply background and text colors again as content is rendered in a portal 'dark:bg-black dark:text-white-95 bg-white text-black-95', getIntentShadow(intent), getIntentBorder(intent), contentClassNames ); return ( onChange?.(x)}> {title && (

{title}

)} {children}
); }