All files / src/components/Product/commons NewMobileStat.tsx

40% Statements 2/5
0% Branches 0/11
0% Functions 0/3
66.66% Lines 2/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                                                                                            13x             13x                
import { Grid, styled } from "@mui/material";
import { palette } from "@palette";
import { StyledMainLinearColorText, Text } from "@common/Text";
import { StatProps } from "@common/NewStats/NewStat";
import Figure from "@common/Figure";
import { parseAmount } from "@utils/index";
 
function NewMobileStat({
  isAmount,
  title,
  value,
  percent,
  isTotal,
  fontSize = 18,
}: StatProps) {
  return (
    <Grid
      container
      spacing={1}
      justifyContent="space-between"
      sx={{ m: 0, pr: 1 }}
    >
      <StatText>
        {title}
        {percent && ` (\u0025)`}
        {isAmount && " (USD)"}
      </StatText>
      {isTotal ? (
        <StyledMainLinearColorText width="fit-content" fontSize={18}>
          <Figure
            color={palette.gradient[10]}
            value={value}
            percent={percent}
            fontSize={fontSize as any}
            isAmount={isAmount}
          />
        </StyledMainLinearColorText>
      ) : (
        <StatValue>
          {isAmount || percent ? parseAmount(value) : value}
        </StatValue>
      )}
    </Grid>
  );
}
 
const StatText = styled(Text)(() => ({
  fontSize: 14,
  fontWeight: 350,
  lineHeight: "16.8px",
  color: palette.neutral[70],
}));
 
const StatValue = styled(Text)(() => ({
  fontSize: 18,
  fontWeight: 300,
  lineHeight: "16.8px",
  color: palette.neutral[750],
}));
 
export default NewMobileStat;