Function
ChatLoader
({
text = "surfing",
className,
dotClassName,
interval = 200,
}: ChatLoaderProps)
Source from the content-addressed store, hash-verified
| 9 | } |
| 10 | |
| 11 | export function ChatLoader({ |
| 12 | text = "surfing", |
| 13 | className, |
| 14 | dotClassName, |
| 15 | interval = 200, |
| 16 | }: ChatLoaderProps) { |
| 17 | const [dots, setDots] = useState(1); |
| 18 | |
| 19 | useEffect(() => { |
| 20 | const timer = setInterval(() => { |
| 21 | setDots((prev) => (prev % 3) + 1); |
| 22 | }, interval); |
| 23 | |
| 24 | return () => clearInterval(timer); |
| 25 | }, [interval]); |
| 26 | |
| 27 | return ( |
| 28 | <div className={cn("flex items-center font-mono text-xs", className)}> |
| 29 | <span>{text}</span> |
| 30 | <span className={cn("inline-flex ml-1", dotClassName)}> |
| 31 | {".".repeat(dots)} |
| 32 | <span className="invisible">{".".repeat(3 - dots)}</span> |
| 33 | </span> |
| 34 | </div> |
| 35 | ); |
| 36 | } |
Callers
nothing calls this directly
Tested by
no test coverage detected