2017-04-21 14:05:35 -04:00
|
|
|
import PropTypes from 'prop-types';
|
2023-05-23 11:15:17 -04:00
|
|
|
import { PureComponent } from 'react';
|
|
|
|
|
|
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
|
|
2024-01-12 05:31:24 -05:00
|
|
|
import UploadFileIcon from '@material-symbols/svg-600/outlined/upload_file.svg?react';
|
2017-05-20 08:58:13 -04:00
|
|
|
import spring from 'react-motion/lib/spring';
|
2023-05-23 11:15:17 -04:00
|
|
|
|
2023-05-08 21:11:56 -04:00
|
|
|
import { Icon } from 'mastodon/components/icon';
|
2023-05-23 11:15:17 -04:00
|
|
|
|
|
|
|
import Motion from '../../ui/util/optional_motion';
|
2017-03-23 22:50:30 -04:00
|
|
|
|
2023-05-23 04:52:27 -04:00
|
|
|
export default class UploadProgress extends 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,
|
2022-10-29 14:05:53 -04:00
|
|
|
isProcessing: PropTypes.bool,
|
2017-05-12 08:44:10 -04:00
|
|
|
};
|
|
|
|
|
2017-03-23 22:50:30 -04:00
|
|
|
render () {
|
2022-10-29 14:05:53 -04:00
|
|
|
const { active, progress, isProcessing } = this.props;
|
2017-03-23 22:50:30 -04:00
|
|
|
|
|
|
|
if (!active) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2022-10-29 14:05:53 -04:00
|
|
|
let message;
|
|
|
|
|
|
|
|
if (isProcessing) {
|
|
|
|
message = <FormattedMessage id='upload_progress.processing' defaultMessage='Processing…' />;
|
|
|
|
} else {
|
|
|
|
message = <FormattedMessage id='upload_progress.label' defaultMessage='Uploading…' />;
|
|
|
|
}
|
|
|
|
|
2017-03-23 22:50:30 -04:00
|
|
|
return (
|
|
|
|
<div className='upload-progress'>
|
2017-04-22 22:26:55 -04:00
|
|
|
<div className='upload-progress__icon'>
|
2023-10-24 13:45:08 -04:00
|
|
|
<Icon id='upload' icon={UploadFileIcon} />
|
2017-03-23 22:50:30 -04:00
|
|
|
</div>
|
|
|
|
|
2017-04-22 22:26:55 -04:00
|
|
|
<div className='upload-progress__message'>
|
2019-08-15 09:13:26 -04:00
|
|
|
{message}
|
2017-03-23 22:50:30 -04: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 14:05:35 -04:00
|
|
|
}
|