2016-09-07 09:17:15 -07:00
|
|
|
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
2016-09-19 14:25:59 -07:00
|
|
|
import Button from '../../../components/button';
|
2016-09-07 09:17:15 -07:00
|
|
|
|
|
|
|
const UploadButton = React.createClass({
|
|
|
|
|
|
|
|
propTypes: {
|
|
|
|
disabled: React.PropTypes.bool,
|
|
|
|
onSelectFile: React.PropTypes.func.isRequired
|
|
|
|
},
|
|
|
|
|
|
|
|
mixins: [PureRenderMixin],
|
|
|
|
|
|
|
|
handleChange (e) {
|
|
|
|
if (e.target.files.length > 0) {
|
|
|
|
this.props.onSelectFile(e.target.files);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
handleClick () {
|
|
|
|
this.refs.fileElement.click();
|
|
|
|
},
|
|
|
|
|
|
|
|
render () {
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<Button disabled={this.props.disabled} onClick={this.handleClick} block={true}>
|
2016-10-30 10:13:05 -07:00
|
|
|
<i className='fa fa-fw fa-photo' /> Add media
|
2016-09-07 09:17:15 -07:00
|
|
|
</Button>
|
|
|
|
|
2016-09-12 17:24:40 -07:00
|
|
|
<input ref='fileElement' type='file' multiple={false} onChange={this.handleChange} disabled={this.props.disabled} style={{ display: 'none' }} />
|
2016-09-07 09:17:15 -07:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
export default UploadButton;
|