All files / src/shared/IconButton GiveIconButton.tsx

100% Statements 4/4
100% Branches 10/10
100% Functions 1/1
100% Lines 4/4

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        328x               328x                             20290x   20290x                                                                    
import { IconButton } from "@mui/material";
import GiveText from "@shared/Text/GiveText";
import { IGiveIconButton } from "./GiveIconButton.type";
 
const ICON_SIZES = {
  extraSmall: "16px",
  mediumSmall: "18px",
  small: "20px",
  medium: "20px",
  large: "24px",
};
 
const GiveIconButton = ({
  Icon,
  CustomIcon,
  size = "small",
  variant = "filled",
  color,
  bgColor,
  elementRef,
  weight,
  iconText,
  disabled,
  textColor,
  label,
  ...rest
}: IGiveIconButton & { textColor?: string }) => {
  const buttonColor = bgColor || "transparent";
 
  return (
    <IconButton
      size={size}
      variant={variant}
      ref={elementRef}
      data-color={buttonColor}
      version="two"
      disabled={disabled}
      {...rest}
    >
      {label}
      {Icon && (
        <Icon
          size={ICON_SIZES[size]}
          color={color || undefined}
          weight={weight}
        />
      )}
      {CustomIcon}
      {iconText && (
        <GiveText
          fontFamily="Give Whyte"
          color={textColor}
          sx={{ color }}
          variant="bodyS"
        >
          {iconText}
        </GiveText>
      )}
    </IconButton>
  );
};
 
export default GiveIconButton;