import Dialog, { DialogProps } from '@mui/material/Dialog'; import DialogContent, { DialogContentProps } from '@mui/material/DialogContent'; import DialogTitle, { DialogTitleProps } from '@mui/material/DialogTitle'; import Grid from '@mui/material/Grid'; import IconButton from '@mui/material/IconButton'; import CloseIcon from '@mui/icons-material/Close'; import { memo, ReactNode } from 'react'; import css from './Modal.module.scss'; export interface ModalQAs { /** Data-qa applied to the main modal */ modal?: string; /** Data-qa applied to the title */ title?: string; /** Data-qa applied to the content */ content?: string; } export interface ModalProps { /** Whether the modal should be opened or not */ open: boolean; /** The content to show in the modal */ dialogContent: JSX.Element; /** Title for the modal */ topic: string | ReactNode; /** Any othe props passed to the Dialog */ DialogProps?: DialogProps; /** Any other props passed to the DialogContent */ DialogContentProps?: DialogContentProps; /** Any other props passed to the DialogTitle */ DialogTitleProps?: DialogTitleProps; /** Object of data-qa tags to pass to the modal */ modalqas?: ModalQAs; /** The action to trigger to close this modal */ closeAction(): void; } /** * Constructs a modal using pre-defined Rijkswaterstaat styling * @param props Props to pass to the modal - {@link ModalProps} * @example * ```jsx * SAMPLE} * open={true} * /> * ``` */ export const Modal = memo(({ DialogContentProps, DialogTitleProps, DialogProps, ...props }: ModalProps) => { return ( { if (reason !== 'backdropClick') { props.closeAction(); } }} > {props.topic} {props.dialogContent} ); });