The code powering m.abunchtell.com https://m.abunchtell.com
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 

52 wiersze
1.7 KiB

  1. import React from 'react';
  2. import ImmutablePropTypes from 'react-immutable-proptypes';
  3. import PropTypes from 'prop-types';
  4. import IconButton from '../../../components/icon_button';
  5. import { defineMessages, injectIntl } from 'react-intl';
  6. import UploadProgressContainer from '../containers/upload_progress_container';
  7. import { Motion, spring } from 'react-motion';
  8. const messages = defineMessages({
  9. undo: { id: 'upload_form.undo', defaultMessage: 'Undo' }
  10. });
  11. class UploadForm extends React.PureComponent {
  12. static propTypes = {
  13. media: ImmutablePropTypes.list.isRequired,
  14. onRemoveFile: PropTypes.func.isRequired,
  15. intl: PropTypes.object.isRequired
  16. };
  17. onRemoveFile = (e) => {
  18. const id = Number(e.currentTarget.parentElement.getAttribute('data-id'));
  19. this.props.onRemoveFile(id);
  20. }
  21. render () {
  22. const { intl, media } = this.props;
  23. const uploads = media.map(attachment =>
  24. <div className='compose-form__upload' key={attachment.get('id')}>
  25. <Motion defaultStyle={{ scale: 0.8 }} style={{ scale: spring(1, { stiffness: 180, damping: 12 }) }}>
  26. {({ scale }) =>
  27. <div className='compose-form__upload-thumbnail' data-id={attachment.get('id')} style={{ transform: `translateZ(0) scale(${scale})`, backgroundImage: `url(${attachment.get('preview_url')})` }}>
  28. <IconButton icon='times' title={intl.formatMessage(messages.undo)} size={36} onClick={this.onRemoveFile} />
  29. </div>
  30. }
  31. </Motion>
  32. </div>
  33. );
  34. return (
  35. <div className='compose-form__upload-wrapper'>
  36. <UploadProgressContainer />
  37. <div className='compose-form__uploads-wrapper'>{uploads}</div>
  38. </div>
  39. );
  40. }
  41. }
  42. export default injectIntl(UploadForm);