All files / src/components/common/NewStats NewStatsTitle.tsx

100% Statements 6/6
72.72% Branches 8/11
100% Functions 2/2
100% Lines 5/5

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                                        13x                             6x   6x     6x                                             13x            
import React from "react";
import { Stack, StackProps, SxProps, Theme, styled } from "@mui/material";
import { Text } from "@common/Text";
import Figure from "@common/Figure";
import { useThemeContext } from "@components/EnterpriseSettings/Branding/Provider/CustomThemeProvider";
 
export interface StatsTitleProps extends StackProps {
  label?: string | React.ReactNode;
  value: string;
  isAmount?: boolean;
  currencyVisible?: boolean;
  fontSize?: number;
  align?: "right" | "left" | "center" | "inherit" | "justify";
  isMainTitle?: boolean;
  labelStyle?: SxProps<Theme>;
  figureStyle?: SxProps<Theme>;
  ratio?: number | string | undefined;
  ratioStyle?: any;
}
 
export const NewStatsTitle = ({
  label,
  value,
  isAmount = true,
  currencyVisible = true,
  fontSize = 48,
  align = "right",
  isMainTitle,
  labelStyle,
  color,
  figureStyle,
  ratio,
  ratioStyle,
  ...rest
}: StatsTitleProps) => {
  const { activeGradientColor, isDarkMode } = useThemeContext();
  const col =
    color ||
    (isDarkMode ? activeGradientColor?.dark : activeGradientColor?.light);
 
  return (
    <Stack direction="column" gap={1} {...rest}>
      <Figure
        sup={isMainTitle}
        value={value}
        fontSize={fontSize}
        color={col as string}
        variant={"h3"}
        fontWeight={"light"}
        lineHeight="normal"
        isAmount={isAmount}
        sx={figureStyle}
        ratio={ratio}
        ratioStyle={ratioStyle}
      />
      <TitleText variant="h6" align={align} width="100%" sx={labelStyle}>
        {label}
        {currencyVisible && isAmount && <span> (USD)</span>}
      </TitleText>
    </Stack>
  );
};
 
const TitleText = styled(Text)(() => ({
  fontWeight: 350,
  lineHeight: "120%",
}));
 
export default NewStatsTitle;