All files / src/componentsV2/Table ActionsComponent.tsx

100% Statements 7/7
100% Branches 6/6
100% Functions 2/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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52            33x           1600x 1412x                                     1600x 1600x 1600x                                  
import { Box, ButtonProps } from "@mui/material";
import { Icon } from "@phosphor-icons/react";
import GiveIconButton from "@shared/IconButton/GiveIconButton";
import GiveTooltip from "@shared/Tooltip/GiveTooltip";
import { useCustomThemeV2 } from "@theme/hooks/useCustomThemeV2";
 
const TooltipWrapper = ({
  title,
  ...props
}: {
  title: string;
} & ButtonProps) => {
  if (props.disabled) return <>{props.children}</>;
  return (
    <Box sx={{ width: "32px" }}>
      <GiveTooltip title={title} color="default">
        <Box>{props.children}</Box>
      </GiveTooltip>
    </Box>
  );
};
interface Props {
  icon: Icon;
  title: string;
}
 
export function ActionsComponent({
  icon,
  title,
  variant,
  ...props
}: Props & ButtonProps) {
  const { disabled } = props;
  const { isDesktopView } = useCustomThemeV2();
  return (
    <TooltipWrapper disabled={!disabled && !isDesktopView} title={title}>
      <GiveIconButton
        Icon={icon}
        weight={title === "Add to watchlist" ? "regular" : "fill"}
        size="small"
        style={{
          border: "none",
          boxShadow: "none",
          background: "inherit",
          padding: "0px",
        }}
        {...props}
      />
    </TooltipWrapper>
  );
}