2022-03-30 07:51:07 -07:00
|
|
|
import React from 'react';
|
|
|
|
import { FormattedMessage } from 'react-intl';
|
2022-03-30 08:22:37 -07:00
|
|
|
import { spring } from 'react-motion';
|
2022-03-30 07:51:07 -07:00
|
|
|
|
2022-03-30 08:22:37 -07:00
|
|
|
import { HStack, Icon, Stack, Text } from 'soapbox/components/ui';
|
2022-03-30 07:51:07 -07:00
|
|
|
import { useAppSelector } from 'soapbox/hooks';
|
|
|
|
|
|
|
|
import Motion from '../../ui/util/optional_motion';
|
|
|
|
|
|
|
|
const UploadProgress = () => {
|
|
|
|
const active = useAppSelector((state) => state.compose.get('is_uploading'));
|
|
|
|
const progress = useAppSelector((state) => state.compose.get('progress'));
|
|
|
|
|
|
|
|
if (!active) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2022-03-30 08:22:37 -07:00
|
|
|
<HStack alignItems='center' space={2}>
|
|
|
|
<Icon
|
|
|
|
src={require('@tabler/icons/icons/cloud-upload.svg')}
|
|
|
|
className='w-7 h-7 text-gray-500'
|
|
|
|
/>
|
|
|
|
|
|
|
|
<Stack space={1}>
|
|
|
|
<Text theme='muted'>
|
|
|
|
<FormattedMessage id='upload_progress.label' defaultMessage='Uploading…' />
|
|
|
|
</Text>
|
|
|
|
|
|
|
|
<div className='w-full h-1.5 rounded-lg bg-gray-200 relative'>
|
2022-03-30 07:51:07 -07:00
|
|
|
<Motion defaultStyle={{ width: 0 }} style={{ width: spring(progress) }}>
|
|
|
|
{({ width }) =>
|
2022-03-30 08:22:37 -07:00
|
|
|
(<div
|
|
|
|
className='absolute left-0 top-0 h-1.5 bg-primary-600 rounded-lg'
|
|
|
|
style={{ width: `${width}%` }}
|
|
|
|
/>)
|
2022-03-30 07:51:07 -07:00
|
|
|
}
|
|
|
|
</Motion>
|
|
|
|
</div>
|
2022-03-30 08:22:37 -07:00
|
|
|
</Stack>
|
|
|
|
</HStack>
|
2022-03-30 07:51:07 -07:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default UploadProgress;
|