2022-03-09 14:59:24 +01:00
|
|
|
import { ReactNode } from 'react';
|
2022-05-02 15:52:41 +02:00
|
|
|
import { Modal, Backdrop } from '@mui/material';
|
|
|
|
import Fade from '@mui/material/Fade';
|
2022-03-09 14:59:24 +01:00
|
|
|
import { useStyles } from 'component/common/SidebarModal/SidebarModal.styles';
|
2022-04-01 10:28:15 +02:00
|
|
|
import { SIDEBAR_MODAL_ID } from 'utils/testIds';
|
2022-03-09 14:59:24 +01:00
|
|
|
|
|
|
|
interface ISidebarModalProps {
|
|
|
|
open: boolean;
|
|
|
|
onClose: () => void;
|
|
|
|
label: string;
|
|
|
|
children: ReactNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
const TRANSITION_DURATION = 250;
|
|
|
|
|
|
|
|
export const SidebarModal = ({
|
|
|
|
open,
|
|
|
|
onClose,
|
|
|
|
label,
|
|
|
|
children,
|
|
|
|
}: ISidebarModalProps) => {
|
2022-05-02 15:52:41 +02:00
|
|
|
const { classes: styles } = useStyles();
|
2022-03-09 14:59:24 +01:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Modal
|
|
|
|
open={open}
|
|
|
|
onClose={onClose}
|
|
|
|
closeAfterTransition
|
|
|
|
aria-label={label}
|
|
|
|
BackdropComponent={Backdrop}
|
|
|
|
BackdropProps={{ timeout: TRANSITION_DURATION }}
|
2022-04-08 13:13:45 +02:00
|
|
|
data-testid={SIDEBAR_MODAL_ID}
|
2022-03-09 14:59:24 +01:00
|
|
|
>
|
|
|
|
<Fade timeout={TRANSITION_DURATION} in={open}>
|
|
|
|
<div className={styles.modal}>{children}</div>
|
|
|
|
</Fade>
|
|
|
|
</Modal>
|
|
|
|
);
|
|
|
|
};
|