react-jam-ui
Version:
React JAM UI components
58 lines (52 loc) • 1.4 kB
JavaScript
import React from 'react';
import classNames from 'classnames';
import './styles.styl'
export default class Radio extends React.Component {
constructor() {
super();
}
onChangeCapture = e => {
if(this.props.bindTo) this.props.bindTo()
if(this.props.onChange) this.props.onChange(e)
}
render() {
const {
className,
id,
label,
disabled,
error,
valid,
children,
inputRef,
bindTo,
onChange,
...rest
} = this.props
const classes = classNames(
'radio',
className,
{
'disabled': disabled,
'error': error,
'valid': valid
}
);
return (
<div className={ classes }>
<input
type='radio'
disabled={ disabled }
id={ id }
ref={ el => {
this.radioDom = el;
if (inputRef) inputRef(el)
}}
onChange={ this.onChangeCapture }
{ ...rest }
/>
<label htmlFor={ id }>{ label } { children }</label>
</div>
)
}
}