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