Next.js template
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.

Radio.js 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import PropTypes from 'prop-types';
  2. import React from 'react';
  3. import { ReactComponent as RadioOff } from '../../../assets/images/svg/radio-off.svg';
  4. import { ReactComponent as RadioOn } from '../../../assets/images/svg/radio-on.svg';
  5. const Checkbox = ({
  6. className,
  7. children,
  8. name,
  9. checked,
  10. field,
  11. value,
  12. selected,
  13. id,
  14. }) => (
  15. <label
  16. htmlFor={name}
  17. className={`c-radio ${selected ? 'c-radio--selected' : ''} ${
  18. className || ''
  19. }`}
  20. >
  21. <input
  22. name={name}
  23. id={id}
  24. className="c-radio__field"
  25. type="radio"
  26. checked={checked}
  27. value={value}
  28. {...field}
  29. />
  30. <div className="c-radio__indicator">
  31. {selected ? (
  32. <RadioOn className="c-radio__icon" />
  33. ) : (
  34. <RadioOff className="c-radio__icon" />
  35. )}
  36. </div>
  37. <div className="c-radio__text">{children}</div>
  38. </label>
  39. );
  40. Checkbox.propTypes = {
  41. children: PropTypes.node,
  42. checked: PropTypes.bool,
  43. name: PropTypes.string,
  44. field: PropTypes.shape({}),
  45. form: PropTypes.shape({}),
  46. className: PropTypes.string,
  47. value: PropTypes.string,
  48. selected: PropTypes.bool,
  49. id: PropTypes.string,
  50. };
  51. export default Checkbox;