{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"cta-section","type":"registry:block","title":"CTA Section","description":"A closing call to action with a headline, two actions and a copyable install command. The column settles in with a short stagger, and the copy button swaps to a check with a success border.","dependencies":["motion","lucide-react"],"registryDependencies":["utils"],"files":[{"path":"registry/prequel/cta-section/cta-section.tsx","type":"registry:component","content":"\"use client\";\n\nimport { useEffect, useId, useRef, useState } from \"react\";\nimport {\n  AnimatePresence,\n  MotionConfig,\n  motion,\n  useInView,\n  useReducedMotion,\n} from \"motion/react\";\nimport { ArrowRight, ArrowUpRight, Check, Copy } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nconst EASE: [number, number, number, number] = [0.22, 1, 0.36, 1];\n\nfunction LensMark({ className }: { className?: string }) {\n  return (\n    <svg\n      viewBox=\"0 0 16 16\"\n      aria-hidden=\"true\"\n      focusable=\"false\"\n      className={className}\n      fill=\"none\"\n    >\n      <circle cx=\"8\" cy=\"8\" r=\"5.25\" stroke=\"currentColor\" strokeWidth=\"1.25\" />\n      <circle cx=\"10.4\" cy=\"5.6\" r=\"1.05\" fill=\"currentColor\" />\n    </svg>\n  );\n}\n\nasync function writeToClipboard(text: string) {\n  if (navigator.clipboard?.writeText) {\n    await navigator.clipboard.writeText(text);\n    return;\n  }\n\n  const field = document.createElement(\"textarea\");\n  field.value = text;\n  field.setAttribute(\"readonly\", \"\");\n  field.style.position = \"fixed\";\n  field.style.top = \"-999px\";\n  document.body.appendChild(field);\n  field.select();\n  const copied = document.execCommand(\"copy\");\n  document.body.removeChild(field);\n  if (!copied) throw new Error(\"Copy failed\");\n}\n\nexport type CtaSectionProps = {\n  className?: string;\n  title?: string;\n  description?: string;\n  primaryLabel?: string;\n  primaryHref?: string;\n  secondaryLabel?: string;\n  secondaryHref?: string;\n  /** Command shown in the copyable pill. */\n  installCommand?: string;\n  /** Small line under the install command. */\n  note?: string;\n};\n\nconst DEFAULT_TITLE = \"Build a dashboard worth opening.\";\nconst DEFAULT_DESCRIPTION =\n  \"Free MIT blocks that copy into your project as a single file you own. No runtime, no lock-in.\";\nconst DEFAULT_INSTALL =\n  \"npx shadcn@latest add https://prequelui.terravidhal.me/r/cta-section.json\";\nconst DEFAULT_NOTE = \"MIT licensed — works with any shadcn theme.\";\n\nconst CTA_BUTTON =\n  \"inline-flex h-10 items-center justify-center gap-2 rounded-lg px-4 text-[13px] font-medium transition-colors motion-reduce:transition-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\";\n\nexport function CtaSection({\n  className,\n  title = DEFAULT_TITLE,\n  description = DEFAULT_DESCRIPTION,\n  primaryLabel = \"Browse the blocks\",\n  primaryHref = \"https://prequelui.terravidhal.me/blocks\",\n  secondaryLabel = \"View on GitHub\",\n  secondaryHref = \"https://github.com/prequelui/prequelui\",\n  installCommand = DEFAULT_INSTALL,\n  note = DEFAULT_NOTE,\n}: CtaSectionProps) {\n  const ref = useRef<HTMLElement>(null);\n  const titleId = useId();\n  const inView = useInView(ref, { once: true, margin: \"-10% 0px\" });\n  const reduce = Boolean(useReducedMotion());\n  const opened = inView || reduce;\n\n  const [copied, setCopied] = useState(false);\n\n  useEffect(() => {\n    if (!copied) return;\n    const timer = window.setTimeout(() => setCopied(false), 2000);\n    return () => window.clearTimeout(timer);\n  }, [copied]);\n\n  const handleCopy = async () => {\n    try {\n      await writeToClipboard(installCommand);\n      setCopied(true);\n    } catch {\n      setCopied(false);\n    }\n  };\n\n  const reveal = (delay: number) => ({\n    initial: reduce ? false : { opacity: 0, y: 14 },\n    animate: opened ? { opacity: 1, y: 0 } : { opacity: 0, y: 14 },\n    transition: {\n      duration: reduce ? 0 : 0.6,\n      delay: reduce ? 0 : delay,\n      ease: EASE,\n    },\n  });\n\n  return (\n    <MotionConfig reducedMotion=\"user\">\n      <section\n        ref={ref}\n        aria-labelledby={titleId}\n        className={cn(\n          \"relative w-full overflow-hidden rounded-xl border border-border bg-card text-card-foreground\",\n          className\n        )}\n      >\n        <div className=\"grid gap-8 px-5 py-10 sm:px-8 sm:py-12 lg:grid-cols-[minmax(0,1.15fr)_minmax(0,0.85fr)] lg:items-center lg:gap-12 lg:px-12 lg:py-14\">\n          <div className=\"min-w-0\">\n            <motion.div\n              {...reveal(0)}\n              className=\"flex flex-wrap items-center gap-x-2 gap-y-1 text-[12px] leading-5 text-muted-foreground\"\n            >\n              <LensMark className=\"h-3.5 w-3.5 text-foreground\" />\n              <span className=\"font-medium text-foreground\">\n                PrequelUI 2.4.0\n              </span>\n              <span aria-hidden=\"true\" className=\"text-border\">\n                /\n              </span>\n              <span className=\"tabular-nums\">57 blocks</span>\n              <span aria-hidden=\"true\" className=\"text-border\">\n                /\n              </span>\n              <span className=\"tabular-nums\">4,812 GitHub stars</span>\n            </motion.div>\n\n            <motion.h2\n              id={titleId}\n              {...reveal(0.06)}\n              className=\"mt-4 text-balance text-[28px] font-semibold leading-[1.06] tracking-[-0.04em] sm:text-4xl lg:text-[42px]\"\n            >\n              {title}\n            </motion.h2>\n\n            <motion.p\n              {...reveal(0.12)}\n              className=\"mt-3 max-w-lg text-pretty text-[14px] leading-6 text-muted-foreground sm:text-[15px]\"\n            >\n              {description}\n            </motion.p>\n\n            <motion.div\n              {...reveal(0.18)}\n              className=\"mt-7 flex flex-col items-stretch gap-2.5 sm:flex-row sm:items-center\"\n            >\n              <a\n                href={primaryHref}\n                className={cn(\n                  CTA_BUTTON,\n                  \"group w-full bg-foreground text-background hover:bg-foreground/90 sm:w-auto\"\n                )}\n              >\n                {primaryLabel}\n                <ArrowRight\n                  aria-hidden=\"true\"\n                  className=\"h-3.5 w-3.5 transition-transform duration-300 ease-out group-hover:translate-x-0.5 motion-reduce:transition-none motion-reduce:group-hover:translate-x-0\"\n                />\n              </a>\n              <a\n                href={secondaryHref}\n                className={cn(\n                  CTA_BUTTON,\n                  \"group w-full border border-border bg-background text-foreground hover:bg-muted sm:w-auto\"\n                )}\n              >\n                {secondaryLabel}\n                <ArrowUpRight\n                  aria-hidden=\"true\"\n                  className=\"h-3.5 w-3.5 text-muted-foreground transition-transform duration-300 ease-out group-hover:-translate-y-0.5 group-hover:translate-x-0.5 motion-reduce:transition-none motion-reduce:group-hover:translate-x-0 motion-reduce:group-hover:translate-y-0\"\n                />\n              </a>\n            </motion.div>\n\n            <motion.p\n              {...reveal(0.24)}\n              className=\"mt-5 max-w-md text-[12px] leading-5 text-muted-foreground\"\n            >\n              Teams at{\" \"}\n              <span className=\"text-foreground\">Northwind Labs</span> and{\" \"}\n              <span className=\"text-foreground\">Halo Cloud</span> shipped{\" \"}\n              <span className=\"tabular-nums text-foreground\">2,140</span>{\" \"}\n              dashboards with these blocks this week.\n            </motion.p>\n          </div>\n\n          <motion.div {...reveal(0.16)} className=\"min-w-0\">\n            <div\n              className={cn(\n                \"min-w-0 rounded-lg border bg-background transition-colors duration-300 motion-reduce:transition-none\",\n                copied ? \"border-success/50\" : \"border-border\"\n              )}\n            >\n              <div className=\"flex items-center justify-between gap-3 px-3 pt-3\">\n                <span className=\"truncate text-[12px] font-medium text-foreground\">\n                  Install a block\n                </span>\n                <span className=\"inline-flex shrink-0 items-center gap-1.5 text-[11px] font-medium text-muted-foreground\">\n                  <span\n                    aria-hidden=\"true\"\n                    className=\"h-1.5 w-1.5 rounded-full bg-success\"\n                  />\n                  MIT\n                </span>\n              </div>\n\n              <div className=\"p-1.5 pt-2\">\n                <div\n                  className={cn(\n                    \"flex min-w-0 items-center gap-1.5 rounded-md border bg-muted/40 p-0.5 pl-2.5 transition-colors duration-300 motion-reduce:transition-none\",\n                    copied ? \"border-success/40\" : \"border-border\"\n                  )}\n                >\n                  <span\n                    aria-hidden=\"true\"\n                    className=\"shrink-0 font-mono text-[11px] text-muted-foreground\"\n                  >\n                    $\n                  </span>\n                  <code\n                    title={installCommand}\n                    className=\"min-w-0 flex-1 select-all truncate font-mono text-[11px] leading-8 text-muted-foreground sm:text-[11.5px]\"\n                  >\n                    {installCommand}\n                  </code>\n                  <button\n                    type=\"button\"\n                    onClick={() => void handleCopy()}\n                    aria-label={copied ? \"Copied\" : \"Copy install command\"}\n                    className=\"grid h-8 w-8 shrink-0 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-background hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring motion-reduce:transition-none\"\n                  >\n                    <AnimatePresence initial={false} mode=\"wait\">\n                      <motion.span\n                        key={copied ? \"check\" : \"copy\"}\n                        initial={reduce ? false : { opacity: 0, scale: 0.6 }}\n                        animate={{ opacity: 1, scale: 1 }}\n                        exit={\n                          reduce ? { opacity: 0 } : { opacity: 0, scale: 0.6 }\n                        }\n                        transition={{\n                          duration: reduce ? 0 : 0.16,\n                          ease: EASE,\n                        }}\n                        className={cn(\n                          \"grid place-items-center\",\n                          copied ? \"text-success\" : undefined\n                        )}\n                      >\n                        {copied ? (\n                          <Check aria-hidden=\"true\" className=\"h-3.5 w-3.5\" />\n                        ) : (\n                          <Copy aria-hidden=\"true\" className=\"h-3.5 w-3.5\" />\n                        )}\n                      </motion.span>\n                    </AnimatePresence>\n                  </button>\n                </div>\n              </div>\n\n              <div className=\"flex items-center justify-between gap-3 border-t border-border px-3 py-2.5\">\n                <p className=\"min-w-0 text-[11px] leading-4 text-muted-foreground\">\n                  {note}\n                </p>\n                <span className=\"shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground\">\n                  v2.4.0\n                </span>\n              </div>\n            </div>\n\n            <span aria-live=\"polite\" className=\"sr-only\">\n              {copied ? \"Install command copied to clipboard.\" : \"\"}\n            </span>\n          </motion.div>\n        </div>\n      </section>\n    </MotionConfig>\n  );\n}\n\nexport default CtaSection;\n"}]}