{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"blur-in-text","type":"registry:block","title":"Blur-in text","description":"A pull quote whose letters sharpen in sequence as it enters the viewport, with the attribution settling in after the last letter.","dependencies":["motion"],"registryDependencies":["utils"],"files":[{"path":"registry/prequel/blur-in-text/blur-in-text.tsx","type":"registry:component","content":"\"use client\";\n\nimport { Fragment, useRef } from \"react\";\nimport {\n  MotionConfig,\n  motion,\n  useInView,\n  useReducedMotion,\n} from \"motion/react\";\nimport { cn } from \"@/lib/utils\";\n\nconst EASE: [number, number, number, number] = [0.22, 1, 0.36, 1];\n\nexport type BlurInTextProps = {\n  className?: string;\n  /** The line whose letters sharpen in sequence. */\n  text?: string;\n  /** Name shown in the attribution line. Leave empty to hide the caption. */\n  name?: string;\n  /** Role and company shown next to the name. */\n  role?: string;\n  /** Seconds between consecutive letters. */\n  stagger?: number;\n};\n\nconst DEFAULT_TEXT =\n  \"Nobody opens a dashboard to admire it. They open it to decide, and the numbers should already be waiting.\";\n\nconst DEFAULT_NAME = \"Ama Mensah\";\nconst DEFAULT_ROLE = \"Head of Analytics, Northwind Labs\";\n\nexport function BlurInText({\n  className,\n  text = DEFAULT_TEXT,\n  name = DEFAULT_NAME,\n  role = DEFAULT_ROLE,\n  stagger = 0.012,\n}: BlurInTextProps) {\n  const rootRef = useRef<HTMLElement>(null);\n  const inView = useInView(rootRef, { once: true, margin: \"-10% 0px\" });\n  const reduce = Boolean(useReducedMotion());\n  const show = inView || reduce;\n\n  const words = text.trim().split(/\\s+/).filter(Boolean);\n  const totalLetters = words.reduce((sum, word) => sum + word.length, 0);\n  const step = Math.max(0, stagger);\n  const captionDelay = Math.min(1.2, totalLetters * step + 0.18);\n\n  const initials = name\n    .trim()\n    .split(/\\s+/)\n    .filter(Boolean)\n    .slice(0, 2)\n    .map((part) => part[0]?.toUpperCase() ?? \"\")\n    .join(\"\");\n\n  let letterIndex = 0;\n\n  return (\n    <MotionConfig reducedMotion=\"user\">\n      <figure\n        ref={rootRef}\n        className={cn(\"w-full max-w-3xl text-left\", className)}\n      >\n        <blockquote>\n          <span className=\"sr-only\">{text}</span>\n          <span\n            aria-hidden=\"true\"\n            className=\"block text-balance text-2xl font-medium leading-snug tracking-tight text-foreground sm:text-3xl md:text-[2.5rem] md:leading-[1.22]\"\n          >\n            {words.map((word, wordIndex) => {\n              const start = letterIndex;\n              letterIndex += word.length;\n              const long = word.length > 14;\n\n              return (\n                <Fragment key={`${word}-${wordIndex}`}>\n                  <span\n                    className={cn(\n                      \"inline-block align-baseline\",\n                      long ? \"max-w-full break-all\" : \"whitespace-nowrap\"\n                    )}\n                  >\n                    {Array.from(word).map((char, charIndex) => {\n                      const index = start + charIndex;\n                      return (\n                        <motion.span\n                          key={`${char}-${charIndex}`}\n                          className=\"inline-block will-change-[filter,opacity,transform]\"\n                          initial={\n                            reduce\n                              ? false\n                              : { opacity: 0, filter: \"blur(7px)\", y: \"0.14em\" }\n                          }\n                          animate={\n                            show\n                              ? { opacity: 1, filter: \"blur(0px)\", y: 0 }\n                              : undefined\n                          }\n                          transition={\n                            reduce\n                              ? { duration: 0 }\n                              : {\n                                  duration: 0.55,\n                                  delay: Math.min(1.1, index * step),\n                                  ease: EASE,\n                                }\n                          }\n                        >\n                          {char}\n                        </motion.span>\n                      );\n                    })}\n                  </span>\n                  {wordIndex < words.length - 1 ? \" \" : null}\n                </Fragment>\n              );\n            })}\n          </span>\n        </blockquote>\n\n        {name || role ? (\n          <motion.figcaption\n            initial={reduce ? false : { opacity: 0, y: 6 }}\n            animate={show ? { opacity: 1, y: 0 } : undefined}\n            transition={\n              reduce\n                ? { duration: 0 }\n                : { duration: 0.5, delay: captionDelay, ease: EASE }\n            }\n            className=\"mt-6 flex flex-wrap items-center gap-x-3 gap-y-2 border-t border-border pt-4\"\n          >\n            {initials ? (\n              <span\n                aria-hidden=\"true\"\n                className=\"grid h-8 w-8 shrink-0 place-items-center rounded-full border border-border bg-muted text-[11px] font-medium tabular-nums text-muted-foreground\"\n              >\n                {initials}\n              </span>\n            ) : null}\n            {name ? (\n              <span className=\"text-[13px] font-medium text-foreground\">\n                {name}\n              </span>\n            ) : null}\n            {role ? (\n              <span className=\"text-[13px] text-muted-foreground\">{role}</span>\n            ) : null}\n          </motion.figcaption>\n        ) : null}\n      </figure>\n    </MotionConfig>\n  );\n}\n\nexport default BlurInText;\n"}]}