All files / src/features/Permissions/ModalV2/components/PermissionsPanel PermissionsPanelSkeleton.tsx

100% Statements 15/15
100% Branches 1/1
100% Functions 9/9
100% Lines 15/15

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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74    4x 41x               4x 41x           164x         4x 41x           123x         4x 123x       369x           4x 369x               4x                 369x                  
import { Skeleton, Stack } from "@mui/material";
 
const PermissionsPanelSkeleton = () => {
  return (
    <>
      <Header />
      <Body />
    </>
  );
};
 
const Header = () => (
  <Stack
    direction="row"
    gap="18px"
    sx={{ paddingTop: "50px", paddingInline: "16px" }}
  >
    {Array.from({ length: 4 }, (_, i) => (
      <BaseSkeleton key={i} width="15%" />
    ))}
  </Stack>
);
 
const Body = () => (
  <Stack padding="16px" direction="column" gap="24px" alignItems="stretch">
    <Stack direction="row" justifyContent="space-between" padding="12px 0">
      <BaseSkeleton width="45%" />
      <BaseSkeleton width="15%" />
    </Stack>
    {Array.from({ length: 3 }, (_, i) => (
      <SectionSkeleton key={i} />
    ))}
  </Stack>
);
 
export const SectionSkeleton = () => (
  <>
    <BaseSkeleton width="25%" align="center" />
    <Stack direction="column" gap="8px">
      {Array.from({ length: 3 }, (_, i) => (
        <SectionItem key={i} />
      ))}
    </Stack>
  </>
);
 
const SectionItem = () => (
  <Skeleton
    variant="rectangular"
    height="48px"
    width="100%"
    sx={{ borderRadius: "8px" }}
  />
);
 
const BaseSkeleton = ({
  width,
  height = "16px",
  align,
}: {
  width: number | string;
  height?: number | string;
  align?: string;
}) => (
  <Skeleton
    variant="rectangular"
    height={height}
    width={width}
    sx={{ borderRadius: "12px", alignSelf: align }}
  />
);
 
export default PermissionsPanelSkeleton;