All files / src/features/GiveSignup/components GiveKotoLinearProgress.tsx

100% Statements 7/7
93.75% Branches 15/16
100% Functions 1/1
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            1x               123x     123x 123x 123x 123x 123x                                                                                        
import { LinearProgress, Stack } from "@mui/material";
import { CheckIcon } from "@phosphor-icons/react";
import GiveText from "@shared/Text/GiveText";
import { useCustomThemeV2 } from "@theme/hooks/useCustomThemeV2";
import { useAppTheme } from "@theme/v2/Provider";
 
const GiveKotoLinearProgress = ({
  LinearProgressProps,
  svgProps,
  isActive,
  hasDescription,
  isCompletedColor,
  ...rest
}: any) => {
  const isCompleted = rest.value === 100;
 
  // is active color primary, else secondary,
  const color = isActive ? "primary" : "secondary";
  const { palette } = useAppTheme();
  const { isMobileView } = useCustomThemeV2();
  const showSolidStepper = isActive || (isCompleted && isMobileView);
  return (
    <Stack flex={1} justifyContent="flex-start" width="100%">
      {rest.title && (
        <GiveText mb={1} textAlign="left" color={color}>
          {rest.title}
        </GiveText>
      )}
      <LinearProgress
        variant="determinate"
        {...rest}
        sx={{
          borderRadius: "90px",
          backgroundColor: showSolidStepper
            ? palette.text.primary
            : palette.border?.secondary,
          height: "1px",
          ".MuiLinearProgress-bar": {
            backgroundColor: "unset",
            ...(!isActive && { opacity: ".2" }),
          },
          ...rest.sx,
        }}
        data-testid="stepper-linear-progress"
      />
      {hasDescription && (
        <Stack direction="row" gap={0.5} alignItems="center" mt={1}>
          {isCompleted && !isMobileView && (
            <CheckIcon width={14} height={14} color={palette.text.primary} />
          )}
          <GiveText
            variant="bodyXS"
            textAlign="left"
            color={color}
            {...LinearProgressProps}
          >
            {rest.label}
          </GiveText>
        </Stack>
      )}
    </Stack>
  );
};
 
export default GiveKotoLinearProgress;