All files / app/components/Bar ScoreBar.tsx

100% Statements 10/10
50% Branches 1/2
100% Functions 4/4
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            4x 4x           8x               8x             8x                   8x 8x              
import {
  Container,
  ContainerProps,
  LinearProgress,
  styled,
  Typography,
} from "@mui/material";
import React from "react";
 
interface ScoreBarProps extends ContainerProps {
  value: number;
}
 
const StyledContainer = styled(Container)(({ theme }) => ({
  height: theme.spacing(3),
  marginInlineStart: 0,
  maxWidth: 300,
  position: "relative",
  width: "100%",
}));
 
const StyledLinearProgress = styled(LinearProgress)(({ theme }) => ({
  borderRadius: theme.spacing(1.5),
  height: "100%",
  position: "absolute",
  width: "100%",
}));
 
const StyledScoreBarLabel = styled(Typography)(({ theme }) => ({
  color: theme.palette.common.white,
  lineHeight: theme.spacing(3),
  paddingLeft: theme.spacing(2),
  position: "absolute",
  verticalAlign: "middle",
  width: "100%",
  fontSize: "0.75rem",
}));
 
export default function SearchResult({ value, children }: ScoreBarProps) {
  return process.env.NEXT_PUBLIC_IS_POST_BETA_ENABLED ? (
    <StyledContainer disableGutters>
      <StyledLinearProgress variant="determinate" value={value} />
      <StyledScoreBarLabel noWrap>{children}</StyledScoreBarLabel>
    </StyledContainer>
  ) : null;
}