forked from 77media/video-flow
41 lines
894 B
TypeScript
41 lines
894 B
TypeScript
'use client';
|
|
|
|
import * as React from 'react';
|
|
import { cn } from '@/lib/utils';
|
|
|
|
interface ProgressProps {
|
|
value?: number;
|
|
max?: number;
|
|
className?: string;
|
|
}
|
|
|
|
const Progress = React.forwardRef<HTMLDivElement, ProgressProps>(
|
|
({ className, value = 0, max = 100, ...props }, ref) => {
|
|
const percentage = Math.min(Math.max(0, value), max) / max * 100;
|
|
|
|
return (
|
|
<div
|
|
ref={ref}
|
|
className={cn(
|
|
'relative h-4 w-full overflow-hidden rounded-full bg-secondary',
|
|
className
|
|
)}
|
|
role="progressbar"
|
|
aria-valuemin={0}
|
|
aria-valuemax={max}
|
|
aria-valuenow={value}
|
|
{...props}
|
|
>
|
|
<div
|
|
className="h-full flex-1 bg-primary transition-all"
|
|
style={{ width: `${percentage}%` }}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|
|
);
|
|
|
|
Progress.displayName = "Progress";
|
|
|
|
export { Progress };
|