All files / src/theme/v2/customStyles customLinkStyle.ts

100% Statements 7/7
100% Branches 6/6
100% Functions 6/6
100% Lines 7/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 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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103                            548x 2905x         4734x                                                                       4734x                 4734x                   4734x                             4734x                        
import { getJsonValue, isSecondVersion } from "@theme/v2/utils";
import { ThemeVersions } from "@theme/v2/types";
 
declare module "@mui/material/Link" {
  interface LinkOwnProps {
    hasIcon?: boolean;
    version?: ThemeVersions;
  }
 
  interface LinkPropsColorOverrides {
    error: true;
  }
}
 
export const getCustomLinkStyle = (mode: "light" | "dark") => {
  return {
    styleOverrides: {
      root: {
        variants: [
          {
            props: (props: any) => isSecondVersion(props.version),
            style: {
              display: "flex",
              flexDirection: "row",
              alignItems: "center",
              fontSize: 14,
              fontWeight: 400,
              lineHeight: "20px",
              gap: "6px",
              color: getJsonValue(`tokens.${mode}.colour.text.primary`),
              textDecoration: "none",
              "& span": {
                position: "relative",
                "&:before": {
                  content: '""',
                  position: "absolute",
                  left: 0,
                  bottom: 0,
                  height: "0px",
                  backgroundColor: "currentColor",
                  width: "100%",
                  opacity: 0,
                  transition: "height 0.15s ease-out, opacity 0.15s ease",
                },
              },
              "&:hover span:before": {
                height: "1px",
                opacity: 1,
              },
              "&:active": {
                color: getJsonValue(`tokens.${mode}.colour.text.secondary`),
              },
            },
          },
          {
            props: (props: any) =>
              isSecondVersion(props.version) && props.color === "secondary",
            style: {
              color: getJsonValue(`tokens.${mode}.primitive.blue.100`),
              "&:active": {
                color: getJsonValue(`tokens.${mode}.primitive.blue.50`),
              },
            },
          },
          {
            props: (props: any) => props.color === "error",
            style: {
              color: getJsonValue(`tokens.${mode}.primitive.error.100`),
              "&:active": {
                color: getJsonValue(`tokens.${mode}.primitive.error.50`),
              },
            },
          },
          {
            props: (props: any) =>
              isSecondVersion(props.version) && props.disabled,
            style: {
              color: getJsonValue(`tokens.${mode}.colour.text.tertiary`),
              cursor: "default",
              "&:active": {
                color: getJsonValue(`tokens.${mode}.colour.text.tertiary`),
              },
              "&:hover span:before": {
                height: "0",
                opacity: 0,
              },
            },
          },
          {
            props: (props: any) =>
              props.disabled && isSecondVersion(props.version),
            style: {
              "&:before": {
                content: "unset",
              },
            },
          },
        ],
      },
    },
  };
};