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.

40 lines
1.3 KiB

  1. import PureRenderMixin from 'react-addons-pure-render-mixin';
  2. import ImmutablePropTypes from 'react-immutable-proptypes';
  3. import IconButton from '../../../components/icon_button';
  4. import { defineMessages, injectIntl } from 'react-intl';
  5. const messages = defineMessages({
  6. undo: { id: 'upload_form.undo', defaultMessage: 'Undo' }
  7. });
  8. const UploadForm = React.createClass({
  9. propTypes: {
  10. media: ImmutablePropTypes.list.isRequired,
  11. is_uploading: React.PropTypes.bool,
  12. onRemoveFile: React.PropTypes.func.isRequired
  13. },
  14. mixins: [PureRenderMixin],
  15. render () {
  16. const { intl } = this.props;
  17. const uploads = this.props.media.map(attachment => (
  18. <div key={attachment.get('id')} style={{ borderRadius: '4px', marginBottom: '10px' }} className='transparent-background'>
  19. <div style={{ width: '100%', height: '100px', borderRadius: '4px', background: `url(${attachment.get('preview_url')}) no-repeat center`, backgroundSize: 'cover' }}>
  20. <IconButton icon='times' title={intl.formatMessage(messages.undo)} size={36} onClick={this.props.onRemoveFile.bind(this, attachment.get('id'))} />
  21. </div>
  22. </div>
  23. ));
  24. return (
  25. <div style={{ marginBottom: '20px', padding: '10px', overflow: 'hidden' }}>
  26. {uploads}
  27. </div>
  28. );
  29. }
  30. });
  31. export default injectIntl(UploadForm);