{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "product",
  "type": "registry:block",
  "title": "Product block",
  "description": "One product's page for a store: the pictures beside the details (a carousel on a phone), the title, the price, the options with sold-out picks said in words, the quantity and Add to cart as the one accent fill, the rest in an accordion, and the cart as a sheet. Every picture opens a lightbox.",
  "registryDependencies": [
    "https://littmd.vercel.app/r/litt.json",
    "https://littmd.vercel.app/r/accordion.json",
    "https://littmd.vercel.app/r/breadcrumb.json",
    "https://littmd.vercel.app/r/carousel.json",
    "https://littmd.vercel.app/r/cart.json",
    "https://littmd.vercel.app/r/framed.json",
    "https://littmd.vercel.app/r/lightbox.json",
    "https://littmd.vercel.app/r/media.json",
    "https://littmd.vercel.app/r/number-field.json",
    "https://littmd.vercel.app/r/option-picker.json",
    "https://littmd.vercel.app/r/price.json",
    "https://littmd.vercel.app/r/product-card.json",
    "https://littmd.vercel.app/r/toast.json"
  ],
  "files": [
    {
      "path": "registry/litt/components/litt-blocks/product.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n// @litt/product 2026.11.03. What changed: https://littmd.vercel.app/changelog.md\n\n/**\n * Product: one product's page, for a store. A block: a whole page built from the litt parts, to copy and make your\n * own. Swap the product at the top for yours (or for one the shopify item's toProduct maps from your store); the\n * layout stays.\n *\n * Where the page sits and the cart, then the pictures and the details side by side when the page is wide (R9,\n * asymmetric: the pictures take the wider column and scroll, the details stay beside them), one above the other on a\n * phone, where the pictures are a carousel of one and a peek. The details: the title, the page's one 18px line, the\n * price under it at the body size (a sale is the old price struck through and a neutral tag, never red), the options,\n * the quantity and Add to cart, the page's one accent fill. The rest folds into an accordion.\n *\n * Picking a frame shows that frame's picture. A pick that is sold out says so in the legend, and Add to cart becomes\n * a disabled Sold out. Add to cart says Added for two seconds, the cart's count rolls and a toast says what was added\n * with View cart; the cart does not open by itself. Every picture opens the lightbox; opening it, or the cart, is the\n * page's one expressive moment. Mount the Toaster once near your root.\n */\nimport { useState } from \"react\";\nimport { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from \"../litt/accordion\";\nimport { Breadcrumb } from \"../litt/breadcrumb\";\nimport { AddToCart, Cart, CartButton, useCartState } from \"../litt/cart\";\nimport { Carousel, CarouselContent, CarouselControls, CarouselItem } from \"../litt/carousel\";\nimport { Lightbox } from \"../litt/lightbox\";\nimport { Media } from \"../litt/media\";\nimport { NumberField } from \"../litt/number-field\";\nimport { OptionPicker } from \"../litt/option-picker\";\nimport { Price, type Money } from \"../litt/price\";\nimport { defaultPicks, findVariant, optionsFor, type Product, type ProductImage } from \"../litt/product-card\";\nimport { toast } from \"../litt/toast\";\nimport { Heading } from \"../litt/framed\";\n\n/* ----------------------------------------------------------------- data */\n\n/* Drawn stand-ins for a store's photographs of a print: a sun low over the ground, on a mat, in a frame. SVGs, so the\n   page fetches nothing; named colors for the art, because it is a picture, not the interface. Replace every picture\n   below with your product's. */\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 scene(s: Scene) {\n  return (\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 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)'/>`\n  );\n}\nconst svg = (body: string, w: number, h: number, box: string) =>\n  `data:image/svg+xml,${encodeURIComponent(`<svg xmlns='http://www.w3.org/2000/svg' width='${w}' height='${h}' viewBox='${box}'>${body}</svg>`)}`;\n\n/** The print in a frame on a mat, centred on a clear ground, so the picture's own frame shows through. */\nconst framed = (s: Scene, wood: string) =>\n  svg(\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)'>${scene(s)}</g>`,\n    1200, 1500, \"0 0 800 1000\",\n  );\n/** The print alone, edge to edge. */\nconst bare = (s: Scene) => svg(scene(s), 1200, 1500, \"0 0 400 500\");\n/** A close look at the sun and its grain. */\nconst detail = (s: Scene) => svg(scene(s), 1200, 1500, \"110 190 180 225\");\n\nconst RED_SUN: Scene = { sky: \"sienna\", glow: \"mistyrose\", ground: \"linen\", core: \"pink\", rim: \"orangered\" };\n\n/** The frames: the product's own colors, from your store (Shopify gives a swatch's color as hex). */\nconst FRAMES = [\n  { value: \"Black\", color: \"#1f1d1b\" }, // litt-allow: user data, a frame's color\n  { value: \"Natural oak\", color: \"#c9a57d\" }, // litt-allow: user data\n  { value: \"Walnut\", color: \"#5e3d2b\" }, // litt-allow: user data\n  { value: \"White\", color: \"#f1eee8\" }, // litt-allow: user data\n];\nconst SIZES = [\n  { value: \"A3\", price: 100 },\n  { value: \"A2\", price: 145 },\n  { value: \"A1\", price: 215 },\n];\nconst SOLD_OUT = [\"A1 / Walnut\", \"A3 / White\"];\nconst eur = (amount: number): Money => ({ amount, currencyCode: \"EUR\" });\n\nconst picture = (frame: (typeof FRAMES)[number]): ProductImage => ({\n  src: framed(RED_SUN, frame.color),\n  alt: `Red sun, framed in ${frame.value.toLowerCase()}, on a white mat`,\n  width: 1200,\n  height: 1500,\n});\n\n/** The product, as the shopify item's toProduct gives it. Load yours. */\nconst PRODUCT: Product = {\n  id: \"red-sun\",\n  handle: \"red-sun\",\n  title: \"Red sun\",\n  vendor: \"Field studies\",\n  description:\n    \"A red sun fading to pale pink, low over a white ground under a brown sky. Made in the studio's Brand Playground, then printed on 310 gsm cotton rag with archival pigment inks.\",\n  images: [\n    picture(FRAMES[1]!),\n    { src: bare(RED_SUN), alt: \"Red sun, the print alone: a red sun fading to pink over a pale ground\", width: 1200, height: 1500 },\n    { src: detail(RED_SUN), alt: \"A close look at the sun's edge and the grain of the print\", width: 1200, height: 1500 },\n  ],\n  options: [\n    { name: \"Size\", values: SIZES.map((s) => ({ value: s.value })) },\n    { name: \"Frame\", values: FRAMES.map((f) => ({ value: f.value, swatch: { color: f.color } })) },\n  ],\n  variants: SIZES.flatMap((s) =>\n    FRAMES.map((f) => ({\n      id: `red-sun-${s.value}-${f.value}`.toLowerCase().replace(/\\s+/g, \"-\"),\n      title: `${s.value} / ${f.value}`,\n      available: !SOLD_OUT.includes(`${s.value} / ${f.value}`),\n      price: eur(s.price),\n      options: { Size: s.value, Frame: f.value },\n      image: picture(f),\n    })),\n  ),\n};\n\n/** Where the page sits. Point the links at your routes. */\nconst TRAIL = [\n  { label: \"Prints\", href: \"/prints\" },\n  { label: \"Red sun\", href: \"/products/red-sun\" },\n];\n\n/** What folds under Add to cart. */\nconst MORE = [\n  { title: \"About this print\", body: PRODUCT.description },\n  { title: \"Paper and printing\", body: \"310 gsm cotton rag, matte, with archival pigment inks. Each print is made to order and signed on the back.\" },\n  { title: \"Shipping and returns\", body: \"Ships in three to five working days, flat in a rigid box. Free over €250 in the EU. Returns within 30 days, unframed or framed.\" },\n];\n\n/* ----------------------------------------------------------------- the page */\n\nexport function ProductPage() {\n  const product = PRODUCT;\n  const cart = useCartState();\n  const [cartOpen, setCartOpen] = useState(false);\n  const [picks, setPicks] = useState(() => defaultPicks(product));\n  const [quantity, setQuantity] = useState<number | null>(1);\n  const [open, setOpen] = useState<number | null>(null);\n  const variant = findVariant(product, picks);\n  /* The picked frame's picture leads; the others follow. */\n  const images = [variant?.image ?? product.images[0]!, ...product.images.slice(1)];\n\n  const add = async () => {\n    if (!variant) return;\n    await cart.add({\n      variantId: variant.id,\n      title: product.title,\n      variantTitle: `${picks.Size} · ${picks.Frame}`,\n      quantity: quantity ?? 1,\n      price: variant.price,\n      compareAt: variant.compareAt,\n      image: variant.image,\n    });\n    toast({ title: `Added ${product.title}`, description: `${picks.Size} · ${picks.Frame}`, action: { label: \"View cart\", onClick: () => setCartOpen(true) } });\n  };\n\n  return (\n    <article className=\"@container mx-auto grid w-full max-w-6xl gap-8\">\n      <div className=\"flex items-center justify-between gap-4\">\n        <Breadcrumb label=\"Where this page is\" items={TRAIL} />\n        <CartButton count={cart.count} onClick={() => setCartOpen(true)} />\n      </div>\n\n      <div className=\"grid gap-8 @min-[40rem]:grid-cols-2 @min-[56rem]:grid-cols-[minmax(0,7fr)_minmax(0,5fr)] @min-[56rem]:gap-12\">\n        {/* Wide: the pictures stacked in the wider column. Narrow: a carousel of one and a peek. */}\n        <div className=\"hidden gap-4 @min-[40rem]:grid\">\n          {images.map((image, i) => (\n            <Media key={i} src={image.src} alt={image.alt} width={image.width} height={image.height} ratio=\"4/5\" priority={i === 0} onOpen={() => setOpen(i)} />\n          ))}\n        </div>\n        <Carousel label={`Pictures of ${product.title}`} perView=\"one\" className=\"@min-[40rem]:hidden\">\n          <CarouselContent>\n            {images.map((image, i) => (\n              <CarouselItem key={i}>\n                <Media src={image.src} alt={image.alt} width={image.width} height={image.height} ratio=\"4/5\" priority={i === 0} onOpen={() => setOpen(i)} />\n              </CarouselItem>\n            ))}\n          </CarouselContent>\n          <CarouselControls />\n        </Carousel>\n\n        <div className=\"grid content-start gap-8 @min-[40rem]:sticky @min-[40rem]:top-8 @min-[40rem]:self-start\">\n          <header className=\"grid gap-1\">\n            {product.vendor && <p className=\"text-litt-caption font-normal text-litt-fg-subtle\">{product.vendor}</p>}\n            <Heading level={1} className=\"text-litt-h1 text-litt-fg\">{product.title}</Heading>\n            {variant && <Price price={variant.price} compareAt={variant.compareAt} saving className=\"text-litt-body\" />}\n          </header>\n\n          <div className=\"grid gap-6\">\n            {optionsFor(product, picks).map((option) => (\n              <OptionPicker\n                key={option.name}\n                name={option.name}\n                values={option.values}\n                value={picks[option.name]}\n                onValueChange={(value) => setPicks({ ...picks, [option.name]: value })}\n              />\n            ))}\n            <NumberField label=\"Quantity\" min={1} max={10} required value={quantity} onValueChange={setQuantity} className=\"w-40\" />\n          </div>\n\n          <div className=\"grid gap-3\">\n            <AddToCart onAdd={add} soldOut={variant ? !variant.available : false} disabled={!variant} />\n            <p className=\"text-litt-small text-litt-fg-subtle\">Made to order, ships in three to five days. Free shipping over €250.</p>\n          </div>\n\n          <Accordion type=\"multiple\" headingLevel={2}>\n            {MORE.map((m) => (\n              <AccordionItem key={m.title} value={m.title}>\n                <AccordionTrigger>{m.title}</AccordionTrigger>\n                <AccordionContent>\n                  <p className=\"max-w-(--litt-measure) text-litt-body text-litt-fg-muted\">{m.body}</p>\n                </AccordionContent>\n              </AccordionItem>\n            ))}\n          </Accordion>\n        </div>\n      </div>\n\n      <Lightbox label={product.title} items={images} index={open} onIndexChange={setOpen} />\n      <Cart open={cartOpen} onOpenChange={setCartOpen} cart={cart} freeShippingAt={eur(250)} />\n    </article>\n  );\n}\n",
      "target": "components/litt-blocks/product.tsx"
    }
  ],
  "docs": "Import ProductPage from components/litt-blocks/product and render it as a page's content. The product sits at the top of the file: replace it with yours, or with one the shopify item's toProduct maps from your store. Mount the Toaster once near your root. See it live at https://littmd.vercel.app/#product.",
  "meta": {
    "version": "2026.11.03",
    "released": "2026-11-03",
    "changelog": "https://littmd.vercel.app/changelog.md"
  }
}
