2019-04-21 13:09:52 +03:00
|
|
|
import PropTypes from 'prop-types';
|
2023-05-28 17:38:10 +03:00
|
|
|
import { PureComponent } from 'react';
|
|
|
|
|
|
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
|
|
2019-04-21 13:09:52 +03:00
|
|
|
import spring from 'react-motion/lib/spring';
|
2023-05-28 17:38:10 +03:00
|
|
|
|
2023-11-15 14:19:17 +02:00
|
|
|
import { Icon } from 'flavours/glitch/components/icon';
|
2023-05-28 17:38:10 +03:00
|
|
|
|
|
|
|
import Motion from '../../ui/util/optional_motion';
|
|
|
|
|
2023-05-28 15:18:23 +03:00
|
|
|
export default class UploadProgress extends PureComponent {
|
2019-04-21 13:09:52 +03:00
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
active: PropTypes.bool,
|
|
|
|
progress: PropTypes.number,
|
2022-10-29 21:05:53 +03:00
|
|
|
isProcessing: PropTypes.bool,
|
2019-04-21 13:09:52 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
render () {
|
2022-10-29 21:05:53 +03:00
|
|
|
const { active, progress, isProcessing } = this.props;
|
2019-04-21 13:09:52 +03: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…' />;
|
|
|
|
}
|
|
|
|
|
2019-04-21 13:09:52 +03:00
|
|
|
return (
|
2022-11-06 14:30:37 +02:00
|
|
|
<div className='upload-progress'>
|
|
|
|
<div className='upload-progress__icon'>
|
|
|
|
<Icon id='upload' />
|
|
|
|
</div>
|
2019-04-21 13:09:52 +03:00
|
|
|
|
2022-11-06 14:30:37 +02:00
|
|
|
<div className='upload-progress__message'>
|
2019-08-19 21:53:28 +03:00
|
|
|
{message}
|
2019-04-21 13:09:52 +03:00
|
|
|
|
2022-11-06 14:30:37 +02:00
|
|
|
<div className='upload-progress__backdrop'>
|
2019-04-21 13:09:52 +03:00
|
|
|
<Motion defaultStyle={{ width: 0 }} style={{ width: spring(progress) }}>
|
|
|
|
{({ width }) =>
|
2022-11-06 14:30:37 +02:00
|
|
|
<div className='upload-progress__tracker' style={{ width: `${width}%` }} />
|
2019-04-21 13:09:52 +03:00
|
|
|
}
|
|
|
|
</Motion>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|