All files / src/components/SolidRadio index.jsx

100% Statements 7/7
100% Branches 2/2
100% Functions 3/3
100% Lines 7/7
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            3x 3x       2x 2x 1x         4x                         1x                  
import styles from './style.postcss';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
 
class SolidRadio extends Component {
  constructor(props) {
    super(props);
    this._handleCheck = this._handleCheck.bind(this);
  }
 
  _handleCheck(evt) {
    const { value } = evt.target;
    if (this.props.onChange) {
      this.props.onChange(value);
    }
  }
 
  render() {
    return <div className={styles.SolidRadio}>
      <input type="radio"
          id={this.props.id}
          name={this.props.name}
          value={this.props.value}
          className={styles.SolidRadio_radio}
          checked={this.props.isChecked}
          onChange={this._handleCheck} />
      <label htmlFor={this.props.id} />
    </div>;
  }
}
 
SolidRadio.propTypes = {
  id: PropTypes.string.isRequired,
  name: PropTypes.string.isRequired,
  value: PropTypes.string,
  isChecked: PropTypes.bool,
  onChange: PropTypes.func,
};
 
export default SolidRadio;