Function
Loader
({
variant = "square",
interval = 150,
className,
}: {
variant?: keyof typeof LOADER_VARIANTS;
interval?: number;
className?: string;
})
Source from the content-addressed store, hash-verified
| 30 | } as const; |
| 31 | |
| 32 | export const Loader = ({ |
| 33 | variant = "square", |
| 34 | interval = 150, |
| 35 | className, |
| 36 | }: { |
| 37 | variant?: keyof typeof LOADER_VARIANTS; |
| 38 | interval?: number; |
| 39 | className?: string; |
| 40 | }) => { |
| 41 | const [index, setIndex] = useState(0); |
| 42 | const chars = LOADER_VARIANTS[variant]; |
| 43 | |
| 44 | useEffect(() => { |
| 45 | const timer = setInterval(() => { |
| 46 | setIndex((i) => (i + 1) % chars.length); |
| 47 | }, interval); |
| 48 | return () => clearInterval(timer); |
| 49 | }, [chars, interval]); |
| 50 | |
| 51 | return <span className={cn("font-mono", className)}>{chars[index]}</span>; |
| 52 | }; |
| 53 | |
| 54 | export const AssemblyLoader = ({ |
| 55 | interval = 20, |
Callers
nothing calls this directly
Tested by
no test coverage detected