All files / src/shared/SideMenu GiveSideMenu.tsx

77.77% Statements 7/9
33.33% Branches 2/6
33.33% Functions 1/3
87.5% Lines 7/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 57            12x             11x 11x 11x 11x       11x                                                 12x                      
import { Box, Drawer, DrawerProps, Fade } from "@mui/material";
import { useCustomThemeV2 } from "@theme/hooks/useCustomThemeV2";
import { styled } from "@theme/v2/Provider";
import { getDrawerV2DefaultProps } from "@theme/v2/customStyles/customDrawerStyle";
import { useAppTheme } from "@theme/v2/Provider";
 
const GiveSideMenu = ({
  anchor,
  open,
  onClose,
  children,
  ...rest
}: DrawerProps) => {
  const { isMobileView, isTabletView } = useCustomThemeV2();
  const theme = useAppTheme();
  const variant = isMobileView ? "temporary" : "permanent";
  const { componentsProps: _, ...drawerProps } = getDrawerV2DefaultProps(
    theme.palette.mode,
  );
 
  return (
    <>
      {isTabletView && (
        <Fade in={open}>
          <StyledBackdrop
            onClick={(e) => onClose && onClose(e, "backdropClick")}
          />
        </Fade>
      )}
      <Drawer
        variant={variant}
        open={open}
        elevation={0}
        anchor={anchor}
        onClose={onClose}
        type="sidemenu"
        {...drawerProps}
        {...rest}
      >
        {children}
      </Drawer>
    </>
  );
};
 
const StyledBackdrop = styled(Box)(({ theme }) => ({
  position: "fixed",
  top: 0,
  left: 0,
  right: 0,
  bottom: 0,
  zIndex: 101,
  backgroundColor: theme.palette?.surface?.overlay,
}));
 
export default GiveSideMenu;