2017-05-03 01:04:16 +01:00
|
|
|
import React from 'react';
|
2017-04-21 19:05:35 +01:00
|
|
|
import PropTypes from 'prop-types';
|
2017-10-16 08:36:15 +01:00
|
|
|
import Motion from '../../ui/util/optional_motion';
|
2017-05-20 13:58:13 +01:00
|
|
|
import spring from 'react-motion/lib/spring';
|
2017-03-24 02:50:30 +00:00
|
|
|
import { FormattedMessage } from 'react-intl';
|
2019-01-31 23:14:05 +00:00
|
|
|
import Icon from 'mastodon/components/icon';
|
2017-03-24 02:50:30 +00:00
|
|
|
|
2017-06-23 18:36:54 +01:00
|
|
|
export default class UploadProgress extends React.PureComponent {
|
2017-03-24 02:50:30 +00:00
|
|
|
|
2017-05-12 13:44:10 +01:00
|
|
|
static propTypes = {
|
|
|
|
active: PropTypes.bool,
|
2017-05-20 16:31:47 +01:00
|
|
|
progress: PropTypes.number,
|
2017-05-12 13:44:10 +01:00
|
|
|
};
|
|
|
|
|
2017-03-24 02:50:30 +00:00
|
|
|
render () {
|
|
|
|
const { active, progress } = this.props;
|
|
|
|
|
|
|
|
if (!active) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className='upload-progress'>
|
2017-04-23 03:26:55 +01:00
|
|
|
<div className='upload-progress__icon'>
|
2019-01-31 23:14:05 +00:00
|
|
|
<Icon id='upload' />
|
2017-03-24 02:50:30 +00:00
|
|
|
</div>
|
|
|
|
|
2017-04-23 03:26:55 +01:00
|
|
|
<div className='upload-progress__message'>
|
2017-03-24 02:50:30 +00: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 19:05:35 +01:00
|
|
|
}
|