"use client"; import { useEffect, useState } from "react"; import { ToggleGroup } from "components/ToggleGroup"; type Page = "drafts" | "posts" | "analytics" | "settings"; const PAGES: { id: Page; label: string }[] = [ { id: "drafts", label: "Drafts" }, { id: "posts", label: "Posts" }, { id: "analytics", label: "Analytics" }, { id: "settings", label: "Settings" }, ]; const AUTOPLAY_INTERVAL_MS = 5000; export function InteractiveAppDemoMobile() { let [page, setPage] = useState("drafts"); let [autoplay, setAutoplay] = useState(true); let [animate, setAnimate] = useState(true); useEffect(() => { if (!autoplay) return; const interval = setInterval(() => { setAnimate(true); setPage((p) => { const idx = PAGES.findIndex((x) => x.id === p); return PAGES[(idx + 1) % PAGES.length].id; }); }, AUTOPLAY_INTERVAL_MS); return () => clearInterval(interval); }, [autoplay]); const handleClick = (id: Page) => { setAnimate(false); setAutoplay(false); setPage(id); }; return (
({ value: p.id, label: p.label }))} />
{PAGES.map((p) => ( {p.id ))}
); }