All files / src/shared/Radio GiveRadio.tsx

100% Statements 5/5
100% Branches 1/1
100% Functions 2/2
100% Lines 4/4

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                51x 915x                                     1002x                     51x                          
import React from "react";
import { styled } from "@theme/v2/Provider";
import { Radio as MuiRadio, RadioProps as MuiRadioProps } from "@mui/material";
 
export type RadioProps = MuiRadioProps & {
  iconStyles?: { [key: string]: string };
};
 
const GiveRadio: React.FC<RadioProps> = ({ iconStyles = {}, ...rest }) => {
  return (
    <MuiRadio
      size="small"
      disableRipple
      checkedIcon={<BpCheckedIcon className="RadioIcon BPchecked" />}
      icon={
        <BpIcon
          className="RadioIcon"
          sx={{
            ...iconStyles,
          }}
        />
      }
      version="two"
      {...rest}
    />
  );
};
 
const BpIcon = styled("span")(({ theme }) => ({
  position: "relative",
  borderRadius: "50%",
  border: `1.5px solid ${theme.palette.border?.tertiary}`,
  transition: "background-color 0.2s",
  backgroundColor: "transparent",
  ".Mui-disabled &": {
    backgroundColor: theme.palette.surface?.secondary,
  },
}));
 
const BpCheckedIcon = styled(BpIcon)({
  "&:before": {
    transition: "background-color 0.2s",
    position: "absolute",
    content: '""',
    top: "50%",
    left: "50%",
    borderRadius: "50%",
    transform: "translate(-50%, -50%)",
  },
});
 
export default GiveRadio;