diff --git a/apps/designer/app/designer/features/sidebar-left/panels/components/thumbnail.tsx b/apps/designer/app/designer/features/sidebar-left/panels/components/thumbnail.tsx index 2383f86139..6ec9751a9e 100644 --- a/apps/designer/app/designer/features/sidebar-left/panels/components/thumbnail.tsx +++ b/apps/designer/app/designer/features/sidebar-left/panels/components/thumbnail.tsx @@ -1,17 +1,11 @@ import { useEffect, useState } from "react"; -import { - Box, - Button, - Flex, - ProgressBar, - Tooltip, -} from "@webstudio-is/design-system"; -import { useInterval } from "react-use"; +import { Box, Button, Flex, Tooltip } from "@webstudio-is/design-system"; import placeholderImage from "~/shared/images/image-placeholder.svg"; import brokenImage from "~/shared/images/broken-image-placeholder.svg"; import { useSubmit } from "@remix-run/react"; import { Asset } from "~/designer/features/sidebar-left/types"; import { Cross2Icon } from "@radix-ui/react-icons"; +import { UploadingAnimation } from "./uploading-animation"; const useImageWithFallback = ({ path }: { path: string }) => { const [src, setSrc] = useState(placeholderImage); @@ -26,28 +20,6 @@ const useImageWithFallback = ({ path }: { path: string }) => { return src; }; -const useFakeProgress = ({ - isUploading, - isDeleting, -}: { - isUploading: boolean; - isDeleting: boolean; -}) => { - const [progressBarPercentage, setProgressBarPercentage] = useState(0); - - // @todo rewrite this fake indication to show real progress - useInterval( - () => { - setProgressBarPercentage((percentage) => - percentage < 60 ? percentage + 1 : percentage - ); - }, - isUploading || isDeleting ? 100 : null - ); - - return progressBarPercentage; -}; - export const AssetManagerThumbnail = ({ path, alt, @@ -60,7 +32,6 @@ export const AssetManagerThumbnail = ({ const isUploading = status === "uploading"; const src = useImageWithFallback({ path }); const [isTooltipOpen, setTolltipOpen] = useState(false); - const progressBarPercentage = useFakeProgress({ isUploading, isDeleting }); const closeTooltip = () => setTolltipOpen(false); @@ -131,11 +102,7 @@ export const AssetManagerThumbnail = ({ )} {(isUploading || isDeleting) && ( - + )} ); diff --git a/apps/designer/app/designer/features/sidebar-left/panels/components/uploading-animation.tsx b/apps/designer/app/designer/features/sidebar-left/panels/components/uploading-animation.tsx new file mode 100644 index 0000000000..06831c7a2a --- /dev/null +++ b/apps/designer/app/designer/features/sidebar-left/panels/components/uploading-animation.tsx @@ -0,0 +1,61 @@ +import { useState } from "react"; +import { useInterval } from "react-use"; + +const useFakeProgress = ({ + isUploading, + isDeleting, +}: { + isUploading: boolean; + isDeleting: boolean; +}) => { + const [progressBarPercentage, setProgressBarPercentage] = useState(0); + + // @todo rewrite this fake indication to show real progress + useInterval( + () => { + setProgressBarPercentage((percentage) => + percentage < 100 ? percentage + 1 : percentage + ); + }, + isUploading || isDeleting ? 100 : null + ); + + return progressBarPercentage; +}; + +export const UploadingAnimation = ({ + isUploading, + isDeleting, +}: { + isUploading: boolean; + isDeleting: boolean; +}) => { + const progressBarPercentage = useFakeProgress({ isUploading, isDeleting }); + return ( + + + + + + ); +}; diff --git a/packages/asset-uploader/src/schema.ts b/packages/asset-uploader/src/schema.ts index d9124afdb3..12205c9724 100644 --- a/packages/asset-uploader/src/schema.ts +++ b/packages/asset-uploader/src/schema.ts @@ -29,5 +29,5 @@ export const fsEnvVariables = z.object({ }); export const assetEnvVariables = z.object({ - MAX_UPLOAD_SIZE: z.string().optional().default("1"), + MAX_UPLOAD_SIZE: z.string().optional().default("10"), });