All files / src/components/common/TableFilters SectionItem.tsx

100% Statements 6/6
100% Branches 9/9
100% Functions 4/4
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                              108x                             108x             13x 337x 216x            
import { Text } from "@common/Text";
import { Stack } from "@mui/material";
import { styled } from "@mui/material";
import { palette } from "@palette";
import { FilterSectionItemType } from "./utils";
 
export default function SectionItem({
  title,
  description,
  startIcon,
  endElement,
  children,
  containerStyle = {},
  dataTestId
}: FilterSectionItemType) {
  return (
    <Container direction="column" sx={containerStyle} data-testid={dataTestId}>
      <Stack direction="row" spacing={1}>
        {!!startIcon && startIcon}
        <Stack flex={1} direction="column" gap="4px">
          <StyledText>{title}</StyledText>
          <StyledText isDescription>{description}</StyledText>
        </Stack>
        {!!endElement && endElement}
      </Stack>
      {!!children && <Stack flex={1}>{children}</Stack>}
    </Container>
  );
}
 
export const Container = styled(Stack)(() => ({
  gap: "8px",
  padding: "16px",
  backgroundColor: palette.neutral.white,
  borderRadius: "8px",
}));
 
const StyledText = styled(Text, {
  shouldForwardProp: (prop) => prop !== "isDescription",
})<{ isDescription?: boolean }>(({ isDescription }) => ({
  fontSize: "14px",
  lineHeight: "16.8px",
  fontWeight: 350,
  color: isDescription ? palette.neutral[70] : palette.neutral[80],
}));