2017-04-22 04:05:35 +10:00
|
|
|
import PropTypes from 'prop-types';
|
2023-05-24 01:15:17 +10:00
|
|
|
|
|
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
|
|
2017-05-20 22:58:13 +10:00
|
|
|
import spring from 'react-motion/lib/spring';
|
2023-05-24 01:15:17 +10:00
|
|
|
|
2024-01-16 21:27:26 +11:00
|
|
|
import UploadFileIcon from '@/material-icons/400-24px/upload_file.svg?react';
|
2023-05-09 11:11:56 +10:00
|
|
|
import { Icon } from 'mastodon/components/icon';
|
2023-05-24 01:15:17 +10:00
|
|
|
|
|
|
|
import Motion from '../../ui/util/optional_motion';
|
2017-03-24 13:50:30 +11:00
|
|
|
|
2024-03-25 21:29:55 +11:00
|
|
|
export const UploadProgress = ({ active, progress, isProcessing }) => {
|
|
|
|
if (!active) {
|
|
|
|
return null;
|
|
|
|
}
|
2017-03-24 13:50:30 +11:00
|
|
|
|
2024-03-25 21:29:55 +11:00
|
|
|
let message;
|
2022-10-30 05:05:53 +11:00
|
|
|
|
2024-03-25 21:29:55 +11:00
|
|
|
if (isProcessing) {
|
|
|
|
message = <FormattedMessage id='upload_progress.processing' defaultMessage='Processing…' />;
|
|
|
|
} else {
|
|
|
|
message = <FormattedMessage id='upload_progress.label' defaultMessage='Uploading…' />;
|
|
|
|
}
|
2022-10-30 05:05:53 +11:00
|
|
|
|
2024-03-25 21:29:55 +11:00
|
|
|
return (
|
|
|
|
<div className='upload-progress'>
|
|
|
|
<Icon id='upload' icon={UploadFileIcon} />
|
2017-03-24 13:50:30 +11:00
|
|
|
|
2024-03-25 21:29:55 +11:00
|
|
|
<div className='upload-progress__message'>
|
|
|
|
{message}
|
2017-03-24 13:50:30 +11:00
|
|
|
|
2024-03-25 21:29:55 +11:00
|
|
|
<div className='upload-progress__backdrop'>
|
|
|
|
<Motion defaultStyle={{ width: 0 }} style={{ width: spring(progress) }}>
|
|
|
|
{({ width }) =>
|
|
|
|
<div className='upload-progress__tracker' style={{ width: `${width}%` }} />
|
|
|
|
}
|
|
|
|
</Motion>
|
2017-03-24 13:50:30 +11:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-03-25 21:29:55 +11:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
UploadProgress.propTypes = {
|
|
|
|
active: PropTypes.bool,
|
|
|
|
progress: PropTypes.number,
|
|
|
|
isProcessing: PropTypes.bool,
|
|
|
|
};
|