{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "focus-grid",
  "type": "registry:ui",
  "title": "Focus Grid",
  "description": "A grid of picture cards where the one you point at or tab to stays bright and the others step back. It helps a reader compare a few visual options (destinations, case studies, chapters) without the grid feeling busy.",
  "author": "ofri-peretz <https://github.com/ofri-peretz>",
  "categories": [
    "marketing",
    "pattern"
  ],
  "dependencies": [],
  "registryDependencies": [
    "https://ds.interlace.tools/r/interlace-base.json",
    "https://ds.interlace.tools/r/cn.json"
  ],
  "files": [
    {
      "path": "registry/interlace-ui/patterns/focus-grid.tsx",
      "target": "components/ui/patterns/focus-grid.tsx",
      "type": "registry:ui",
      "content": "import * as React from 'react';\n\n// @interlace/focus-grid v1.0.0 — Interlace design system.\n// Docs, props and live preview: https://ds.interlace.tools/c/focus-grid\n// What changed since: https://ds.interlace.tools/c/focus-grid#history\n// Generated banner — keep it, the upgrade diff reads this version.\n\n/**\n * @interlace/ui — FocusGrid\n *\n * A grid of picture cards where the one you point at or tab to stays bright\n * and the others step back. It helps a reader compare a few visual options\n * (destinations, case studies, chapters) without the grid feeling busy.\n *\n * ## No JavaScript\n *\n * The whole effect is CSS. The grid uses `:has()` to notice that one of its\n * cards is hovered or holds focus, and dims every other card. There is no\n * state, no event handler and no hydration: it renders on the server and\n * works before scripts load. Browsers without `:has()` simply show every\n * card at full strength.\n *\n * ## Composition\n *\n *   FocusGrid                         (ul — data-slot=\"focus-grid\", columns)\n *     └─ FocusGrid.Item × n           (li > article)\n *         ├─ media                    (any node: img, next/image, video)\n *         ├─ title / description      (text on a scrim over the media)\n *         └─ href?                    (makes the whole card one link)\n *\n * The card's text sits on a dark scrim (`--scrim` / `--scrim-foreground`,\n * which do not invert between schemes) so it stays readable on any picture.\n * With `href`, the title is the link and its hit area covers the card, so\n * there is one tab stop per card and the link's name is the title.\n *\n * ## Motion\n *\n * Dimming is opacity, applied in every mode because it carries the meaning.\n * The soft blur and the small scale only run under `motion-safe:`.\n *\n * | Rule | Concept                 | Where in this file                                   |\n * | ---- | ----------------------- | ---------------------------------------------------- |\n * | R4   | Extends native el       | `ul` / `article` props                                |\n * | R6   | data-slot per part      | focus-grid / -item / -media / -caption                |\n * | R7   | cn + ...rest            | `cn(…, className)` + `{...props}`                     |\n * | R8   | Enums, not booleans     | `columns`, `aspect`                                   |\n * | R14  | Declares min viewport   | `data-min-viewport` + exported const                  |\n * | R19  | Tokens only             | `--scrim`, `--scrim-foreground`, `--ring`             |\n * | R25  | Server component        | no hooks → no `'use client'`                          |\n * | R26  | A11y from native el     | list semantics, one link per card                     |\n */\n\nimport { cn } from '@/lib/utils';\n\nexport const MIN_VIEWPORT = 320 as const;\n\nconst COLUMNS = {\n  2: 'sm:grid-cols-2',\n  3: 'sm:grid-cols-2 lg:grid-cols-3',\n  4: 'sm:grid-cols-2 lg:grid-cols-4',\n} as const;\n\nconst ASPECT = {\n  square: 'aspect-square',\n  portrait: 'aspect-[3/4]',\n  landscape: 'aspect-[4/3]',\n} as const;\n\n/** Every card that is not the hovered or focused one steps back. */\nconst DIM_OTHERS = [\n  '[&:has([data-slot=focus-grid-item]:is(:hover,:focus-within))_[data-slot=focus-grid-item]:not(:hover,:focus-within)]:opacity-55',\n  'motion-safe:[&:has([data-slot=focus-grid-item]:is(:hover,:focus-within))_[data-slot=focus-grid-item]:not(:hover,:focus-within)]:blur-[2px]',\n  'motion-safe:[&:has([data-slot=focus-grid-item]:is(:hover,:focus-within))_[data-slot=focus-grid-item]:not(:hover,:focus-within)]:scale-[0.98]',\n].join(' ');\n\nexport interface FocusGridProps extends React.ComponentProps<'ul'> {\n  /** Columns from `lg` up (two from `sm`, one below). @default 3 */\n  columns?: keyof typeof COLUMNS;\n}\n\nfunction FocusGrid({ columns = 3, className, ...props }: FocusGridProps) {\n  return (\n    <ul\n      data-slot=\"focus-grid\"\n      data-min-viewport={String(MIN_VIEWPORT)}\n      className={cn('grid grid-cols-1 gap-4', COLUMNS[columns], DIM_OTHERS, className)}\n      {...props}\n    />\n  );\n}\n\nexport interface FocusGridItemProps extends Omit<React.ComponentProps<'article'>, 'title'> {\n  /** The picture: an `<img>`, a framework image, a video. Fills the card. */\n  media: React.ReactNode;\n  /** Card title, shown over the media. With `href`, it is the link's name. */\n  title: React.ReactNode;\n  /** One short line under the title. */\n  description?: React.ReactNode;\n  /** Makes the whole card a single link. */\n  href?: string;\n  /** Shape of the card. @default 'portrait' */\n  aspect?: keyof typeof ASPECT;\n  /** Heading level of the title, to fit the page outline. @default 'h3' */\n  as?: 'h2' | 'h3' | 'h4';\n}\n\nfunction FocusGridItem({\n  media,\n  title,\n  description,\n  href,\n  aspect = 'portrait',\n  as: Heading = 'h3',\n  className,\n  ...props\n}: FocusGridItemProps) {\n  return (\n    <li\n      data-slot=\"focus-grid-item\"\n      className=\"motion-safe:transition-[opacity,filter,transform] motion-safe:duration-300 transition-opacity\"\n    >\n      <article\n        className={cn(\n          'focus-within:ring-ring relative isolate overflow-hidden rounded-xl focus-within:ring-[3px]',\n          ASPECT[aspect],\n          className,\n        )}\n        {...props}\n      >\n        <div\n          data-slot=\"focus-grid-media\"\n          className=\"absolute inset-0 -z-10 [&>*]:size-full [&>img]:object-cover [&>video]:object-cover\"\n        >\n          {media}\n        </div>\n        <div\n          data-slot=\"focus-grid-caption\"\n          className=\"from-scrim/85 text-scrim-foreground absolute inset-x-0 bottom-0 bg-linear-to-t to-transparent p-4 pt-12\"\n        >\n          <Heading className=\"font-heading text-lg leading-snug font-semibold text-balance\">\n            {href ? (\n              <a href={href} className=\"outline-none after:absolute after:inset-0\">\n                {title}\n              </a>\n            ) : (\n              title\n            )}\n          </Heading>\n          {description ? <p className=\"mt-1 text-sm opacity-90\">{description}</p> : null}\n        </div>\n      </article>\n    </li>\n  );\n}\n\nconst FocusGridWithDot = Object.assign(FocusGrid, { Item: FocusGridItem });\n\nexport { FocusGridWithDot as FocusGrid, FocusGridItem };\n"
    }
  ],
  "meta": {
    "tier": "pattern",
    "client": false,
    "minViewport": 320,
    "loading": false,
    "version": "1.0.0",
    "since": null
  },
  "docs": "## @interlace/focus-grid\n\nInstalled to `components/ui/patterns/focus-grid.tsx`.\n\n```tsx\nimport { /* … */ } from '@/components/ui/patterns/focus-grid';\n```\n\nProps, a11y contract, live preview and source: https://ds.interlace.tools/c/focus-grid\n\nRequires the `@interlace/interlace-base` CSS baseline (installed automatically as a registry dependency). For the Interlace look, also add `@interlace/theme`."
}
