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.

35 lines
803 B

  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import classNames from 'classnames';
  4. export default class RadioButton extends React.PureComponent {
  5. static propTypes = {
  6. value: PropTypes.string.isRequired,
  7. checked: PropTypes.bool,
  8. name: PropTypes.string.isRequired,
  9. onChange: PropTypes.func.isRequired,
  10. label: PropTypes.node.isRequired,
  11. };
  12. render () {
  13. const { name, value, checked, onChange, label } = this.props;
  14. return (
  15. <label className='radio-button'>
  16. <input
  17. name={name}
  18. type='radio'
  19. value={value}
  20. checked={checked}
  21. onChange={onChange}
  22. />
  23. <span className={classNames('radio-button__input', { checked })} />
  24. <span>{label}</span>
  25. </label>
  26. );
  27. }
  28. }