diff --git a/app/soapbox/components/ui/progress-bar/progress-bar.tsx b/app/soapbox/components/ui/progress-bar/progress-bar.tsx index 5feadf0a33..3d02e49711 100644 --- a/app/soapbox/components/ui/progress-bar/progress-bar.tsx +++ b/app/soapbox/components/ui/progress-bar/progress-bar.tsx @@ -1,13 +1,32 @@ +import clsx from 'clsx'; import React from 'react'; +import { spring } from 'react-motion'; + +import Motion from 'soapbox/features/ui/util/optional-motion'; interface IProgressBar { - progress: number, + /** Number between 0 and 1 to represent the percentage complete. */ + progress: number + /** Height of the progress bar. */ + size?: 'sm' | 'md' } /** A horizontal meter filled to the given percentage. */ -const ProgressBar: React.FC = ({ progress }) => ( -
-
+const ProgressBar: React.FC = ({ progress, size = 'md' }) => ( +
+ + {({ width }) => ( +
+ )} +
); diff --git a/app/soapbox/components/upload-progress.tsx b/app/soapbox/components/upload-progress.tsx index fe9b84797b..81f5be14ed 100644 --- a/app/soapbox/components/upload-progress.tsx +++ b/app/soapbox/components/upload-progress.tsx @@ -1,13 +1,11 @@ import React from 'react'; import { FormattedMessage } from 'react-intl'; -import { spring } from 'react-motion'; -import { HStack, Icon, Stack, Text } from 'soapbox/components/ui'; -import Motion from 'soapbox/features/ui/util/optional-motion'; +import { HStack, Icon, ProgressBar, Stack, Text } from 'soapbox/components/ui'; interface IUploadProgress { - /** Number between 0 and 1 to represent the percentage complete. */ - progress: number, + /** Number between 0 and 100 to represent the percentage complete. */ + progress: number } /** Displays a progress bar for uploading files. */ @@ -24,16 +22,7 @@ const UploadProgress: React.FC = ({ progress }) => { -
- - {({ width }) => - (
) - } - -
+ ); diff --git a/app/soapbox/features/chats/components/chat-pending-upload.tsx b/app/soapbox/features/chats/components/chat-pending-upload.tsx new file mode 100644 index 0000000000..2694f1bcbc --- /dev/null +++ b/app/soapbox/features/chats/components/chat-pending-upload.tsx @@ -0,0 +1,18 @@ +import React from 'react'; + +import { ProgressBar } from 'soapbox/components/ui'; + +interface IChatPendingUpload { + progress: number +} + +/** Displays a loading thumbnail for an upload in the chat composer. */ +const ChatPendingUpload: React.FC = ({ progress }) => { + return ( +
+ +
+ ); +}; + +export default ChatPendingUpload; \ No newline at end of file diff --git a/app/soapbox/features/chats/components/chat-textarea.tsx b/app/soapbox/features/chats/components/chat-textarea.tsx index 18950300f0..79baa882ea 100644 --- a/app/soapbox/features/chats/components/chat-textarea.tsx +++ b/app/soapbox/features/chats/components/chat-textarea.tsx @@ -1,8 +1,9 @@ import React from 'react'; -import { ProgressBar, Textarea } from 'soapbox/components/ui'; +import { Textarea } from 'soapbox/components/ui'; import { Attachment } from 'soapbox/types/entities'; +import ChatPendingUpload from './chat-pending-upload'; import ChatUpload from './chat-upload'; interface IChatTextarea extends React.ComponentProps { @@ -36,9 +37,7 @@ const ChatTextarea: React.FC = ({ {(!!attachments?.length || isUploading) && (
{isUploading && ( -
- -
+ )} {attachments?.map(attachment => (