All files / app/components IconButton.tsx

100% Statements 10/10
50% Branches 1/2
100% Functions 2/2
100% Lines 9/9

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        28x 28x 28x   28x   53x                     28x       204x 204x 204x                            
import {
  IconButton as MuiIconButton,
  IconButtonProps as MuiIconButtonProps,
  useTheme,
} from "@material-ui/core";
import { forwardRef } from "react";
import makeStyles from "utils/makeStyles";
 
import CircularProgress from "./CircularProgress";
 
const useStyles = makeStyles((theme) => ({
  circularProgress: {
    margin: 3,
  },
}));
 
interface IconButtonProps extends MuiIconButtonProps {
  "aria-label": string;
  loading?: boolean;
}
 
export default forwardRef(function IconButton(
  { loading, ...otherProps }: IconButtonProps,
  ref: IconButtonProps["ref"]
) {
  const classes = useStyles();
  const theme = useTheme();
  return (
    <MuiIconButton {...otherProps} ref={ref}>
      {loading ? (
        <CircularProgress
          className={classes.circularProgress}
          //stolen from source for MUI IconButton
          size={theme.typography.pxToRem(18)}
        />
      ) : (
        otherProps.children
      )}
    </MuiIconButton>
  );
});