All files / src/components/common/FilePreview/layout ArrowButton.tsx

14.28% Statements 1/7
0% Branches 0/4
0% Functions 0/5
14.28% Lines 1/7

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        1x                                                                                              
import FadeInWrapper from "@components/animation/FadeInWrapper";
import { SxProps } from "@mui/material";
import { SingleActionButton } from "./PreviewToolbar";
 
const ArrowButton = ({
  children,
  sx,
  onClick,
  disabled = false,
  onMouseEnterAndLeave = () => null,
  ...props
}: {
  children: React.ReactNode;
  sx: SxProps;
  onClick: () => void;
  disabled?: boolean;
  "data-testid": string;
  onMouseEnterAndLeave?: (value?: boolean) => void;
}) => {
  return (
    <FadeInWrapper
      delay={100}
      dataTestId={props["data-testid"]}
      containerProps={{ zIndex: 1100 }}
    >
      <SingleActionButton
        data-testid="arrow-button"
        disabled={disabled}
        onClick={(event) => {
          event.stopPropagation();
          onClick();
        }}
        onMouseEnter={() => onMouseEnterAndLeave(true)}
        onMouseLeave={() => onMouseEnterAndLeave(false)}
        sx={{
          position: "fixed",
          top: "50%",
          transform: "translateY(-50%)",
          "&:hover": {
            opacity: disabled ? 0.3 : 0.8,
          },
          ...sx,
        }}
      >
        {children}
      </SingleActionButton>
    </FadeInWrapper>
  );
};
 
export default ArrowButton;