All files / javascripts/explorev2/components/controls CheckboxControl.jsx

100% Statements 9/9
100% Branches 0/0
50% Functions 1/2
100% Lines 9/9
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 331x 1x   1x               1x   1x         1x     2x                 1x 1x  
import React, { PropTypes } from 'react';
import { Checkbox } from 'react-bootstrap';
 
const propTypes = {
  name: PropTypes.string.isRequired,
  value: PropTypes.bool,
  label: PropTypes.string,
  description: PropTypes.string,
  onChange: PropTypes.func,
};
 
const defaultProps = {
  value: false,
  onChange: () => {},
};
 
export default class CheckboxControl extends React.Component {
  onToggle() {
    this.props.onChange(!this.props.value);
  }
  render() {
    return (
      <Checkbox
        checked={this.props.value}
        onChange={this.onToggle.bind(this)}
      />
    );
  }
}
 
CheckboxControl.propTypes = propTypes;
CheckboxControl.defaultProps = defaultProps;