All files / src/components/common/Modal/ModalDrawer ModalDrawer.tsx

30% Statements 3/10
0% Branches 0/8
0% Functions 0/3
37.5% Lines 3/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56              4x       4x                                                                       4x                
import { Drawer, styled } from "@mui/material";
import { palette } from "@palette";
import DrawerBody from "./ModalDrawerBody";
import { useModal } from "@ebay/nice-modal-react";
import { useCustomTheme } from "@theme/hooks/useCustomTheme";
import { ModalDrawerProps } from "./types";
 
const Body = (props: ModalDrawerProps) => (
  <DrawerBody {...props}>{props.children}</DrawerBody>
);
 
const ModalDrawer = (props: ModalDrawerProps) => {
  const modal = useModal();
  const { isDesktopView } = useCustomTheme();
 
  if (props.isBody) return <Body {...props} />;
 
  return (
    <DrawerContainer
      anchor="right"
      open={modal.visible}
      onClose={props.steps ? undefined : props.onModalClose}
      PaperProps={{
        style: {
          width: isDesktopView ? "600px" : "100%",
          background: palette.liftedWhite.main,
          boxShadow: isDesktopView
            ? "0px 10px 25px 0px rgba(103, 103, 103, 0.15)"
            : "none",
        },
      }}
      ModalProps={{
        onBackdropClick: props.onModalClose,
      }}
      slotProps={{
        backdrop: {
          sx: {
            background: "rgba(53, 53, 53, 0.10)",
          },
        },
      }}
    >
      <Body {...props} />
    </DrawerContainer>
  );
};
 
const DrawerContainer = styled(Drawer)(() => ({
  display: "flex",
  flexDirection: "column",
  alignItems: "flex-end",
  gap: "16px",
}));
 
export default ModalDrawer;