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