Files
supabase/apps/studio/components/ui/ToastLoader.tsx
64e5ba8777 chore: tus optimisations (#28034)
* chore: tus optimisations

* Update apps/studio/localStores/storageExplorer/StorageExplorerStore.tsx

* fix prettier

* remaining time

* fix prettier + change styling

* styling

* remove console.log

* fixed timing

* fix upload progress

* add abort uploads function

* amended chunk-size

* add cancel button

* fix infinity label

* scope aborts to a toast

* abort when cancelled

* fix divide by zero error

* Small style

* eat abort error

---------

Co-authored-by: fenos <fabri.feno@gmail.com>
Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2024-07-19 11:05:58 +08:00

37 lines
918 B
TypeScript

// [Joshen] Just FYI eventually we're going to move to use toasts
// from the UI library, but this is a transition to move everything to
// react-hot-toast while we're trying to deprecate mobx entirely
import { PropsWithChildren } from 'react'
import SparkBar from './SparkBar'
interface ToastLoaderProps {
progress: number
message: string
labelTopOverride?: string
}
export const ToastLoader = ({
progress,
message,
labelTopOverride,
children,
}: PropsWithChildren<ToastLoaderProps>) => {
return (
<div className="flex flex-col gap-2" style={{ minWidth: '220px' }}>
<SparkBar
value={progress}
max={100}
type="horizontal"
barClass="bg-brand"
labelBottom={message}
labelBottomClass="normal-nums"
labelTop={labelTopOverride || `${progress.toFixed(2)}%`}
labelTopClass="tabular-nums"
/>
{children}
</div>
)
}