{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "integrations",
  "title": "Integrations",
  "description": "The tools your product works with around its mark, each joined to it by a beam that draws in the first time it is seen; a tool that is hovered or focused sends a pulse along its beam, or, live, the pulses keep coming one tool at a time.",
  "dependencies": [],
  "registryDependencies": [
    "https://kinoui.com/r/beams.json",
    "https://kinoui.com/r/button.json",
    "https://kinoui.com/r/hero-parts.json",
    "https://kinoui.com/r/hold.json",
    "https://kinoui.com/r/integrations-parts.json",
    "https://kinoui.com/r/section-heading.json",
    "https://kinoui.com/r/tooltip.json",
    "https://kinoui.com/r/theme.json"
  ],
  "files": [
    {
      "path": "registry/components/kino/integrations/integrations.tsx",
      "content": "'use client'\n\nimport {\n  Tooltip,\n  TooltipContent,\n  TooltipGroup,\n  TooltipTrigger,\n} from '@/registry/components/kino/tooltip'\nimport { BeamField, type BeamLayout, type BeamLink, BeamSpot } from '@/registry/lib/beams'\nimport { pageColumnClassName } from '@/registry/lib/hero-parts'\nimport { useHold, useTurns } from '@/registry/lib/hold'\nimport {\n  type Integration,\n  integrationsSectionClassName,\n  type IntegrationsSectionProps,\n  IntegrationTile,\n} from '@/registry/lib/integrations-parts'\nimport { SectionHeading } from '@/registry/lib/section-heading'\nimport { type ComponentProps, type ReactNode, useId, useRef, useState } from 'react'\n\nimport { cn } from '@/lib/utils'\n\n/*\n * The tools your product works with, around your product's mark, each with\n * a beam into it. The beams draw in the first time the picture is seen, and\n * a tool that is hovered or focused lights its beam and sends a pulse along\n * it into the hub, with its name and what it does beside it. `live` keeps\n * pulses coming, one tool at a time, held while the pointer is over it, an\n * item has focus or it is out of view. Under reduced motion the beams stand\n * still. Six to ten tools read best; the rest go behind `actions`.\n *\n *   <Integrations\n *     title='Kino works with the tools you have'\n *     hub={<Logo />}\n *     integrations={[{ value: 'github', name: 'GitHub', description: 'Link pull requests to issues.', logo: { src: '/logos/tools/github.svg', width: 24, height: 24 }, href: '/integrations/github' }]}\n *     actions={<a href='/integrations'>See every integration</a>}\n *   />\n */\n\ninterface IntegrationsProps\n  extends\n    IntegrationsSectionProps,\n    Omit<ComponentProps<'section'>, 'title' | 'children'> {\n  integrations: Integration[]\n  /** Your product's mark, in the middle: a picture, as its name is the page's. */\n  hub: ReactNode\n  /** Under the picture: a link to every integration. */\n  actions?: ReactNode\n  /** Pulses keep coming, one tool at a time, while the picture is in view. */\n  live?: boolean\n}\n\n/** How many `layout` durations pass between pulses when `live`. */\nconst PULSE_EVERY = 2\n\nfunction Integrations({\n  title,\n  eyebrow,\n  description,\n  heading = 'h2',\n  integrations,\n  hub,\n  actions,\n  live = false,\n  className,\n  ...props\n}: IntegrationsProps) {\n  const titleId = useId()\n  const values = integrations.map((integration) => integration.value)\n  const layout = hubLayout(values)\n  const links: BeamLink[] = values.map((value) => ({\n    id: value,\n    from: value,\n    to: HUB,\n    flow: 'forward',\n  }))\n  const [lit, setLit] = useState<string | null>(null)\n  const [pulses, setPulses] = useState<Record<string, number>>({})\n  const pulse = (value: string) =>\n    setPulses((last) => ({ ...last, [value]: (last[value] ?? 0) + 1 }))\n\n  const picture = useRef<HTMLDivElement>(null)\n  const hold = useHold()\n  const turn = useRef(0)\n  useTurns(picture, live && hold.running && values.length > 0, PULSE_EVERY, () => {\n    const order = liveOrder(values.length)\n    const next = values[order[turn.current % order.length] ?? 0]\n    turn.current += 1\n    if (next) pulse(next)\n  })\n\n  return (\n    <section\n      data-slot='integrations'\n      aria-labelledby={titleId}\n      className={cn(integrationsSectionClassName, className)}\n      {...props}\n    >\n      <div\n        className={cn(\n          pageColumnClassName,\n          'flex flex-col items-center gap-10 py-16 @3xl:py-24',\n        )}\n      >\n        <SectionHeading\n          id={titleId}\n          eyebrow={eyebrow}\n          title={title}\n          description={description}\n          heading={heading}\n        />\n        <div ref={picture} className='w-full max-w-3xl' {...hold.handlers}>\n          <TooltipGroup>\n            <BeamField\n              layout={layout}\n              links={links}\n              lit={lit ? [lit] : []}\n              pulses={pulses}\n            >\n              <BeamSpot node={HUB}>\n                <span\n                  aria-hidden\n                  data-slot='integrations-hub'\n                  // Its size follows the picture's width, as the beams do, within a tile's sizes.\n                  className='bg-card text-foreground grid size-[clamp(3.5rem,14cqi,6rem)] place-items-center rounded-(--surface-radius) border shadow-sm [&_svg]:size-1/2'\n                >\n                  {hub}\n                </span>\n              </BeamSpot>\n              <ul aria-labelledby={titleId} className='contents'>\n                {integrations.map((integration) => (\n                  <BeamSpot\n                    key={integration.value}\n                    node={integration.value}\n                    render={<li />}\n                  >\n                    <Tool\n                      integration={integration}\n                      onShow={() => {\n                        setLit(integration.value)\n                        pulse(integration.value)\n                      }}\n                      onHide={() =>\n                        setLit((last) => (last === integration.value ? null : last))\n                      }\n                    />\n                  </BeamSpot>\n                ))}\n              </ul>\n            </BeamField>\n          </TooltipGroup>\n        </div>\n        {actions ? (\n          <div className='flex flex-wrap justify-center gap-3'>{actions}</div>\n        ) : null}\n      </div>\n    </section>\n  )\n}\n\n/** A tool on the picture: its tile, which leads to its page, with its name and line in a tooltip. */\nfunction Tool({\n  integration,\n  onShow,\n  onHide,\n}: {\n  integration: Integration\n  onShow: () => void\n  onHide: () => void\n}) {\n  return (\n    <Tooltip>\n      <TooltipTrigger\n        render={\n          <a\n            href={integration.href}\n            aria-label={integration.name}\n            onPointerEnter={(event) => event.pointerType === 'mouse' && onShow()}\n            onPointerLeave={onHide}\n            // A press focuses the link too: only a keyboard's focus sends its own pulse.\n            onFocus={(event) => event.currentTarget.matches(':focus-visible') && onShow()}\n            onBlur={onHide}\n          />\n        }\n        className='group/tool focus-visible:ring-ring/50 block rounded-(--control-radius-capped) focus-visible:ring-3 focus-visible:outline-hidden'\n      >\n        <IntegrationTile\n          logo={integration.logo}\n          // Its size follows the picture's width, as the beams do, within a tile's sizes.\n          className='size-[clamp(1.75rem,8cqi,3.5rem)] transition-[border-color,box-shadow] duration-(--motion-press-duration) ease-(--motion-press-fade-easing) group-hover/tool:border-muted-foreground/50'\n        />\n      </TooltipTrigger>\n      <TooltipContent className='flex max-w-60 flex-col gap-0.5'>\n        {/* The link has the name already, so a screen reader hears only the line. */}\n        <span aria-hidden className='font-medium'>\n          {integration.name}\n        </span>\n        <span className='opacity-80'>{integration.description}</span>\n      </TooltipContent>\n    </Tooltip>\n  )\n}\n\n/** The hub's node: your product, in the middle. */\nconst HUB = 'hub'\n\n/** How far apart a column's tools sit, in the field's units: room for the smallest tile at a 280px column. */\nconst ROW_PITCH = 100\n\n/**\n * Where the picture puts each tool: half of them in a column on each side\n * of the hub, the first half at the start, top to bottom, `ROW_PITCH` apart,\n * so more tools make a taller picture rather than tiles that overlap. Each\n * column bows towards the hub at its middle, so the beams fan in evenly.\n */\nfunction hubLayout(tools: readonly string[]): BeamLayout {\n  const width = 720\n  const rows = Math.max(1, Math.ceil(tools.length / 2))\n  const height = ROW_PITCH * (rows - 1) + 2 * HUB_MARGIN\n  const middle = height / 2\n  const span = Math.max(1, middle - HUB_MARGIN)\n  const at: BeamLayout['at'] = { [HUB]: { x: width / 2, y: middle } }\n  const columns = [tools.slice(0, rows), tools.slice(rows)]\n  columns.forEach((column, side) => {\n    // A shorter column sits in the middle of the longer one.\n    const top = middle - (ROW_PITCH * (column.length - 1)) / 2\n    column.forEach((tool, row) => {\n      const y = top + row * ROW_PITCH\n      // 70 from the edge at the top and bottom, 130 at the middle.\n      const inset = 70 + 60 * (1 - Math.abs(y - middle) / span)\n      at[tool] = { x: side === 0 ? inset : width - inset, y }\n    })\n  })\n  return { width, height, at }\n}\n\n/** The room above the first row and below the last, in the field's units: half a tile at its largest, and the hub's. */\nconst HUB_MARGIN = 60\n\n/**\n * The order `live` pulses the tools in: a side at a time, the start column\n * and then the end one, each column's rows in turn, the end column half a\n * column on, so no two pulses in a row come from neighbours.\n */\nfunction liveOrder(count: number): number[] {\n  const startCount = Math.ceil(count / 2)\n  const endCount = count - startCount\n  const order: number[] = []\n  for (let turn = 0; turn < startCount; turn++) {\n    order.push(turn)\n    if (endCount > 0)\n      order.push(startCount + ((turn + Math.ceil(endCount / 2)) % endCount))\n  }\n  return [...new Set(order)]\n}\n\nexport { Integrations }\nexport { hubLayout, liveOrder }\n",
      "type": "registry:component",
      "target": "@components/kino/integrations/integrations.tsx"
    }
  ],
  "type": "registry:block"
}