{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "dynamic-island-demo", "registryDependencies": [ "dynamic-island" ], "files": [ { "path": "registry/default/example/dynamic-island-demo.tsx", "content": "\"use client\"\n\nimport { createContext, useContext } from \"react\"\nimport {\n ArrowUpLeftSquareIcon,\n Loader,\n Mail,\n MessageCircle,\n MousePointerClickIcon,\n User,\n Waves,\n} from \"lucide-react\"\nimport { motion, useReducedMotion } from \"motion/react\"\n\nimport { Badge } from \"@/components/ui/badge\"\nimport { Button } from \"@/components/ui/button\"\nimport {\n DynamicContainer,\n DynamicDescription,\n DynamicDiv,\n DynamicIsland,\n DynamicIslandProvider,\n DynamicTitle,\n SizePresets,\n useDynamicIslandSize,\n useScheduledAnimations,\n} from \"@/registry/default/ui/dynamic-island\"\n\nconst DynamicAction = () => {\n const { state: blobState, setSize } = useDynamicIslandSize()\n\n const blobStates: SizePresets[] = [\n \"compact\",\n \"large\",\n \"tall\",\n \"long\",\n \"medium\",\n ]\n\n const cycleBlobStates = () => {\n const currentIndex = blobStates.indexOf(blobState.size)\n const nextIndex = (currentIndex + 1) % blobStates.length\n setSize(blobStates[nextIndex])\n }\n\n useScheduledAnimations([\n { size: \"compact\", delay: 1000 },\n { size: \"large\", delay: 1200 },\n { size: \"tall\", delay: 1600 },\n { size: \"long\", delay: 1800 },\n { size: \"medium\", delay: 2200 },\n ])\n\n // Provide dynamic detail in such a beautiful small place :)\n const renderCompactState = () => (\n \n
\n \n \n \n\n \n newcult.co\n \n
\n
\n )\n\n // Great for call to action, popping up in users face :)\n const renderLargeState = () => (\n \n
\n \n\n \n loading\n \n
\n
\n )\n\n // Great for user onboarding, forms, etc\n const renderTallState = () => (\n \n \n The Cult of Pythagoras\n \n \n Music of the Spheres, an idea that celestial bodies produce a form of\n music through their movements\n \n\n \n any cool cults?\n \n \n )\n\n const renderLongState = () => (\n \n \n
\n \n
\n\n \n Supercalifragilisticexpialid\n \n
\n
\n )\n\n const renderMediumState = () => (\n \n \n Reincarnation, welcome back\n \n \n Good for small tasks or call outs\n \n\n \n \n\n \n \n \n )\n\n // Render function for other states\n const renderOtherStates = () => (\n
\n
\n \n
\n

cycle states

\n
\n )\n\n // Main render logic based on size\n function renderState() {\n switch (blobState.size) {\n case \"compact\":\n return renderCompactState()\n case \"large\":\n return renderLargeState()\n case \"tall\":\n return renderTallState()\n case \"medium\":\n return renderMediumState()\n case \"long\":\n return renderLongState()\n // Optionally add cases for other states as necessary\n default:\n return renderOtherStates()\n }\n }\n\n return (\n
\n
\n
\n {/* {!blobState.isAnimating ? ( */}\n \n \n Click to cycle states\n \n {/* ) : null} */}\n
\n
\n
\n prev - {blobState.previousSize}\n cur -{blobState.size}\n
\n
\n\n {renderState()}\n
\n
\n )\n}\n\nexport default function DynamicIslandDemo() {\n return (\n \n
\n \n
\n
\n )\n}\n\nconst FadeInStaggerContext = createContext(false)\n\nconst viewport = { once: true, margin: \"0px 0px -200px\" }\n\nexport function FadeIn(props: any) {\n let shouldReduceMotion = useReducedMotion()\n let isInStaggerGroup = useContext(FadeInStaggerContext)\n\n return (\n \n )\n}\n\nexport function FadeInStagger({ faster = false, ...props }) {\n return (\n \n \n \n )\n}\n", "type": "registry:component" } ], "type": "registry:component" }