{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "dialog-20",
  "title": "Onboarding dialog",
  "description": "Four steps in one dialog that resizes, with an indicator that travels.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/dialog.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/components/dialog/dialog-20.tsx",
      "content": "'use client';\n\nimport {\n  AnimatePresence,\n  motion,\n  type Transition,\n  type Variants,\n} from 'motion/react';\nimport { useId, useState } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport {\n  ArrowRightIcon,\n  FolderIcon,\n  type Icon,\n  LayoutGridIcon,\n  LifeBuoyIcon,\n  UsersIcon,\n} from '@/registry/ndeko/lib/icons';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport {\n  Dialog,\n  DialogClose,\n  DialogContent,\n  DialogDescription,\n  DialogFooter,\n  DialogHeader,\n  DialogTitle,\n  DialogTrigger,\n} from '@/registry/ndeko/ui/dialog';\n\ntype OnboardingStep = {\n  title: string;\n  description: string;\n  Icon: Icon;\n  hue: string;\n};\n\nconst STEPS: OnboardingStep[] = [\n  {\n    title: 'Welcome to your workspace',\n    description:\n      'Projects, tasks and docs live side by side here. This tour takes less than a minute.',\n    Icon: LayoutGridIcon,\n    hue: 'var(--primary)',\n  },\n  {\n    title: 'Plan with projects',\n    description:\n      'Group tasks into projects, give them a due date and see what is late before anyone asks.',\n    Icon: FolderIcon,\n    hue: 'var(--info)',\n  },\n  {\n    title: 'Invite your team',\n    description:\n      'Teammates join with a link and only see the projects you share with them.',\n    Icon: UsersIcon,\n    hue: 'var(--success)',\n  },\n  {\n    title: 'Get help at any time',\n    description:\n      'Press the question mark key anywhere to see the shortcuts, or write to support from the help menu.',\n    Icon: LifeBuoyIcon,\n    hue: 'var(--warning)',\n  },\n];\n\nconst LAST_STEP_INDEX = STEPS.length - 1;\n\nconst SWAP_TRANSITION: Transition = { duration: 0.15, ease: [0.2, 0, 0, 1] };\nconst TRAVEL_TRANSITION: Transition = {\n  duration: 0.25,\n  ease: [0.77, 0, 0.175, 1],\n};\nconst INSTANT_TRANSITION: Transition = { duration: 0 };\n\nconst GLYPH_VARIANTS: Variants = {\n  enter: { opacity: 0, scale: 0.6, filter: 'blur(2px)' },\n  visible: { opacity: 1, scale: 1, filter: 'blur(0px)' },\n  exit: { opacity: 0, scale: 0.6, filter: 'blur(2px)' },\n};\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 glyphVariantsOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return FADE_VARIANTS;\n  }\n  return GLYPH_VARIANTS;\n}\n\nfunction textVariantsOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return FADE_VARIANTS;\n  }\n  return TEXT_VARIANTS;\n}\n\nfunction travelTransitionOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return INSTANT_TRANSITION;\n  }\n  return TRAVEL_TRANSITION;\n}\n\nexport default function Dialog20() {\n  const indicatorId = useId();\n  const [stepIndex, setStepIndex] = useState(0);\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const glyphVariants = glyphVariantsOf(shouldReduceMotion);\n  const textVariants = textVariantsOf(shouldReduceMotion);\n  const travelTransition = travelTransitionOf(shouldReduceMotion);\n  const step = STEPS[stepIndex];\n  const stepNumber = stepIndex + 1;\n  const isLastStep = stepIndex === LAST_STEP_INDEX;\n  const glyphStyle = { '--gem': step.hue } as React.CSSProperties;\n\n  function restartOnOpen(open: boolean) {\n    if (open) {\n      setStepIndex(0);\n    }\n  }\n\n  function goToNextStep() {\n    setStepIndex((current) => {\n      const next = current + 1;\n      return Math.min(next, LAST_STEP_INDEX);\n    });\n  }\n\n  return (\n    <Dialog onOpenChange={restartOnOpen}>\n      <DialogTrigger render={<Button variant='outline' />}>\n        Start the tour\n      </DialogTrigger>\n      <DialogContent className='p-1' contentClassName='gap-0'>\n        <div className='bg-foreground/[0.03] hairline-ring ring-border flex h-44 items-center justify-center rounded-lg'>\n          <AnimatePresence mode='popLayout' initial={false}>\n            <motion.span\n              key={step.title}\n              aria-hidden='true'\n              style={glyphStyle}\n              className='gem-plate flex size-14 items-center justify-center rounded-2xl'\n              variants={glyphVariants}\n              initial='enter'\n              animate='visible'\n              exit='exit'\n              transition={SWAP_TRANSITION}\n            >\n              <step.Icon className='size-7' />\n            </motion.span>\n          </AnimatePresence>\n        </div>\n        <div className='flex flex-col gap-6 px-4 pt-3 pb-4'>\n          <DialogHeader className='pr-0'>\n            <DialogTitle className='relative'>\n              <AnimatePresence mode='popLayout' initial={false}>\n                <motion.span\n                  key={step.title}\n                  className='block'\n                  variants={textVariants}\n                  initial='enter'\n                  animate='visible'\n                  exit='exit'\n                  transition={SWAP_TRANSITION}\n                >\n                  {step.title}\n                </motion.span>\n              </AnimatePresence>\n            </DialogTitle>\n            <DialogDescription className='relative'>\n              <AnimatePresence mode='popLayout' initial={false}>\n                <motion.span\n                  key={step.title}\n                  className='block'\n                  variants={textVariants}\n                  initial='enter'\n                  animate='visible'\n                  exit='exit'\n                  transition={SWAP_TRANSITION}\n                >\n                  {step.description}\n                </motion.span>\n              </AnimatePresence>\n            </DialogDescription>\n          </DialogHeader>\n          <div className='flex flex-col justify-between gap-4 sm:flex-row sm:items-center'>\n            <div className='flex justify-center gap-1.5 max-sm:order-1'>\n              {STEPS.map((item, index) => (\n                <span\n                  key={item.title}\n                  aria-hidden='true'\n                  className='bg-foreground/15 relative size-1.5 rounded-full'\n                >\n                  {index === stepIndex && (\n                    <motion.span\n                      layoutId={indicatorId}\n                      className='bg-primary absolute inset-0 rounded-full'\n                      transition={travelTransition}\n                    />\n                  )}\n                </span>\n              ))}\n              <span className='sr-only' aria-live='polite'>\n                Step {stepNumber} of {STEPS.length}\n              </span>\n            </div>\n            <DialogFooter>\n              <DialogClose render={<Button variant='outline' size='lg' />}>\n                Skip tour\n              </DialogClose>\n              {isLastStep && (\n                <DialogClose render={<Button size='lg' />}>\n                  Get started\n                </DialogClose>\n              )}\n              {!isLastStep && (\n                <Button size='lg' className='group' onClick={goToNextStep}>\n                  Next\n                  <ArrowRightIcon className='-me-1 opacity-60 transition-transform group-hover:translate-x-0.5' />\n                </Button>\n              )}\n            </DialogFooter>\n          </div>\n        </div>\n      </DialogContent>\n    </Dialog>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "categories": [
    "components",
    "dialog"
  ],
  "type": "registry:component"
}