import { useEffect, useState } from 'react'; import { motion } from 'motion/react'; import { Button } from '@workspace/ui/components/ui/button'; import { type Frames, MotionGrid } from '@/registry/components/motion-grid'; import { RotatingText } from '@/registry/text/rotating'; const importingFrames = [ [[2, 2]], [ [1, 2], [2, 1], [2, 3], [3, 2], ], [ [2, 2], [0, 2], [1, 1], [1, 3], [2, 0], [2, 4], [3, 1], [3, 3], [4, 2], ], [ [0, 1], [0, 3], [1, 0], [1, 2], [1, 4], [2, 1], [2, 3], [3, 0], [3, 2], [3, 4], [4, 1], [4, 3], ], [ [0, 0], [0, 2], [0, 4], [1, 1], [1, 3], [2, 0], [2, 2], [2, 4], [3, 1], [3, 3], [4, 0], [4, 2], [4, 4], ], [ [0, 1], [0, 3], [1, 0], [1, 2], [1, 4], [2, 1], [2, 3], [3, 0], [3, 2], [3, 4], [4, 1], [4, 3], ], [ [0, 0], [0, 2], [0, 4], [1, 1], [1, 3], [2, 0], [2, 4], [3, 1], [3, 3], [4, 0], [4, 2], [4, 4], ], [ [0, 1], [1, 0], [3, 0], [4, 1], [0, 3], [1, 4], [3, 4], [4, 3], ], [ [0, 0], [0, 4], [4, 0], [4, 4], ], [], ] as Frames; const arrowDownFrames = [ [[2, 0]], [ [1, 0], [2, 0], [3, 0], [2, 1], ], [ [2, 0], [1, 1], [2, 1], [3, 1], [2, 2], ], [ [2, 0], [2, 1], [1, 2], [2, 2], [3, 2], [2, 3], ], [ [2, 1], [2, 2], [1, 3], [2, 3], [3, 3], [2, 4], ], [ [2, 2], [2, 3], [1, 4], [2, 4], [3, 4], ], [ [2, 3], [2, 4], ], [[2, 4]], [], ] as Frames; const arrowUpFrames = [ [[2, 4]], [ [1, 4], [2, 4], [3, 4], [2, 3], ], [ [2, 4], [1, 3], [2, 3], [3, 3], [2, 2], ], [ [2, 4], [2, 3], [1, 2], [2, 2], [3, 2], [2, 1], ], [ [2, 3], [2, 2], [1, 1], [2, 1], [3, 1], [2, 0], ], [ [2, 2], [2, 1], [1, 0], [2, 0], [3, 0], ], [ [2, 1], [2, 0], ], [[2, 0]], [], ] as Frames; const syncingFrames = [...arrowDownFrames, ...arrowUpFrames] as Frames; const searchingFrames = [ [ [1, 0], [0, 1], [1, 1], [2, 1], [1, 2], ], [ [2, 0], [1, 1], [2, 1], [3, 1], [2, 2], ], [ [3, 0], [2, 1], [3, 1], [4, 1], [3, 2], ], [ [3, 1], [2, 2], [3, 2], [4, 2], [3, 3], ], [ [3, 2], [2, 3], [3, 3], [4, 3], [3, 4], ], [ [1, 2], [0, 3], [1, 3], [2, 3], [1, 4], ], [ [0, 0], [0, 1], [0, 2], [1, 0], [1, 2], [2, 0], [2, 1], [2, 2], ], [], ] as Frames; const busyFrames = [ [ [0, 1], [0, 2], [0, 3], [1, 2], [4, 1], [4, 2], [4, 3], ], [ [0, 1], [0, 2], [0, 3], [2, 3], [4, 2], [4, 3], [4, 4], ], [ [0, 1], [0, 2], [0, 3], [3, 4], [4, 2], [4, 3], [4, 4], ], [ [0, 1], [0, 2], [0, 3], [2, 3], [4, 2], [4, 3], [4, 4], ], [ [0, 0], [0, 1], [0, 2], [1, 2], [4, 2], [4, 3], [4, 4], ], [ [0, 0], [0, 1], [0, 2], [2, 1], [4, 1], [4, 2], [4, 3], ], [ [0, 0], [0, 1], [0, 2], [3, 0], [4, 0], [4, 1], [4, 2], ], [ [0, 1], [0, 2], [0, 3], [2, 1], [4, 0], [4, 1], [4, 2], ], ] as Frames; const savingFrames = [ [ [0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [1, 0], [1, 1], [1, 2], [1, 3], [2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [3, 0], [3, 1], [3, 2], [3, 3], [4, 0], [4, 1], [4, 2], [4, 3], [4, 4], ], [ [0, 0], [0, 1], [0, 2], [0, 3], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [2, 3], [3, 0], [3, 1], [3, 2], [4, 0], [4, 1], [4, 2], [4, 3], ], [ [0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [2, 0], [2, 1], [2, 2], [3, 0], [3, 1], [4, 0], [4, 1], [4, 2], [4, 4], [3, 4], [2, 4], [1, 4], [0, 4], ], [ [0, 0], [0, 1], [1, 0], [2, 0], [2, 1], [3, 0], [4, 0], [4, 1], [4, 3], [3, 3], [2, 3], [1, 3], [0, 3], [4, 4], [3, 4], [2, 4], [1, 4], [0, 4], ], [ [0, 0], [2, 0], [4, 0], [4, 2], [3, 2], [2, 2], [1, 2], [0, 2], [4, 3], [3, 3], [2, 3], [1, 3], [0, 3], [4, 4], [3, 4], [2, 4], [1, 4], [0, 4], ], [ [0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [4, 1], [3, 1], [2, 1], [1, 1], [0, 1], [4, 2], [3, 2], [2, 2], [1, 2], [0, 2], [4, 3], [3, 3], [2, 3], [1, 3], [0, 3], [4, 4], [3, 4], [2, 4], [1, 4], [0, 4], ], [ [0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [4, 1], [3, 1], [2, 1], [1, 1], [0, 1], [4, 2], [3, 2], [2, 2], [1, 2], [0, 2], [4, 3], [3, 3], [2, 3], [1, 3], [0, 3], [4, 4], [3, 4], [2, 4], [1, 4], [0, 4], ], [ [0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [4, 1], [3, 1], [2, 1], [1, 1], [0, 1], [4, 2], [3, 2], [2, 2], [1, 2], [0, 2], [4, 3], [3, 3], [2, 3], [1, 3], [0, 3], [4, 4], [3, 4], [2, 4], [1, 4], [0, 4], ], ] as Frames; const initializingFrames = [ [], [ [1, 0], [3, 0], ], [ [1, 0], [3, 0], [0, 1], [1, 1], [2, 1], [3, 1], [4, 1], ], [ [1, 0], [3, 0], [0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [0, 2], [1, 2], [2, 2], [3, 2], [4, 2], ], [ [1, 0], [3, 0], [0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [0, 2], [1, 2], [2, 2], [3, 2], [4, 2], [1, 3], [2, 3], [3, 3], ], [ [1, 0], [3, 0], [0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [0, 2], [1, 2], [2, 2], [3, 2], [4, 2], [1, 3], [2, 3], [3, 3], [2, 4], ], [ [1, 2], [2, 1], [2, 2], [2, 3], [3, 2], ], [[2, 2]], [], ] as Frames; const states = { importing: { frames: importingFrames, label: 'Importing', }, syncing: { frames: syncingFrames, label: 'Syncing', }, searching: { frames: searchingFrames, label: 'Searching', }, busy: { frames: busyFrames, label: 'Busy', }, saving: { frames: savingFrames, label: 'Saving', }, initializing: { frames: initializingFrames, label: 'Initializing', }, }; const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); export const MotionGridDemo = () => { const [state, setState] = useState('importing'); const runStates = async () => { while (true) { for (const state of Object.keys(states) as (keyof typeof states)[]) { setState(state); await sleep(3000); } } }; useEffect(() => { runStates(); }, []); return ( ); };