2016-10-26 16:04:32 +03:00
|
|
|
const classNames = require('classnames');
|
|
|
|
const React = require('react');
|
|
|
|
const styles = require('./style.css');
|
|
|
|
|
|
|
|
const Checkbox = ({
|
|
|
|
checked = false,
|
|
|
|
className,
|
|
|
|
children,
|
|
|
|
disabled = false,
|
2016-10-26 16:44:17 +03:00
|
|
|
id,
|
2016-10-26 16:04:32 +03:00
|
|
|
onChange,
|
|
|
|
style
|
|
|
|
}) => {
|
|
|
|
const cn = classNames(
|
|
|
|
className,
|
|
|
|
styles.checkbox,
|
|
|
|
checked ? styles.checked : '',
|
|
|
|
disabled ? styles.disabled : ''
|
|
|
|
);
|
|
|
|
|
|
|
|
return (
|
2016-10-26 16:44:17 +03:00
|
|
|
<label className={styles.label} htmlFor={id}>
|
2016-10-26 16:04:32 +03:00
|
|
|
<input
|
|
|
|
checked={checked}
|
2016-10-26 16:44:17 +03:00
|
|
|
className={cn}
|
2016-10-26 16:04:32 +03:00
|
|
|
disabled={disabled}
|
2016-10-26 16:44:17 +03:00
|
|
|
id={id}
|
|
|
|
onChange={onChange}
|
|
|
|
style={style}
|
2016-10-26 16:04:32 +03:00
|
|
|
type='checkbox'
|
|
|
|
/>
|
|
|
|
<span>{children}</span>
|
|
|
|
</label>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
Checkbox.propTypes = {
|
2016-10-26 16:44:17 +03:00
|
|
|
checked: React.PropTypes.bool,
|
2016-10-26 16:04:32 +03:00
|
|
|
children: React.PropTypes.node,
|
|
|
|
className: React.PropTypes.string,
|
|
|
|
disabled: React.PropTypes.bool,
|
2016-10-26 16:44:17 +03:00
|
|
|
id: React.PropTypes.string,
|
2016-10-26 16:04:32 +03:00
|
|
|
onChange: React.PropTypes.func,
|
|
|
|
style: React.PropTypes.object
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = Checkbox;
|