You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
892 B

  1. import PureRenderMixin from 'react-addons-pure-render-mixin';
  2. import Button from '../../../components/button';
  3. const UploadButton = React.createClass({
  4. propTypes: {
  5. disabled: React.PropTypes.bool,
  6. onSelectFile: React.PropTypes.func.isRequired
  7. },
  8. mixins: [PureRenderMixin],
  9. handleChange (e) {
  10. if (e.target.files.length > 0) {
  11. this.props.onSelectFile(e.target.files);
  12. }
  13. },
  14. handleClick () {
  15. this.refs.fileElement.click();
  16. },
  17. render () {
  18. return (
  19. <div>
  20. <Button disabled={this.props.disabled} onClick={this.handleClick} block={true}>
  21. <i className='fa fa-fw fa-photo' /> Add images
  22. </Button>
  23. <input ref='fileElement' type='file' multiple={false} onChange={this.handleChange} disabled={this.props.disabled} style={{ display: 'none' }} />
  24. </div>
  25. );
  26. }
  27. });
  28. export default UploadButton;