All files / src/shared/Button GiveButton.tsx

77.77% Statements 7/9
72.72% Branches 8/11
100% Functions 2/2
75% Lines 6/8

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            352x             17174x 3543x         17174x                                     17174x       17174x        
import { Button, ThemeProvider } from "@mui/material";
import { ButtonProps } from "./GiveButton.types";
import { createThemeBuilder } from "@theme/v2/theme.builders";
import { useMemo } from "react";
import GiveCircularProgress from "@shared/GiveCircularProgress";
 
const GiveButton = ({
  label,
  variant = "filled",
  forceDarkMode = false,
  loading = false,
  ...rest
}: ButtonProps) => {
  const darkTheme = useMemo(() => {
    Eif (!forceDarkMode) return undefined;
    return createThemeBuilder("dark");
  }, [forceDarkMode]);
 
  const button = (
    <Button
      disableTouchRipple
      disableRipple
      disableFocusRipple
      variant={variant}
      version="two"
      endIcon={
        loading ? (
          <GiveCircularProgress size={14} thickness={4} color="inherit" />
        ) : (
          rest.endIcon
        )
      }
      {...rest}
    >
      {label}
    </Button>
  );
 
  Iif (forceDarkMode && darkTheme) {
    return <ThemeProvider theme={darkTheme}>{button}</ThemeProvider>;
  }
 
  return button;
};
 
export default GiveButton;