refactor: move component into a single package (#898)

This commit is contained in:
Himself65
2023-02-08 22:19:11 -06:00
committed by GitHub
parent 0984c37cad
commit cc605251a8
145 changed files with 9609 additions and 450 deletions
+52
View File
@@ -0,0 +1,52 @@
import Fade from '@mui/material/Fade';
import { StyledModal, StyledBackdrop } from './styles';
import { ModalUnstyledOwnProps } from '@mui/base/ModalUnstyled';
const Backdrop = ({
open,
...other
}: {
open?: boolean;
className: string;
}) => {
return (
<Fade in={open}>
<StyledBackdrop {...other} />
</Fade>
);
};
export type ModalProps = {
wrapperPosition?: ['top' | 'bottom' | 'center', 'left' | 'right' | 'center'];
} & ModalUnstyledOwnProps;
const transformConfig = {
top: 'flex-start',
bottom: 'flex-end',
center: 'center',
left: 'flex-start',
right: 'flex-end',
};
export const Modal = (props: ModalProps) => {
const {
wrapperPosition = ['center', 'center'],
open,
children,
...otherProps
} = props;
const [vertical, horizontal] = wrapperPosition;
return (
<StyledModal
{...otherProps}
open={open}
components={{ Backdrop }}
alignItems={transformConfig[vertical]}
justifyContent={transformConfig[horizontal]}
>
<Fade in={open}>{children}</Fade>
</StyledModal>
);
};
export default Modal;