'use client'; import * as React from 'react'; import { Progress } from '@/components/ui/progress'; import type * as ProgressPrimitive from '@radix-ui/react-progress'; type Loading_Props = React.ComponentProps & { /** how many ms between updates */ intervalMs?: number; /** fraction of the remaining distance to add each tick */ alpha?: number; }; export const Loading: React.FC = ({ intervalMs = 50, alpha = 0.1, className, ...props }: Loading_Props) => { const [progress, setProgress] = React.useState(0); React.useEffect(() => { const id = window.setInterval(() => { setProgress((prev) => { // compute the next progress const next = prev + (100 - prev) * alpha; // optional: round if you want neat numbers return Math.min(100, Math.round(next * 10) / 10); }); }, intervalMs); return () => window.clearInterval(id); }, [intervalMs, alpha]); return (
); }; export default Loading;