闭社主体 forked from https://github.com/tootsuite/mastodon
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.

42 lines
1.1 KiB

  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import Motion from 'react-motion/lib/Motion';
  4. import spring from 'react-motion/lib/spring';
  5. import { FormattedMessage } from 'react-intl';
  6. export default class UploadProgress extends React.PureComponent {
  7. static propTypes = {
  8. active: PropTypes.bool,
  9. progress: PropTypes.number,
  10. };
  11. render () {
  12. const { active, progress } = this.props;
  13. if (!active) {
  14. return null;
  15. }
  16. return (
  17. <div className='upload-progress'>
  18. <div className='upload-progress__icon'>
  19. <i className='fa fa-upload' />
  20. </div>
  21. <div className='upload-progress__message'>
  22. <FormattedMessage id='upload_progress.label' defaultMessage='Uploading...' />
  23. <div className='upload-progress__backdrop'>
  24. <Motion defaultStyle={{ width: 0 }} style={{ width: spring(progress) }}>
  25. {({ width }) =>
  26. <div className='upload-progress__tracker' style={{ width: `${width}%` }} />
  27. }
  28. </Motion>
  29. </div>
  30. </div>
  31. </div>
  32. );
  33. }
  34. }