{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "popover-05",
  "title": "Tips popover",
  "description": "Short tips read one after another, then start over.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/animated-size.json",
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/motion-number.json",
    "https://ui.ndekocode.dev/r/popover.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/components/popover/popover-05.tsx",
      "content": "'use client';\n\nimport {\n  AnimatePresence,\n  motion,\n  type Transition,\n  type Variants,\n} from 'motion/react';\nimport { useState } from 'react';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { AnimatedSize } from '@/registry/ndeko/ui/animated-size';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport {\n  Popover,\n  PopoverContent,\n  PopoverTrigger,\n} from '@/registry/ndeko/ui/popover';\n\nconst TIPS = [\n  {\n    title: 'Welcome to your dashboard',\n    description:\n      'This is your new workspace. Your projects, recent activity and settings all live here.',\n  },\n  {\n    title: 'Quick actions',\n    description:\n      'Use the toolbar above to create a project, invite a teammate or open the settings.',\n  },\n  {\n    title: 'Need help?',\n    description:\n      'The support icon in the top right corner opens the help center and the documentation.',\n  },\n];\n\nconst SWAP_TRANSITION: Transition = { duration: 0.15, ease: [0.2, 0, 0, 1] };\n\nconst TEXT_VARIANTS: Variants = {\n  enter: { opacity: 0, filter: 'blur(2px)' },\n  visible: { opacity: 1, filter: 'blur(0px)' },\n  exit: { opacity: 0, filter: 'blur(2px)' },\n};\n\nconst FADE_VARIANTS: Variants = {\n  enter: { opacity: 0 },\n  visible: { opacity: 1 },\n  exit: { opacity: 0 },\n};\n\nfunction textVariantsOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return FADE_VARIANTS;\n  }\n  return TEXT_VARIANTS;\n}\n\nfunction nextLabelOf(isLastTip: boolean) {\n  if (isLastTip) {\n    return 'Start over';\n  }\n  return 'Next';\n}\n\nexport default function Popover05() {\n  const [tipIndex, setTipIndex] = useState(0);\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const textVariants = textVariantsOf(shouldReduceMotion);\n  const tip = TIPS[tipIndex];\n  const tipNumber = tipIndex + 1;\n  const isLastTip = tipNumber === TIPS.length;\n  const nextLabel = nextLabelOf(isLastTip);\n\n  function showNextTip() {\n    if (isLastTip) {\n      setTipIndex(0);\n      return;\n    }\n    setTipIndex(tipIndex + 1);\n  }\n\n  return (\n    <Popover>\n      <PopoverTrigger render={<Button variant='outline' />}>\n        Show tips\n      </PopoverTrigger>\n      <PopoverContent side='top' className='flex w-64 flex-col gap-3 p-3'>\n        <AnimatedSize contentClassName='relative flex' aria-live='polite'>\n          <AnimatePresence mode='popLayout' initial={false}>\n            <motion.div\n              key={tipIndex}\n              className='flex flex-col gap-1'\n              variants={textVariants}\n              initial='enter'\n              animate='visible'\n              exit='exit'\n              transition={SWAP_TRANSITION}\n            >\n              <p className='font-medium'>{tip.title}</p>\n              <p className='text-muted-foreground text-xs'>{tip.description}</p>\n            </motion.div>\n          </AnimatePresence>\n        </AnimatedSize>\n        <div className='flex items-center justify-between gap-2'>\n          <span className='text-muted-foreground flex text-xs tabular-nums'>\n            <MotionNumber value={tipNumber} />/{TIPS.length}\n          </span>\n          <Button\n            variant='link'\n            size='sm'\n            onClick={showNextTip}\n            className='h-auto p-0 text-xs'\n          >\n            <AnimatePresence mode='popLayout' initial={false}>\n              <motion.span\n                key={nextLabel}\n                className='flex'\n                variants={textVariants}\n                initial='enter'\n                animate='visible'\n                exit='exit'\n                transition={SWAP_TRANSITION}\n              >\n                {nextLabel}\n              </motion.span>\n            </AnimatePresence>\n          </Button>\n        </div>\n      </PopoverContent>\n    </Popover>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "categories": [
    "components",
    "popover"
  ],
  "type": "registry:component"
}