{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "collection",
  "type": "registry:block",
  "title": "Collection block",
  "description": "A store's products as a grid: the title and the count, a filter row with what to show and the order, product cards with no buy buttons (two across on a phone), an empty state for a filter with nothing in it, and the cart as a sheet.",
  "registryDependencies": [
    "https://littmd.vercel.app/r/litt.json",
    "https://littmd.vercel.app/r/button.json",
    "https://littmd.vercel.app/r/cart.json",
    "https://littmd.vercel.app/r/framed.json",
    "https://littmd.vercel.app/r/price.json",
    "https://littmd.vercel.app/r/product-card.json",
    "https://littmd.vercel.app/r/segmented.json",
    "https://littmd.vercel.app/r/select.json",
    "https://littmd.vercel.app/r/states.json"
  ],
  "files": [
    {
      "path": "registry/litt/components/litt-blocks/collection.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n// @litt/collection 2026.11.03. What changed: https://littmd.vercel.app/changelog.md\n\n/**\n * Collection: a store's products as a grid, for a shop's front page or a category. A block: a whole page built from\n * the litt parts, to copy and make your own. Swap the products at the top for yours (or for the ones the shopify\n * item's toProduct maps from a collection); the layout stays.\n *\n * The title and the count as one line in two inks, the cart at the end. A filter row: what to show as a Segmented\n * control and the order as a Select, left-aligned (R9). Then the grid: two across on a phone, then as many 14rem\n * columns as fit, every cover one shape. Each card is one link to its product, with no buy button, so the page has no\n * accent fill until the cart is open (R6). A sale strikes the old price through; a print with nothing in stock keeps\n * its card and says Sold out. A filter with nothing in it says so and offers the way back. Nothing moves until\n * someone moves it; opening the cart is the page's one expressive moment.\n */\nimport { useId, useState } from \"react\";\nimport { Button } from \"../litt/button\";\nimport { Cart, CartButton, useCartState } from \"../litt/cart\";\nimport { type Money } from \"../litt/price\";\nimport { ProductCard, ProductGrid, isSoldOut, priceRange, type Product } from \"../litt/product-card\";\nimport { Segmented } from \"../litt/segmented\";\nimport { Select } from \"../litt/select\";\nimport { Empty } from \"../litt/states\";\nimport { Heading } from \"../litt/framed\";\n\n/* ----------------------------------------------------------------- data */\n\n/* Drawn stand-ins for a store's photographs of its prints: a sun low over the ground, on a mat, in a frame. SVGs, so\n   the page fetches nothing; named colors for the art, because it is a picture, not the interface. Replace each\n   product's images with yours. */\ntype Scene = { sky: string; glow: string; ground: string; core: string; rim: string };\n/** The frame's edge in the drawing, so a white frame keeps its shape on a pale ground. */\nconst EDGE = \"black\";\n\nfunction framed(s: Scene, wood: string) {\n  const body =\n    `<defs><linearGradient id='s' x2='0' y2='1'><stop offset='0' stop-color='${s.sky}'/><stop offset='.68' stop-color='${s.glow}'/></linearGradient>` +\n    `<radialGradient id='o' cx='.42' cy='.38' r='.7'><stop offset='0' stop-color='${s.core}'/><stop offset='1' stop-color='${s.rim}'/></radialGradient>` +\n    `<filter id='g' x='0' y='0' width='1' height='1'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .14 0'/></filter></defs>` +\n    `<rect x='130' y='130' width='540' height='675' fill='${wood}' stroke='${EDGE}' stroke-opacity='.12'/>` +\n    `<rect x='154' y='154' width='492' height='627' fill='whitesmoke'/>` +\n    `<g transform='translate(194 194) scale(1.03)'><rect width='400' height='500' fill='url(#s)'/><rect y='340' width='400' height='160' fill='${s.ground}'/>` +\n    `<circle cx='200' cy='300' r='92' fill='url(#o)'/><rect width='400' height='500' filter='url(#g)'/></g>`;\n  return `data:image/svg+xml,${encodeURIComponent(`<svg xmlns='http://www.w3.org/2000/svg' width='800' height='1000' viewBox='0 0 800 1000'>${body}</svg>`)}`;\n}\n\nconst OAK = \"#c9a57d\"; // litt-allow: user data, a frame's color\nconst eur = (amount: number): Money => ({ amount, currencyCode: \"EUR\" });\n\ntype Mood = \"warm\" | \"cool\";\n\n/** One print in three sizes. `from` is the A3's price; `sale` takes a share off; `out` sells every size out. */\nfunction print(id: string, title: string, mood: Mood, scene: Scene, from: number, { sale = 0, out = false } = {}): Product & { mood: Mood } {\n  const sizes = [\n    { value: \"A3\", price: from },\n    { value: \"A2\", price: from + 45 },\n    { value: \"A1\", price: from + 115 },\n  ];\n  return {\n    id,\n    handle: id,\n    title,\n    mood,\n    images: [{ src: framed(scene, OAK), alt: `${title}, framed in oak on a white mat`, width: 800, height: 1000 }],\n    options: [{ name: \"Size\", values: sizes.map((s) => ({ value: s.value })) }],\n    variants: sizes.map((s) => ({\n      id: `${id}-${s.value}`.toLowerCase(),\n      title: s.value,\n      available: !out,\n      price: eur(sale ? Math.round(s.price * (1 - sale)) : s.price),\n      compareAt: sale ? eur(s.price) : null,\n      options: { Size: s.value },\n    })),\n  };\n}\n\n/** The collection, in the store's own order. Load yours. */\nconst PRODUCTS = [\n  print(\"red-sun\", \"Red sun\", \"warm\", { sky: \"sienna\", glow: \"mistyrose\", ground: \"linen\", core: \"pink\", rim: \"orangered\" }, 100),\n  print(\"blue-hour\", \"Blue hour\", \"cool\", { sky: \"midnightblue\", glow: \"steelblue\", ground: \"lightsteelblue\", core: \"darkorange\", rim: \"cornflowerblue\" }, 100),\n  print(\"pale-moon\", \"Pale moon\", \"cool\", { sky: \"slategray\", glow: \"lavender\", ground: \"gainsboro\", core: \"white\", rim: \"lightgray\" }, 120),\n  print(\"dusk\", \"Dusk\", \"warm\", { sky: \"darkslateblue\", glow: \"lightsalmon\", ground: \"dimgray\", core: \"gold\", rim: \"coral\" }, 100, { sale: 0.2 }),\n  print(\"noon\", \"Noon\", \"warm\", { sky: \"skyblue\", glow: \"aliceblue\", ground: \"tan\", core: \"lightyellow\", rim: \"khaki\" }, 140),\n  print(\"eclipse\", \"Eclipse\", \"cool\", { sky: \"black\", glow: \"darkslategray\", ground: \"dimgray\", core: \"black\", rim: \"goldenrod\" }, 180, { out: true }),\n  print(\"tide-moon\", \"Tide moon\", \"cool\", { sky: \"teal\", glow: \"paleturquoise\", ground: \"cadetblue\", core: \"white\", rim: \"aquamarine\" }, 120),\n  print(\"ember\", \"Ember\", \"warm\", { sky: \"maroon\", glow: \"indianred\", ground: \"rosybrown\", core: \"yellow\", rim: \"red\" }, 100),\n];\n\nconst SHOW = [\n  { value: \"all\", label: \"All\" },\n  { value: \"warm\", label: \"Warm\" },\n  { value: \"cool\", label: \"Cool\" },\n  { value: \"stock\", label: \"In stock\" },\n];\nconst ORDER = [\n  { value: \"featured\", label: \"Featured\" },\n  { value: \"low\", label: \"Price, low to high\" },\n  { value: \"high\", label: \"Price, high to low\" },\n];\n\nconst lowest = (p: Product) => Number(priceRange(p).min.amount);\n\n/* ----------------------------------------------------------------- the page */\n\nexport function Collection() {\n  const titleId = useId();\n  const cart = useCartState();\n  const [cartOpen, setCartOpen] = useState(false);\n  const [show, setShow] = useState(\"all\");\n  const [order, setOrder] = useState(\"featured\");\n\n  const shown = PRODUCTS.filter((p) => (show === \"all\" ? true : show === \"stock\" ? !isSoldOut(p) : p.mood === show));\n  if (order !== \"featured\") shown.sort((a, b) => (order === \"low\" ? lowest(a) - lowest(b) : lowest(b) - lowest(a)));\n\n  return (\n    <section aria-labelledby={titleId} className=\"@container mx-auto grid w-full max-w-6xl gap-8\">\n      <header className=\"flex items-start justify-between gap-4\">\n        {/* The title and its count as one line in two inks; the h1 stays the name alone. */}\n        <div className=\"flex flex-wrap items-baseline gap-x-2 text-litt-h1\">\n          <Heading level={1} id={titleId} className=\"text-litt-fg\">\n            Prints\n          </Heading>\n          <p className=\"font-normal text-litt-fg-muted\">\n            {shown.length} {shown.length === 1 ? \"print\" : \"prints\"}, made to order.\n          </p>\n        </div>\n        <CartButton count={cart.count} onClick={() => setCartOpen(true)} />\n      </header>\n\n      <div className=\"flex flex-wrap items-center justify-between gap-3\">\n        <Segmented legend=\"Show\" options={SHOW} value={show} onValueChange={setShow} size=\"sm\" />\n        <div className=\"w-48\">\n          <Select aria-label=\"Order\" options={ORDER} value={order} onValueChange={setOrder} size=\"sm\" />\n        </div>\n      </div>\n\n      {shown.length ? (\n        <ProductGrid label=\"Prints\">\n          {shown.map((p) => (\n            <ProductCard key={p.id} product={p} href={`/products/${p.handle}`} />\n          ))}\n        </ProductGrid>\n      ) : (\n        <Empty title=\"Nothing here yet\" action={<Button onClick={() => setShow(\"all\")}>Show all prints</Button>}>\n          No prints match that filter.\n        </Empty>\n      )}\n\n      <Cart open={cartOpen} onOpenChange={setCartOpen} cart={cart} freeShippingAt={eur(250)} />\n    </section>\n  );\n}\n",
      "target": "components/litt-blocks/collection.tsx"
    }
  ],
  "docs": "Import Collection from components/litt-blocks/collection and render it as a page's content. The products sit at the top of the file: replace them with yours, or with the ones the shopify item's toProduct maps from a collection. See it live at https://littmd.vercel.app/#collection.",
  "meta": {
    "version": "2026.11.03",
    "released": "2026-11-03",
    "changelog": "https://littmd.vercel.app/changelog.md"
  }
}
