All files / src/sections/PayBuilder/Checkout/components SectionHeader.tsx

100% Statements 5/5
100% Branches 4/4
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                          15x 374x 374x                                                       15x 374x                
import React, { cloneElement } from "react";
import { Box, Stack } from "@mui/material";
import GiveText from "@shared/Text/GiveText";
import { CustomTheme } from "@theme/v2/palette.interface";
import { styled } from "@theme/v2/Provider";
import { usePayBuilderForm } from "@sections/PayBuilder/provider/PayBuilderFormProvider";
 
type Props = {
  title: string;
  icon: React.ReactElement;
  description?: string;
};
 
const SectionHeader = ({ title, icon, description }: Props) => {
  const { parsedValues } = usePayBuilderForm();
  return (
    <Stack
      direction="row"
      alignItems={description ? "flex-start" : "center"}
      gap="20px"
    >
      <IconContainer color={parsedValues.accentColor}>
        {cloneElement(icon, {
          color: parsedValues.accentColor,
          size: 20
        })}
      </IconContainer>
      <Stack>
        <GiveText variant="h3" fontWeight={300} color="primary">
          {title}
        </GiveText>
        {description && (
          <GiveText variant="bodyS" color="secondary">
            {description}
          </GiveText>
        )}
      </Stack>
    </Stack>
  );
};
 
export default SectionHeader;
 
const IconContainer = styled(Box)<{ color?: string }>(
  ({ theme, color }: { theme: CustomTheme; color?: string }) => ({
    width: 36,
    height: 36,
    padding: "8px",
    borderRadius: "20px",
    backgroundColor: `${color}1A`,
  }),
);