2017-05-02 20:04:16 -04:00
|
|
|
import React from 'react';
|
2017-04-21 14:05:35 -04:00
|
|
|
import PropTypes from 'prop-types';
|
2017-05-20 08:58:13 -04:00
|
|
|
import Motion from 'react-motion/lib/Motion';
|
|
|
|
import spring from 'react-motion/lib/spring';
|
2017-03-23 22:50:30 -04:00
|
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
|
|
2017-04-21 14:05:35 -04:00
|
|
|
class UploadProgress extends React.PureComponent {
|
2017-03-23 22:50:30 -04:00
|
|
|
|
2017-05-12 08:44:10 -04:00
|
|
|
static propTypes = {
|
|
|
|
active: PropTypes.bool,
|
2017-05-20 11:31:47 -04:00
|
|
|
progress: PropTypes.number,
|
2017-05-12 08:44:10 -04:00
|
|
|
};
|
|
|
|
|
2017-03-23 22:50:30 -04:00
|
|
|
render () {
|
|
|
|
const { active, progress } = this.props;
|
|
|
|
|
|
|
|
if (!active) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className='upload-progress'>
|
2017-04-22 22:26:55 -04:00
|
|
|
<div className='upload-progress__icon'>
|
2017-03-23 22:50:30 -04:00
|
|
|
<i className='fa fa-upload' />
|
|
|
|
</div>
|
|
|
|
|
2017-04-22 22:26:55 -04:00
|
|
|
<div className='upload-progress__message'>
|
2017-03-23 22:50:30 -04:00
|
|
|
<FormattedMessage id='upload_progress.label' defaultMessage='Uploading...' />
|
|
|
|
|
|
|
|
<div className='upload-progress__backdrop'>
|
|
|
|
<Motion defaultStyle={{ width: 0 }} style={{ width: spring(progress) }}>
|
|
|
|
{({ width }) =>
|
|
|
|
<div className='upload-progress__tracker' style={{ width: `${width}%` }} />
|
|
|
|
}
|
|
|
|
</Motion>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-04-21 14:05:35 -04:00
|
|
|
}
|
|
|
|
|
2017-03-23 22:50:30 -04:00
|
|
|
export default UploadProgress;
|