{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "mood-board-canvas",
  "title": "Mood Board Canvas",
  "description": "An editable visual reference board with image, palette and typography tiles, drag reordering, keyboard-friendly move controls and reference editing.",
  "dependencies": [
    "lucide-react",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/mood-board-canvas/mood-board-canvas.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { Layers, Plus, X, ArrowUp, ArrowDown } from \"lucide-react\";\nimport { clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction Frame({\n  name,\n  title,\n  description,\n  theme,\n  className,\n  toolbar,\n  children,\n}: {\n  name: string;\n  title: string;\n  description: string;\n  theme: \"dark\" | \"light\";\n  className?: string;\n  toolbar?: React.ReactNode;\n  children: React.ReactNode;\n}) {\n  const dark = theme === \"dark\";\n  return (\n    <section\n      aria-label={name}\n      className={twMerge(\n        clsx(\n          \"w-full overflow-hidden rounded-xl border font-sans antialiased\",\n          className,\n        ),\n      )}\n      style={\n        {\n          background: dark ? \"#111113\" : \"#fcfcfd\",\n          color: dark ? \"#e5e5e8\" : \"#28282e\",\n          borderColor: dark ? \"#ffffff12\" : \"#18181b16\",\n          \"--board-panel\": dark ? \"#19191d\" : \"#ffffff\",\n          \"--board-canvas\": dark ? \"#0e0e10\" : \"#f6f6f8\",\n          \"--board-input\": dark ? \"#222227\" : \"#efeff3\",\n          \"--board-accent\": dark ? \"#a49aee\" : \"#6857ac\",\n        } as React.CSSProperties\n      }\n    >\n      <header className=\"flex items-center justify-between border-b border-current/[0.07] px-6 py-3 text-[11px]\">\n        <span className=\"flex items-center gap-2\">\n          <Layers size={14} className=\"opacity-45\" />\n          <span className=\"opacity-50\">Workspace</span>\n          <span className=\"px-1 opacity-20\">/</span>\n          {name}\n        </span>\n        <span className=\"flex size-6 items-center justify-center rounded-full border border-current/10 text-[9px] opacity-60\">\n          AL\n        </span>\n      </header>\n      <div className=\"px-6 pb-5 pt-6\">\n        <p className=\"mb-2 text-[9px] tracking-[0.14em] opacity-35\">\n          PRODUCT WORKSPACE\n        </p>\n        <h2 className=\"text-[23px] font-medium tracking-[-0.035em]\">{title}</h2>\n        <p className=\"mt-2 text-xs leading-relaxed opacity-45\">{description}</p>\n      </div>\n      {toolbar && (\n        <div className=\"flex flex-wrap items-center justify-between gap-3 border-y border-current/[0.07] px-6 py-3\">\n          {toolbar}\n        </div>\n      )}\n      {children}\n    </section>\n  );\n}\nconst button =\n  \"inline-flex items-center justify-center gap-1.5 rounded-md border border-current/10 px-2.5 py-1.5 text-[11px] transition-colors hover:bg-current/5 focus-visible:outline-2 focus-visible:outline-offset-2 disabled:cursor-not-allowed disabled:opacity-25\";\nconst primary =\n  \"inline-flex items-center justify-center gap-1.5 rounded-md border border-white/15 bg-[#6e67d4] px-3 py-1.5 text-[11px] font-medium text-white hover:bg-[#7a73df] focus-visible:outline-2 focus-visible:outline-offset-2\";\nconst input =\n  \"min-w-0 rounded-md border border-current/10 bg-[var(--board-input)] px-3 py-2 text-xs outline-none focus:border-[#9690da]\";\n\nexport interface MoodTile {\n  id: string;\n  type: \"image\" | \"palette\" | \"text\";\n  title: string;\n  content: string;\n  colors?: string[];\n}\nexport interface MoodBoardCanvasProps {\n  title?: string;\n  theme?: \"dark\" | \"light\";\n  initialTiles?: MoodTile[];\n  onTilesChange?: (tiles: MoodTile[]) => void;\n  className?: string;\n}\nconst initial: MoodTile[] = [\n  {\n    id: \"m1\",\n    type: \"image\",\n    title: \"Quiet architecture\",\n    content:\n      \"https://images.unsplash.com/photo-1600210492486-724fe5c67fb0?auto=format&fit=crop&w=700&q=85\",\n  },\n  {\n    id: \"m2\",\n    type: \"palette\",\n    title: \"Soft structure\",\n    content: \"A little warmth. A clear point of view.\",\n    colors: [\"#d9d5cb\", \"#9caa9a\", \"#6e7184\", \"#32343b\", \"#b7a2d5\"],\n  },\n  {\n    id: \"m3\",\n    type: \"text\",\n    title: \"Type direction\",\n    content: \"Less, but\\nbetter.\",\n  },\n  {\n    id: \"m4\",\n    type: \"image\",\n    title: \"Natural rhythm\",\n    content:\n      \"https://images.unsplash.com/photo-1441974231531-c6227db76b6e?auto=format&fit=crop&w=700&q=85\",\n  },\n  {\n    id: \"m5\",\n    type: \"text\",\n    title: \"The feeling\",\n    content: \"Calm. Considered.\\nA little unexpected.\",\n  },\n  {\n    id: \"m6\",\n    type: \"image\",\n    title: \"Room to breathe\",\n    content:\n      \"https://images.unsplash.com/photo-1494438639946-1ebd1d20bf85?auto=format&fit=crop&w=700&q=85\",\n  },\n];\nexport function MoodBoardCanvas({\n  title = \"A direction worth exploring.\",\n  theme = \"dark\",\n  initialTiles = initial,\n  onTilesChange,\n  className,\n}: MoodBoardCanvasProps) {\n  const [tiles, setTiles] = React.useState(() =>\n    initialTiles.map((tile) => ({ ...tile })),\n  );\n  const [filter, setFilter] = React.useState(\"all\");\n  const [selected, setSelected] = React.useState<string | null>(null);\n  const [adding, setAdding] = React.useState(false);\n  const [kind, setKind] = React.useState<MoodTile[\"type\"]>(\"image\");\n  const [name, setName] = React.useState(\"\");\n  const [content, setContent] = React.useState(\"\");\n  const [notice, setNotice] = React.useState(\"\");\n  const dragged = React.useRef<string | null>(null);\n  const current = React.useRef(tiles);\n  const update = (next: MoodTile[]) => {\n    current.current = next;\n    setTiles(next);\n    onTilesChange?.(next);\n  };\n  const move = (id: string, delta: number) => {\n    const next = [...current.current];\n    const index = next.findIndex((tile) => tile.id === id);\n    const target = index + delta;\n    if (target < 0 || target >= next.length) return;\n    [next[index], next[target]] = [next[target], next[index]];\n    update(next);\n  };\n  const visible = tiles.filter(\n    (tile) => filter === \"all\" || tile.type === filter,\n  );\n  const active = tiles.find((tile) => tile.id === selected);\n  const patch = (id: string, values: Partial<MoodTile>) =>\n    update(\n      current.current.map((tile) =>\n        tile.id === id ? { ...tile, ...values } : tile,\n      ),\n    );\n  const add = (event: React.FormEvent) => {\n    event.preventDefault();\n    if (!name.trim() || !content.trim()) return;\n    const id = crypto.randomUUID();\n    update([\n      ...current.current,\n      {\n        id,\n        type: kind,\n        title: name.trim(),\n        content: kind === \"palette\" ? \"Custom palette\" : content.trim(),\n        ...(kind === \"palette\"\n          ? {\n              colors: content\n                .split(\",\")\n                .map((value) => value.trim())\n                .filter((value) => /^#[0-9a-f]{6}$/i.test(value)),\n            }\n          : {}),\n      },\n    ]);\n    setSelected(id);\n    setFilter(\"all\");\n    setAdding(false);\n    setName(\"\");\n    setContent(\"\");\n  };\n  return (\n    <Frame\n      name=\"Mood board\"\n      title={title}\n      description=\"Gather references. Find the thread that ties everything together.\"\n      theme={theme}\n      className={className}\n      toolbar={\n        <>\n          <div\n            role=\"group\"\n            aria-label=\"Filter references\"\n            className=\"flex gap-1\"\n          >\n            {[\"all\", \"image\", \"palette\", \"text\"].map((type) => (\n              <button\n                key={type}\n                className={button}\n                aria-pressed={filter === type}\n                onClick={() => setFilter(type)}\n                style={{\n                  background:\n                    filter === type ? \"var(--board-input)\" : undefined,\n                }}\n              >\n                {\n                  (\n                    {\n                      all: \"All references\",\n                      image: \"Images\",\n                      palette: \"Colors\",\n                      text: \"Typography\",\n                    } as Record<string, string>\n                  )[type]\n                }\n              </button>\n            ))}\n          </div>\n          <button\n            className={primary}\n            onClick={() => setAdding(!adding)}\n            aria-expanded={adding}\n          >\n            <Plus size={13} /> Add reference\n          </button>\n        </>\n      }\n    >\n      {adding && (\n        <form\n          onSubmit={add}\n          className=\"grid gap-3 border-b border-current/10 p-5 sm:grid-cols-2\"\n        >\n          <input\n            aria-label=\"Reference title\"\n            className={input}\n            placeholder=\"Reference title\"\n            value={name}\n            onChange={(event) => setName(event.target.value)}\n            required\n            maxLength={80}\n          />\n          <select\n            aria-label=\"Reference type\"\n            className={input}\n            value={kind}\n            onChange={(event) =>\n              setKind(event.target.value as MoodTile[\"type\"])\n            }\n          >\n            <option value=\"image\">Image URL</option>\n            <option value=\"text\">Text</option>\n            <option value=\"palette\">Color palette</option>\n          </select>\n          <input\n            aria-label=\"Reference content\"\n            type={kind === \"image\" ? \"url\" : \"text\"}\n            pattern={\n              kind === \"palette\"\n                ? \"#[0-9A-Fa-f]{6}(, *#[0-9A-Fa-f]{6})*\"\n                : undefined\n            }\n            className={input}\n            placeholder={\n              kind === \"palette\"\n                ? \"#9690da, #79a798, #18181b\"\n                : kind === \"image\"\n                  ? \"https://…\"\n                  : \"Words to set the direction\"\n            }\n            value={content}\n            onChange={(event) => setContent(event.target.value)}\n            required\n          />\n          <div className=\"flex gap-2\">\n            <button className={primary} type=\"submit\">\n              Add to board\n            </button>\n            <button\n              className={button}\n              type=\"button\"\n              onClick={() => setAdding(false)}\n            >\n              Cancel\n            </button>\n          </div>\n        </form>\n      )}\n      <div className=\"grid gap-4 bg-[var(--board-canvas)] p-5 sm:grid-cols-2 lg:grid-cols-3\">\n        {visible.map((tile) => (\n          <article\n            key={tile.id}\n            draggable\n            onDragStart={() => {\n              dragged.current = tile.id;\n            }}\n            onDragEnd={() => {\n              dragged.current = null;\n            }}\n            onDragOver={(event) => event.preventDefault()}\n            onDrop={(event) => {\n              event.preventDefault();\n              const from = current.current.findIndex(\n                (item) => item.id === dragged.current,\n              );\n              const to = current.current.findIndex(\n                (item) => item.id === tile.id,\n              );\n              if (from < 0 || from === to) return;\n              const next = [...current.current];\n              const [item] = next.splice(from, 1);\n              next.splice(to, 0, item);\n              update(next);\n              dragged.current = null;\n            }}\n            className=\"overflow-hidden rounded-lg border bg-[var(--board-panel)]\"\n            style={{\n              borderColor: selected === tile.id ? \"#9690da90\" : \"#88888820\",\n            }}\n          >\n            <button\n              aria-label={`Select reference ${tile.title}`}\n              className=\"block w-full text-left focus-visible:outline-2 focus-visible:outline-offset-[-3px]\"\n              onClick={() => setSelected(selected === tile.id ? null : tile.id)}\n            >\n              {tile.type === \"image\" ? (\n                <div\n                  role=\"img\"\n                  aria-label={tile.title}\n                  className=\"h-[190px] bg-cover bg-center\"\n                  style={{\n                    backgroundColor: \"#303038\",\n                    backgroundImage: `url(${JSON.stringify(tile.content)})`,\n                  }}\n                />\n              ) : tile.type === \"palette\" ? (\n                <div className=\"flex h-[190px]\">\n                  {(tile.colors ?? []).map((color, i) => (\n                    <div\n                      key={i}\n                      className=\"flex flex-1 items-end justify-center pb-4\"\n                      style={{ background: color }}\n                    >\n                      <span className=\"rounded bg-black/30 px-1 py-0.5 text-[8px] text-white\">\n                        {color}\n                      </span>\n                    </div>\n                  ))}\n                </div>\n              ) : (\n                <div\n                  className=\"flex h-[190px] items-center px-6\"\n                  style={{\n                    background:\n                      tile.id === \"m3\"\n                        ? \"#d8d5ca\"\n                        : theme === \"dark\"\n                          ? \"#25242e\"\n                          : \"#eeecf4\",\n                    color: tile.id === \"m3\" ? \"#35352f\" : undefined,\n                  }}\n                >\n                  <p className=\"whitespace-pre-wrap font-serif text-[30px] leading-tight tracking-tight\">\n                    {tile.content}\n                  </p>\n                </div>\n              )}\n              <div className=\"flex items-center justify-between px-3 py-3\">\n                <span className=\"text-[11px] font-medium\">{tile.title}</span>\n                <span className=\"text-[9px] capitalize opacity-35\">\n                  {tile.type}\n                </span>\n              </div>\n            </button>\n            <div className=\"flex items-center justify-between border-t border-current/[0.06] px-2 py-1.5\">\n              <span className=\"px-1 text-[9px] opacity-30\">\n                REFERENCE {String(tiles.indexOf(tile) + 1).padStart(2, \"0\")}\n              </span>\n              <div className=\"flex gap-1\">\n                <button\n                  aria-label={`Move ${tile.title} earlier`}\n                  disabled={tiles.indexOf(tile) === 0}\n                  onClick={() => move(tile.id, -1)}\n                  className=\"rounded p-1 disabled:opacity-20\"\n                >\n                  <ArrowUp size={12} />\n                </button>\n                <button\n                  aria-label={`Move ${tile.title} later`}\n                  disabled={tiles.indexOf(tile) === tiles.length - 1}\n                  onClick={() => move(tile.id, 1)}\n                  className=\"rounded p-1 disabled:opacity-20\"\n                >\n                  <ArrowDown size={12} />\n                </button>\n              </div>\n            </div>\n          </article>\n        ))}\n        {!visible.length && (\n          <p className=\"col-span-full p-8 text-center text-xs opacity-45\">\n            No references yet. Add the first piece of your direction.\n          </p>\n        )}\n      </div>\n      {active && (\n        <div className=\"flex flex-wrap items-center gap-3 border-t border-current/10 px-5 py-4\">\n          <input\n            aria-label=\"Edit reference title\"\n            className={input}\n            value={active.title}\n            onChange={(event) =>\n              patch(active.id, { title: event.target.value })\n            }\n          />\n          <button\n            className={button}\n            onClick={() => {\n              update(current.current.filter((tile) => tile.id !== active.id));\n              setSelected(null);\n            }}\n          >\n            Remove reference\n          </button>\n          {active.type === \"palette\" &&\n            (active.colors ?? []).map((color, i) => (\n              <button\n                key={i}\n                className={button}\n                onClick={async () => {\n                  try {\n                    await navigator.clipboard.writeText(color);\n                    setNotice(`${color} copied`);\n                  } catch {\n                    setNotice(\n                      \"Clipboard unavailable. Select the color label to copy manually.\",\n                    );\n                  }\n                }}\n              >\n                {color}\n              </button>\n            ))}\n          <button\n            aria-label=\"Close reference details\"\n            className=\"ml-auto p-1\"\n            onClick={() => setSelected(null)}\n          >\n            <X size={14} />\n          </button>\n        </div>\n      )}\n      <footer\n        role=\"status\"\n        className=\"border-t border-current/[0.07] px-5 py-3 text-[10px] opacity-40\"\n      >\n        {notice ||\n          `${visible.length} references · Drag to reorder, or use the arrow controls`}\n      </footer>\n    </Frame>\n  );\n}\nexport default MoodBoardCanvas;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}