'use client'; import styles from '@components/BlockLoader.module.css'; import * as React from 'react'; const SEQUENCES = [ ['⠁', '⠂', '⠄', '⡀', '⢀', '⠠', '⠐', '⠈'], ['⣾', '⣽', '⣻', '⢿', '⡿', '⣟', '⣯', '⣷'], ['▖', '▘', '▝', '▗'], ['▁', '▂', '▃', '▄', '▅', '▆', '▇', '█', '▇', '▆', '▅', '▄', '▃', '▁'], ['▉', '▊', '▋', '▌', '▍', '▎', '▏', '▎', '▍', '▌', '▋', '▊', '▉'], ['←', '↖', '↑', '↗', '→', '↘', '↓', '↙'], ['┤', '┘', '┴', '└', '├', '┌', '┬', '┐'], ['◢', '◣', '◤', '◥'], ['◰', '◳', '◲', '◱'], ['◴', '◷', '◶', '◵'], ['◐', '◓', '◑', '◒'], ]; interface BlockLoaderProps extends Omit, 'children'> { mode?: number; } const BlockLoader: React.FC = ({ mode = 0 }) => { if (!SEQUENCES[mode]) { return ; } const [index, setIndex] = React.useState(0); const intervalRef = React.useRef(null); const indexLength = SEQUENCES[mode].length; React.useEffect(() => { if (intervalRef.current) { clearInterval(intervalRef.current); } intervalRef.current = window.setInterval(() => { setIndex((prevIndex) => (prevIndex + 1) % indexLength); }, 100); return () => { if (intervalRef.current) { clearInterval(intervalRef.current); } }; }, [indexLength]); return {SEQUENCES[mode][index]}; }; export default BlockLoader;