All files / app/components IconButton.tsx

87.5% Statements 7/8
50% Branches 1/2
50% Functions 1/2
100% Lines 6/6

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          30x 30x   30x   30x                 368x       327x                      
import {
  IconButton as MuiIconButton,
  IconButtonProps as MuiIconButtonProps,
  styled,
  useTheme,
} from "@mui/material";
import { forwardRef } from "react";
 
import CircularProgress from "./CircularProgress";
 
const StyledCircularProgress = styled(CircularProgress)(({ theme }) => ({
  margin: 3,
}));
 
interface IconButtonProps extends MuiIconButtonProps {
  "aria-label": string;
  loading?: boolean;
}
 
export default forwardRef(function IconButton(
  { loading, ...otherProps }: IconButtonProps,
  ref: IconButtonProps["ref"]
) {
  const theme = useTheme();
  return (
    <MuiIconButton {...otherProps} ref={ref}>
      {loading ? (
        <StyledCircularProgress size={theme.typography.pxToRem(18)} />
      ) : (
        otherProps.children
      )}
    </MuiIconButton>
  );
});