All files / src/components/common/Button Button_V2.tsx

100% Statements 3/3
83.33% Branches 5/6
100% Functions 2/2
100% Lines 3/3

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                                              506x 26813x               4891x                                                              
import React from "react";
import {
  Button as MuiButton,
  ButtonProps as MuiButtonProps,
} from "@mui/material";
import { styled } from "@mui/material/styles";
import { buttonTheme } from "./newButtonTheme";
 
export type BtnBGTypes =
  | "primary"
  | "secondary"
  | "tertiary"
  | "text"
  | "red"
  | "success"
  | "outlined";
 
export type RebrandedButtonProps = MuiButtonProps & {
  children?: React.ReactNode;
  background?: BtnBGTypes;
  size?: "small" | "medium" | "large";
};
 
export const StyledButton_V2 = styled(MuiButton, {
  shouldForwardProp: (prop) => prop !== "size" && prop !== "background",
})(
  ({
    background = "primary",
    size = "large",
  }: {
    background?: BtnBGTypes;
    size?: "small" | "medium" | "large";
  }) => ({
    borderRadius: "90px",
    boxShadow: "none",
    backgroundColor: buttonTheme.colors[background].background,
    borderColor: buttonTheme.colors[background].borderColor,
    borderWidth: buttonTheme.colors[background].borderWeight,
    fontSize: buttonTheme.size[size].fontSize,
    height: buttonTheme.size[size].height,
    paddingTop: buttonTheme.size[size].vertical,
    paddingBottom: buttonTheme.size[size].vertical,
    paddingLeft: buttonTheme.size[size].horizontal,
    paddingRight: buttonTheme.size[size].horizontal,
    color: buttonTheme.colors[background].text,
    "&:disabled": {
      backgroundColor:
        buttonTheme.colors[background].disabled.background ?? "transparent",
      color: buttonTheme.colors[background].disabled.color,
      borderColor: buttonTheme.colors[background].disabled.borderColor,
      boxShadow: "none",
    },
    "&:hover": {
      backgroundColor: buttonTheme.colors[background].hover.background,
      textDecoration: buttonTheme.colors[background].active.decoration,
      boxShadow: "none",
    },
    "&:active": {
      backgroundColor: buttonTheme.colors[background].active.background,
      textDecoration: buttonTheme.colors[background].active.decoration,
    },
  }),
);