{"size": 1142, "ext": "js", "max_stars_repo_path": "source/Switchery/Switchery.js", "max_stars_repo_name": "vivaxy/react-pianist", "max_stars_repo_stars_event_min_datetime": "2016-09-04T03:04:58.000Z", "max_stars_repo_stars_event_max_datetime": "2016-09-06T05:10:22.000Z", "max_issues_repo_path": "source/Switchery/Switchery.js", "max_issues_repo_name": "vivaxy/react-pianist", "max_issues_repo_issues_event_min_datetime": "2016-09-25T02:08:41.000Z", "max_issues_repo_issues_event_max_datetime": "2016-10-30T04:40:38.000Z", "max_forks_repo_path": "source/Switchery/Switchery.js", "max_forks_repo_name": "vivaxy/react-pianist", "max_forks_repo_forks_event_min_datetime": "2016-09-04T03:05:00.000Z", "max_forks_repo_forks_event_max_datetime": "2016-11-15T10:35:49.000Z"}
{"max_stars_count": 3, "max_issues_count": 2, "max_forks_count": 2, "avg_line_length": 19.3559322034, "max_line_length": 50, "alphanum_fraction": 0.5122591944}
/**
 * @since 2016-09-06 09:13
 * @author vivaxy
 */

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import warning from 'warning';

import i18n from '../config/i18n';
import colors from '../colors';
import './Switchery.less';

export default class Switchery extends Component {

    static propTypes = {
        checked: PropTypes.bool,
        disabled: PropTypes.bool,
        onChange: PropTypes.func,
    };

    static defaultProps = {
        checked: true,
        disabled: false,
        onChange: () => {

        },
    };

    render() {

        const {
            checked,
            disabled,
            style,
            onChange,
            ...otherProps,
        } = this.props;

        return <input
            type={'checkbox'}
            disabled={disabled}
            checked={checked}
            style={style}
            className={`react-pianist-switchery`}
            onChange={::this.onChange}
            {...otherProps}
        />
    }

    onChange(e) {
        const {
            onChange,
        } = this.props;

        return onChange(e.target.checked);
    }
}
