feat(ui): add indeterminate mode to Progress
Desktop's core-download dialog needs to show progress while the server returns no Content-Length (some mirrors omit it; the SnowLuma core release artifact does have it but GitHub's CDN sometimes strips it on redirects). Hard-coded 50% was a placeholder. Add an `indeterminate` boolean prop: when true, render a marquee bar that animates left-to-right indefinitely. When false, render the familiar bytes-done / bytes-total fill at `value%`. Hooked up via a new `@keyframes progress-marquee` in theme.css. Also dropped the bar's CSS transition from 500ms → 200ms so live download updates feel responsive instead of laggy.
This commit is contained in:
2 files changed
+39
-8
No files matched your search
@@ -4,28 +4,50 @@ import { cn } from '../lib/cn';
|
|||||||
interface ProgressProps extends React.HTMLAttributes<HTMLDivElement> {
|
interface ProgressProps extends React.HTMLAttributes<HTMLDivElement> {
|
||||||
value?: number;
|
value?: number;
|
||||||
indicatorClassName?: string;
|
indicatorClassName?: string;
|
||||||
|
/**
|
||||||
|
* When true, the bar shows an animated marquee instead of a fixed
|
||||||
|
* width — useful when we know a job is running but don't yet know
|
||||||
|
* the total size (e.g. a download whose Content-Length is unknown).
|
||||||
|
*/
|
||||||
|
indeterminate?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Progress = React.forwardRef<HTMLDivElement, ProgressProps>(
|
const Progress = React.forwardRef<HTMLDivElement, ProgressProps>(
|
||||||
({ className, value = 0, indicatorClassName, ...props }, ref) => {
|
({ className, value = 0, indicatorClassName, indeterminate = false, ...props }, ref) => {
|
||||||
const clamped = Math.max(0, Math.min(100, value));
|
const clamped = Math.max(0, Math.min(100, value));
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
ref={ref}
|
ref={ref}
|
||||||
role="progressbar"
|
role="progressbar"
|
||||||
aria-valuenow={clamped}
|
aria-valuenow={indeterminate ? undefined : clamped}
|
||||||
aria-valuemin={0}
|
aria-valuemin={0}
|
||||||
aria-valuemax={100}
|
aria-valuemax={100}
|
||||||
className={cn('relative h-2 w-full overflow-hidden rounded-full bg-muted', className)}
|
className={cn(
|
||||||
|
'relative h-2 w-full overflow-hidden rounded-full bg-muted',
|
||||||
|
className,
|
||||||
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
<div
|
{indeterminate ? (
|
||||||
className={cn('h-full rounded-full bg-primary transition-[width] duration-500 ease-out', indicatorClassName)}
|
<div
|
||||||
style={{ width: `${clamped}%` }}
|
className={cn(
|
||||||
/>
|
'absolute inset-y-0 left-0 w-1/3 rounded-full bg-primary',
|
||||||
|
'animate-[progress-marquee_1.4s_ease-in-out_infinite]',
|
||||||
|
indicatorClassName,
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
'h-full rounded-full bg-primary transition-[width] duration-200 ease-out',
|
||||||
|
indicatorClassName,
|
||||||
|
)}
|
||||||
|
style={{ width: `${clamped}%` }}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
Progress.displayName = 'Progress';
|
Progress.displayName = 'Progress';
|
||||||
|
|
||||||
|
|||||||
@@ -247,3 +247,12 @@
|
|||||||
-webkit-backdrop-filter: saturate(180%) blur(12px);
|
-webkit-backdrop-filter: saturate(180%) blur(12px);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@keyframes progress-marquee {
|
||||||
|
0% {
|
||||||
|
transform: translateX(-100%);
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
transform: translateX(400%);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user