All files / src/components/common/Modal/ModalFactory/variants PopupVariant.tsx

100% Statements 4/4
80% Branches 4/5
100% Functions 2/2
100% Lines 3/3

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                              37x               76x                       76x                          
import AnimatedDialog, { BaseModalProps } from "../atoms/AnimatedDialog";
import { SxProps, styled } from "@mui/material";
import ErrorCatcher from "@common/Error/ErrorCatcher";
import { palette } from "@palette";
 
export type PopupVariantProps = {
  open: boolean;
  onClose: () => void;
  sx?: SxProps;
  children: React.ReactNode;
  width?: number | string;
  showMobileView?: boolean;
  PopupProps?: Omit<BaseModalProps, "onClose" | "open">;
};
 
const PopupVariant = ({
  onClose,
  children,
  width,
  showMobileView = false,
  PopupProps,
  ...rest
}: PopupVariantProps) => {
  return (
    <StyledPopup
      width={showMobileView ? "90vw" : width || "500px"}
      onClose={onClose}
      {...PopupProps}
      {...rest}
    >
      <ErrorCatcher errorID="animated-dialog">{children}</ErrorCatcher>
    </StyledPopup>
  );
};
 
const StyledPopup = styled(AnimatedDialog)(() => ({
  "& .MuiDialog-paper": {
    borderRadius: "12px",
    background: palette.background.dimmedWhite,
    boxShadow: "0px 60px 180px 0px rgba(0, 0, 0, 0.15)",
    backdropFilter: "20px",
    overflow: "hidden",
    height: "fit-content",
    maxHeight: "76%",
  },
}));
 
export default PopupVariant;