Files
sorsfonalak/services/frontend/src/components/AnalysisLoading.tsx
T

31 lines
963 B
TypeScript
Raw Normal View History

"use client";
import { useEffect, useState } from "react";
import { ZodiacWheel } from "./ZodiacWheel";
/** Slowly turning wheel with the elapsed time, while the LLM writes. */
export function AnalysisLoading({ title, text, compact = false }: { title?: string; text: string; compact?: boolean }) {
const [seconds, setSeconds] = useState(0);
useEffect(() => {
const t = setInterval(() => setSeconds((s) => s + 1), 1000);
return () => clearInterval(t);
}, []);
const elapsed = `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, "0")}`;
return (
<div className={compact ? "loading loading-compact" : "loading"}>
<ZodiacWheel className="loading-wheel" />
<div className="loading-text">
{title && <strong>{title}</strong>}
<p className="muted" role="status">
{text}
</p>
<p className="hint" aria-hidden="true">
{elapsed}
</p>
</div>
</div>
);
}