All files / src/components/common/IconButton IconButton.tsx

90.9% Statements 10/11
50% Branches 1/2
100% Functions 4/4
88.88% Lines 8/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 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 75 76 77 78 79 80 81 82 83 84                                                      4229x           188x         4229x             188x         3637x   3637x               3637x     3637x                                        
import React from "react";
 
import {
  Button as MuiButton,
  ButtonProps as MuiButtonProps,
  TooltipProps,
  styled,
} from "@mui/material";
import { Tooltip } from "@common/Tooltip";
 
interface StyleIconButtonProps extends MuiButtonProps {
  toolTipText?: string;
  disabled?: boolean;
  children: React.ReactElement;
  tooltipProps?: TooltipProps;
}
/**
 * FOR ICON BUTTON ALSO USING BUTTON OF MUI
 */
 
export interface IStyleIconButtonProps extends MuiButtonProps {
  toolTipText?: string;
  disabled?: boolean;
  children: React.ReactElement;
  tooltipProps?: TooltipProps;
}
 
const IconWrapper = styled("span")(() => ({
  justifyContent: "center",
  display: "flex",
  alignItems: "center",
}));
 
export const IconButton: React.FC<MuiButtonProps> = ({
  className,
  children,
  ...props
}) => {
  return (
    <MuiButton className={`CustomIconButton ${className}`} {...props}>
      <IconWrapper>{children}</IconWrapper>
    </MuiButton>
  );
};
 
export const StyledIconButton: React.FC<IStyleIconButtonProps> = ({
  toolTipText,
  tooltipProps,
  ...rest
}) => {
  const renderContent = <BaseIconButton {...rest} />;
 
  Iif (toolTipText) {
    return (
      <Tooltip title={toolTipText} {...tooltipProps}>
        {renderContent}
      </Tooltip>
    );
  }
 
  return renderContent;
};
 
const BaseIconButton = styled(IconButton)(({ theme }) => ({
  border: "none",
  boxShadow: "none",
  backgroundColor: "transparent",
  background: "none",
  "&:hover": {
    backgroundColor: "transparent",
    background: "none",
    
  },
  "&:disabled": {
    boxShadow: "none",
    backgroundColor: "transparent",
    background: "none",
  },
  "&:hover path": {
    fill: theme?.palette?.neutral?.[100],
    transition: "fill 250ms ease",
  },
}));