You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RadioButton.js 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import React from "react";
  2. import PropTypes from "prop-types";
  3. import {
  4. FormControlLabelStyled,
  5. RadioButtonContainer,
  6. RadioButtonStyled,
  7. } from "./RadioButton.styled";
  8. import { ReactComponent as RadioChecked } from "../../../assets/images/svg/radio-checked.svg";
  9. import { ReactComponent as RadioUnchecked } from "../../../assets/images/svg/radio-unchecked.svg";
  10. import { Label } from "../../CheckBox/Label";
  11. const RadioButton = (props) => {
  12. return (
  13. <RadioButtonContainer fullwidth={props.fullWidth ? 1 : 0}>
  14. <FormControlLabelStyled
  15. value={props.value}
  16. fullwidth={props.fullWidth ? 1 : 0}
  17. control={
  18. <RadioButtonStyled
  19. icon={<RadioUnchecked />}
  20. onChange={() => props.onChange(props.value)}
  21. checkedIcon={<RadioChecked />}
  22. checked={props.checked}
  23. />
  24. }
  25. label={
  26. <Label
  27. leftText={props.label}
  28. rightText={props.number}
  29. onClick={() => props.onChange(props.value)}
  30. />
  31. }
  32. />
  33. </RadioButtonContainer>
  34. );
  35. };
  36. RadioButton.propTypes = {
  37. children: PropTypes.node,
  38. value: PropTypes.any,
  39. label: PropTypes.string,
  40. number: PropTypes.number,
  41. fullWidth: PropTypes.bool,
  42. checked: PropTypes.bool,
  43. onChange: PropTypes.func,
  44. };
  45. RadioButton.defaultProps = {
  46. fullWidth: false,
  47. };
  48. export default RadioButton;