{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ctas-02",
  "title": "Install command card",
  "description": "A card with a package manager switch, the matching install command and a copy button whose icon swaps to a check.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/tabs.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/tooltip.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/blocks/ctas/ctas-02/index.tsx",
      "content": "'use client';\n\nimport { useState } from 'react';\n\nimport { ArrowRightIcon, CodeIcon } from '@/registry/ndeko/lib/icons';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Tabs, TabsList, TabsTab } from '@/registry/ndeko/ui/tabs';\n\nimport { CommandRow } from './command-row';\nimport {\n  CARD,\n  DEFAULT_MANAGER,\n  INSTALL_COMMANDS,\n  type InstallCommand,\n  type PackageManagerId,\n} from './data';\n\nfunction isPackageManagerId(value: unknown): value is PackageManagerId {\n  return INSTALL_COMMANDS.some((entry) => entry.id === value);\n}\n\nfunction commandOf(id: PackageManagerId) {\n  const found = INSTALL_COMMANDS.find((entry) => entry.id === id);\n  const fallback: InstallCommand = INSTALL_COMMANDS[0];\n  const entry = found ?? fallback;\n  return entry.command;\n}\n\nexport default function Ctas02() {\n  const [manager, setManager] = useState<PackageManagerId>(DEFAULT_MANAGER);\n  const command = commandOf(manager);\n\n  function changeManager(value: unknown) {\n    if (isPackageManagerId(value)) {\n      setManager(value);\n    }\n  }\n\n  return (\n    <section className='px-4 py-12 sm:px-6 sm:py-16 lg:px-8'>\n      <div className='bg-card hairline-ring ring-border dark:bg-foreground/[0.03] mx-auto grid max-w-4xl gap-8 rounded-xl p-6 shadow-[0_1px_2px_rgb(0_0_0/0.04)] sm:p-8 md:grid-cols-[minmax(0,1fr)_minmax(0,1.1fr)] md:items-center md:gap-10'>\n        <div className='flex flex-col items-start gap-4'>\n          <span className='keycap-3d text-muted-foreground flex size-9 items-center justify-center rounded-lg'>\n            <CodeIcon />\n          </span>\n          <div className='flex flex-col gap-2'>\n            <p className='text-primary-ink text-xs font-medium'>\n              {CARD.eyebrow}\n            </p>\n            <h2 className='text-xl font-semibold text-balance'>{CARD.title}</h2>\n            <p className='text-muted-foreground text-sm text-pretty'>\n              {CARD.description}\n            </p>\n          </div>\n        </div>\n        <div className='flex min-w-0 flex-col gap-3'>\n          <Tabs value={manager} onValueChange={changeManager}>\n            <TabsList variant='segmented' aria-label='Package manager'>\n              {INSTALL_COMMANDS.map((entry) => (\n                <TabsTab key={entry.id} value={entry.id}>\n                  {entry.label}\n                </TabsTab>\n              ))}\n            </TabsList>\n          </Tabs>\n          <CommandRow command={command} />\n          <div className='flex flex-wrap gap-x-5 gap-y-1'>\n            {CARD.links.map((link) => (\n              <Button\n                key={link.label}\n                variant='link'\n                className='h-auto px-0'\n                nativeButton={false}\n                render={<a href={link.href} />}\n              >\n                {link.label}\n                <ArrowRightIcon className='size-3.5' />\n              </Button>\n            ))}\n          </div>\n        </div>\n      </div>\n    </section>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/ctas-02/index.tsx"
    },
    {
      "path": "registry/ndeko/blocks/ctas/ctas-02/command-row.tsx",
      "content": "'use client';\n\nimport {\n  AnimatePresence,\n  motion,\n  type Transition,\n  type Variants,\n} from 'motion/react';\nimport { useEffect, useState } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { CheckIcon, CopyIcon } from '@/registry/ndeko/lib/icons';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport {\n  Tooltip,\n  TooltipContent,\n  TooltipTrigger,\n} from '@/registry/ndeko/ui/tooltip';\n\ntype CopyState = 'idle' | 'copied' | 'failed';\n\nconst COPIED_RESET_MS = 1500;\n\nconst SWAP_TRANSITION: Transition = { duration: 0.15, ease: [0.2, 0, 0, 1] };\n\nconst ICON_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 iconVariantsOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return FADE_VARIANTS;\n  }\n  return ICON_VARIANTS;\n}\n\nfunction textVariantsOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return FADE_VARIANTS;\n  }\n  return TEXT_VARIANTS;\n}\n\nfunction copyGlyphOf(isCopied: boolean) {\n  if (isCopied) {\n    return {\n      key: 'copied',\n      icon: <CheckIcon className='text-success-foreground' />,\n    };\n  }\n  return { key: 'copy', icon: <CopyIcon /> };\n}\n\nfunction copyLabelOf(isCopied: boolean) {\n  if (isCopied) {\n    return 'Copied';\n  }\n  return 'Copy the command';\n}\n\nexport function CommandRow({ command }: { command: string }) {\n  const [copyState, setCopyState] = useState<CopyState>('idle');\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const iconVariants = iconVariantsOf(shouldReduceMotion);\n  const textVariants = textVariantsOf(shouldReduceMotion);\n  const isCopied = copyState === 'copied';\n  const hasFailed = copyState === 'failed';\n  const glyph = copyGlyphOf(isCopied);\n  const copyLabel = copyLabelOf(isCopied);\n\n  useEffect(() => {\n    if (!isCopied) {\n      return;\n    }\n    const timeout = window.setTimeout(() => {\n      setCopyState('idle');\n    }, COPIED_RESET_MS);\n    return () => window.clearTimeout(timeout);\n  }, [isCopied]);\n\n  async function copyCommand() {\n    try {\n      await navigator.clipboard.writeText(command);\n      setCopyState('copied');\n    } catch {\n      setCopyState('failed');\n    }\n  }\n\n  return (\n    <div className='flex flex-col gap-2'>\n      <div className='bg-foreground/[0.04] hairline-ring ring-border flex h-11 items-center gap-2 rounded-lg ps-3.5 pe-1.5'>\n        <code className='relative flex min-w-0 flex-1 overflow-hidden font-mono text-[13px]'>\n          <AnimatePresence mode='popLayout' initial={false}>\n            <motion.span\n              key={command}\n              className='truncate'\n              variants={textVariants}\n              initial='enter'\n              animate='visible'\n              exit='exit'\n              transition={SWAP_TRANSITION}\n            >\n              {command}\n            </motion.span>\n          </AnimatePresence>\n        </code>\n        <Tooltip>\n          <TooltipTrigger\n            delay={0}\n            render={\n              <Button\n                variant='ghost'\n                size='icon'\n                onClick={copyCommand}\n                aria-label={copyLabel}\n              />\n            }\n          >\n            <AnimatePresence mode='popLayout' initial={false}>\n              <motion.span\n                key={glyph.key}\n                className='flex'\n                variants={iconVariants}\n                initial='enter'\n                animate='visible'\n                exit='exit'\n                transition={SWAP_TRANSITION}\n              >\n                {glyph.icon}\n              </motion.span>\n            </AnimatePresence>\n          </TooltipTrigger>\n          <TooltipContent>{copyLabel}</TooltipContent>\n        </Tooltip>\n      </div>\n      <p aria-live='polite' className='text-destructive-ink min-h-4 text-xs'>\n        {hasFailed &&\n          'Copying is blocked in this window, select the command and copy it by hand'}\n      </p>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/ctas-02/command-row.tsx"
    },
    {
      "path": "registry/ndeko/blocks/ctas/ctas-02/data.ts",
      "content": "export type PackageManagerId = 'npm' | 'pnpm' | 'yarn' | 'bun';\n\nexport type InstallCommand = {\n  id: PackageManagerId;\n  label: string;\n  command: string;\n};\n\nexport const INSTALL_COMMANDS: InstallCommand[] = [\n  { id: 'npm', label: 'npm', command: 'npm install @fernpost/sdk' },\n  { id: 'pnpm', label: 'pnpm', command: 'pnpm add @fernpost/sdk' },\n  { id: 'yarn', label: 'yarn', command: 'yarn add @fernpost/sdk' },\n  { id: 'bun', label: 'bun', command: 'bun add @fernpost/sdk' },\n];\n\nexport const DEFAULT_MANAGER: PackageManagerId = 'npm';\n\nexport const CARD = {\n  eyebrow: 'Fernpost SDK',\n  title: 'Send your first issue from code',\n  description:\n    'Install the SDK, keep your API key on the server and publish drafts from any script, CMS or scheduled job.',\n  links: [\n    { label: 'Read the quickstart', href: '#' },\n    { label: 'Browse the API reference', href: '#' },\n  ],\n};\n",
      "type": "registry:component",
      "target": "components/blocks/ctas-02/data.ts"
    }
  ],
  "categories": [
    "blocks",
    "ctas"
  ],
  "type": "registry:block"
}