{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "card-library-cards-masonry",
  "type": "registry:block",
  "title": "Masonry cards",
  "description": "Workspace card from the overtrue/ui workspace examples. Editable source, scoped styles, and demo interactions.",
  "categories": [
    "cards",
    "workspace"
  ],
  "registryDependencies": [
    "https://ui.overtrue.xyz/r/overtrue-card-foundation.json"
  ],
  "files": [
    {
      "path": "src/blocks/registry/library-cards-masonry.tsx",
      "type": "registry:component",
      "target": "components/overtrue/blocks/library-cards-masonry.tsx",
      "content": "\"use client\";\nimport { BlockFrame } from \"./runtime/blocks/frame\";\nimport \"./runtime/cards.css\";\n// Extracted from src/components/overtrue/scenes/library.tsx:182.\nimport { useEffect, useRef, useState } from \"react\";\nimport { Link } from \"react-router-dom\";\nimport { FileBrowser } from \"./runtime/registry/overtrue/file-browser\";\nimport { IconLayoutGrid, IconList } from \"@tabler/icons-react\";\nimport { projects } from \"./runtime/data/workspace/studio\";\nimport {\n  SearchField,\n  FilterTabs,\n  Action,\n  Pill,\n} from \"./runtime/components/overtrue/scenes/shared\";\nconst assets = [\n  ...projects.map((p, i) => ({\n    title: p.client,\n    category: i % 2 ? \"Identity\" : \"Photography\",\n    image: p.image,\n  })),\n  ...Array.from({ length: 6 }, (_, i) => ({\n    title: [\n      \"Studio stationery\",\n      \"Seasonal publication\",\n      \"Visitor guide\",\n      \"Member toolkit\",\n      \"Launch directions\",\n      \"Research notes\",\n    ][i],\n    category: \"Design\",\n    image: `https://ui.overtrue.xyz/assets/overtrue/project-${String(i + 7).padStart(2, \"0\")}.webp`,\n  })),\n];\nfunction CardExample({\n  id = \"cards-masonry\",\n  masonry = true,\n}: {\n  id?: string;\n  title?: string;\n  masonry?: boolean;\n} = {}) {\n  const [view, setView] = useState(\"Grid\");\n  const [selectedIds, setSelectedIds] = useState<string[]>([]);\n  const dialogRef = useRef<HTMLDialogElement>(null);\n  const previewTriggerRef = useRef<HTMLButtonElement>(null);\n  const searchRef = useRef<HTMLInputElement>(null);\n  const [query, setQuery] = useState(\"\");\n  const [filter, setFilter] = useState(\"All assets\");\n  const [selected, setSelected] = useState<(typeof assets)[number] | null>(\n    null,\n  );\n  const shown = assets.filter(\n    (a) =>\n      (filter === \"All assets\" || a.category === filter) &&\n      a.title.toLowerCase().includes(query.trim().toLowerCase()),\n  );\n  const movePreview = (direction: number) => {\n    if (!selected || !shown.length) return;\n    const index = shown.indexOf(selected);\n    setSelected(shown[(index + direction + shown.length) % shown.length]);\n  };\n  const closePreview = () => {\n    dialogRef.current?.close();\n    setSelected(null);\n    previewTriggerRef.current?.focus();\n  };\n  useEffect(() => {\n    if (selected) dialogRef.current?.showModal();\n  }, [selected]);\n  return (\n    <>\n      <div className=\"overtrue-block-content\" data-workspace-page={id}>\n        <div className=\"scene-page-tabs\">\n          <Link\n            to=\"/gallery\"\n            aria-current={\n              id === \"gallery\" || id === \"lightbox\" ? \"page\" : undefined\n            }\n          >\n            All files\n          </Link>\n          <Link\n            to=\"/photogrid\"\n            aria-current={id === \"photogrid\" ? \"page\" : undefined}\n          >\n            Photo collection\n          </Link>\n          <Link\n            to=\"/cards-masonry\"\n            aria-current={id === \"cards-masonry\" ? \"page\" : undefined}\n          >\n            Moodboards\n          </Link>\n          <span className=\"scene-tabs-context\">\n            {assets.length} shared assets\n          </span>\n        </div>\n        <div className=\"scene-toolbar\">\n          <FilterTabs\n            items={[\"All assets\", \"Photography\", \"Identity\", \"Design\"]}\n            value={filter}\n            onChange={setFilter}\n          />\n          <SearchField\n            ref={searchRef}\n            value={query}\n            onChange={setQuery}\n            placeholder=\"Search the library…\"\n          />\n        </div>\n        <div className=\"scene-toolbar\">\n          <span>\n            {selectedIds.length\n              ? `${selectedIds.length} selected`\n              : `${shown.length} assets`}{\" \"}\n            · Acme Studio\n          </span>\n          <div className=\"scene-view-switch\" aria-label=\"Asset view\">\n            <button\n              aria-pressed={view === \"Grid\"}\n              onClick={() => setView(\"Grid\")}\n            >\n              <IconLayoutGrid size={16} />\n              Grid\n            </button>\n            <button\n              aria-pressed={view === \"List\"}\n              onClick={() => setView(\"List\")}\n            >\n              <IconList size={16} />\n              List\n            </button>\n          </div>\n        </div>\n        {selectedIds.length > 0 && (\n          <div className=\"scene-selection-bar\">\n            <span>{selectedIds.length} files selected</span>\n            <Action onClick={() => setSelectedIds([])}>Clear selection</Action>\n          </div>\n        )}\n        {!shown.length && (\n          <div className=\"scene-empty-search\">\n            <h3>No assets found</h3>\n            <p>Try another search or browse all categories.</p>\n            <Action\n              onClick={() => {\n                setQuery(\"\");\n                setFilter(\"All assets\");\n                searchRef.current?.focus();\n              }}\n            >\n              Clear filters\n            </Action>\n          </div>\n        )}\n        {view === \"List\" ? (\n          <FileBrowser\n            files={shown.map((asset) => ({\n              id: asset.image,\n              name: asset.title,\n              kind: \"image\",\n              preview: asset.image,\n              downloadUrl: asset.image,\n              owner: asset.category,\n              updated: \"Sep 21, 2026\",\n            }))}\n            selectedIds={selectedIds}\n            onSelectionChange={setSelectedIds}\n            onOpen={(file) => {\n              if (document.activeElement instanceof HTMLButtonElement)\n                previewTriggerRef.current = document.activeElement;\n              setSelected(\n                assets.find((asset) => asset.image === file.id) ?? null,\n              );\n            }}\n          />\n        ) : (\n          <div\n            className={\n              id === \"photogrid\"\n                ? \"scene-library is-photo-grid\"\n                : masonry\n                  ? \"scene-library is-masonry\"\n                  : \"scene-library\"\n            }\n          >\n            {shown.map((a) => (\n              <button\n                key={a.title}\n                onClick={(event) => {\n                  previewTriggerRef.current = event.currentTarget;\n                  setSelected(a);\n                }}\n              >\n                <img src={a.image} alt={a.title} />\n                <span>\n                  <strong>{a.title}</strong>\n                  <small>{a.category} · Acme Studio</small>\n                  {id === \"cards-masonry\" && (\n                    <p>\n                      {a.category === \"Photography\"\n                        ? \"A study of spaces, surfaces, and the details that make a place feel welcoming.\"\n                        : \"A considered visual direction, from the first idea to a useful set of working assets.\"}\n                    </p>\n                  )}\n                </span>\n              </button>\n            ))}\n          </div>\n        )}\n        {selected && (\n          <dialog\n            ref={dialogRef}\n            onKeyDown={(event) => {\n              if (event.key === \"ArrowRight\" || event.key === \"ArrowLeft\") {\n                event.preventDefault();\n                movePreview(event.key === \"ArrowRight\" ? 1 : -1);\n              }\n            }}\n            onCancel={(event) => {\n              event.preventDefault();\n              closePreview();\n            }}\n            onClick={(e) => {\n              if (e.target === e.currentTarget) closePreview();\n            }}\n            aria-label={selected.title}\n            className=\"scene-asset-dialog\"\n          >\n            <header>\n              <div>\n                <h2>{selected.title}</h2>\n                <Pill>{selected.category}</Pill>\n              </div>\n              <Action onClick={closePreview}>Close preview</Action>\n            </header>\n            <img src={selected.image} alt={selected.title} />\n            <footer>\n              <div className=\"scene-asset-controls\">\n                <Action onClick={() => movePreview(-1)}>Previous asset</Action>\n                <span>\n                  {shown.indexOf(selected) + 1} / {shown.length}\n                </span>\n                <Action onClick={() => movePreview(1)}>Next asset</Action>\n              </div>\n              <a className=\"scene-button\" href={selected.image} download>\n                Download asset\n              </a>\n            </footer>\n          </dialog>\n        )}\n      </div>\n    </>\n  );\n}\n\nexport default function Block() { return <BlockFrame><CardExample /></BlockFrame>; }\n"
    }
  ],
  "docs": "Documentation: https://ui.overtrue.xyz/blocks/library-cards-masonry. Includes the shared card foundation and hosted demo imagery. Replace sample data and navigation with your application data."
}
