joyent-portal/ui/src/components/radio/index.js

51 lines
935 B
JavaScript
Raw Normal View History

const classNames = require('classnames');
const React = require('react');
const styles = require('./style.css');
const Radio = ({
name,
value,
2016-10-27 12:51:47 +03:00
children,
checked,
disabled = false,
className,
id,
onChange,
style
}) => {
const cn = classNames(
className,
styles.radio
);
return (
2016-10-27 12:51:47 +03:00
<label className={cn} htmlFor={id}>
<input
checked={checked}
2016-10-27 12:51:47 +03:00
disabled={disabled}
id={id}
name={name}
onChange={onChange}
2016-10-27 12:51:47 +03:00
type='radio'
value={value}
/>
2016-10-27 12:51:47 +03:00
<span>{children}</span>
</label>
);
};
Radio.propTypes = {
2016-10-27 12:51:47 +03:00
checked: React.PropTypes.bool,
children: React.PropTypes.node,
className: React.PropTypes.string,
2016-10-27 12:51:47 +03:00
disabled: React.PropTypes.bool,
id: React.PropTypes.string,
name: React.PropTypes.string,
2016-10-27 12:51:47 +03:00
onChange: React.PropTypes.func,
style: React.PropTypes.object,
value: React.PropTypes.string
};
module.exports = Radio;