{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "expand-card-shop-demo",
  "type": "registry:block",
  "title": "Expand Card: Shop",
  "description": "Expandable Card Modal example, Shop: Product cards that open into a product page with close-ups and a size picker. Add something to the bag, then pull the page down to watch the count behind it change. A take on the modal (dialog). Fits changelog, features, portfolio, blog, shop and team sections.",
  "author": "KeyframeUI <https://keyframeui.com>",
  "categories": [
    "changelog",
    "features",
    "portfolio",
    "blog",
    "shop",
    "team",
    "modal",
    "image-gallery",
    "card",
    "gesture",
    "motion"
  ],
  "docs": "Live preview, examples and props: https://keyframeui.com/components/expand-card#expand-card-shop-demo",
  "registryDependencies": [
    "https://keyframeui.com/r/expand-card.json"
  ],
  "files": [
    {
      "path": "components/expand-card-shop-demo.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\nimport { ExpandCard } from \"@/components/ui/expand-card\";\n\ntype Product = {\n  id: string;\n  name: string;\n  color: string;\n  price: number;\n  about: string;\n  soldOut: string[];\n  // Focal points for the detail shots, as fractions of the photo.\n  details: [number, number][];\n};\n\nconst products: Product[] = [\n  { id: \"1542291026-7eec264c27ff\", name: \"Ember Runner\", color: \"Crimson\", price: 140, about: \"A daily trainer with a springy foam midsole and a knit upper that stretches where your foot does.\", soldOut: [\"7\", \"12\"], details: [[0.42, 0.45], [0.62, 0.62], [0.3, 0.6]] },\n  { id: \"1606107557195-0e29a4b5b4aa\", name: \"Volt Trainer\", color: \"Lime / Black\", price: 120, about: \"Built for the gym floor: a flat, grippy sole, a wide toe box and a heel that locks in for lifts.\", soldOut: [\"8.5\"], details: [[0.5, 0.42], [0.4, 0.6], [0.62, 0.55]] },\n  { id: \"1595950653106-6c9ebd614d3a\", name: \"Pastel Court\", color: \"Lilac / Mint\", price: 110, about: \"A retro court shoe in soft suede, with a cupsole that's comfortable from the first wear.\", soldOut: [\"10\", \"10.5\"], details: [[0.5, 0.45], [0.45, 0.62], [0.55, 0.35]] },\n  { id: \"1600185365483-26d7a4cc7519\", name: \"Coral Air\", color: \"Sail / Coral\", price: 150, about: \"A visible air unit under the heel and a mesh upper that keeps long days cool.\", soldOut: [\"7.5\"], details: [[0.5, 0.5], [0.35, 0.55], [0.66, 0.5]] },\n  { id: \"1549298916-b41d501d3772\", name: \"Desert Low\", color: \"Wheat\", price: 130, about: \"Waxed nubuck that shrugs off rain, on a lugged sole made for gravel paths and cobbles.\", soldOut: [\"9\", \"12\"], details: [[0.5, 0.5], [0.38, 0.62], [0.62, 0.42]] },\n  { id: \"1608231387042-66d1773070a5\", name: \"Night Court\", color: \"White / Black\", price: 95, about: \"The classic high-contrast low-top, cut from smooth leather that creases in all the right places.\", soldOut: [], details: [[0.48, 0.5], [0.35, 0.58], [0.65, 0.46]] },\n];\n\nconst SIZES = [\"7\", \"7.5\", \"8\", \"8.5\", \"9\", \"9.5\", \"10\", \"10.5\", \"11\", \"12\"];\n\nconst photo = (id: string, width: number) =>\n  `https://images.unsplash.com/photo-${id}?auto=format&fit=max&q=80&w=${width}`;\nconst detail = (id: string, [x, y]: [number, number]) =>\n  `https://images.unsplash.com/photo-${id}?auto=format&fit=crop&crop=focalpoint&fp-x=${x}&fp-y=${y}&fp-z=2.2&w=480&h=480&q=80`;\n\nexport function ExpandCardShopDemo() {\n  const [bag, setBag] = React.useState(0);\n\n  return (\n    <section className=\"w-full max-w-3xl\">\n      <div className=\"mb-6 flex items-end justify-between gap-4\">\n        <div>\n          <p className=\"font-mono text-xs tracking-widest text-zinc-500 uppercase\">Spring drop</p>\n          <h3 className=\"mt-2 text-2xl font-semibold tracking-tight text-zinc-900 dark:text-zinc-50\">\n            New arrivals\n          </h3>\n        </div>\n        <Bag count={bag} />\n      </div>\n\n      <div className=\"grid grid-cols-2 gap-3 sm:grid-cols-3 sm:gap-4\">\n        {products.map((product) => (\n          <ExpandCard\n            key={product.id}\n            width={760}\n            coverHeight={460}\n            className=\"aspect-[4/5] w-full rounded-2xl bg-zinc-100 dark:bg-zinc-900\"\n            articleClassName=\"bg-white text-zinc-900 dark:bg-zinc-950 dark:text-zinc-50\"\n            cover={<ProductCover product={product} />}\n          >\n            <ProductPage product={product} onAdd={() => setBag((count) => count + 1)} />\n          </ExpandCard>\n        ))}\n      </div>\n    </section>\n  );\n}\n\nfunction ProductCover({ product }: { product: Product }) {\n  return (\n    <div className=\"relative size-full\">\n      <img\n        src={photo(product.id, 1400)}\n        alt=\"\"\n        draggable={false}\n        className=\"absolute inset-0 size-full object-cover\"\n      />\n      <div className=\"absolute bottom-2 left-2 max-w-[calc(100%-1rem)] rounded-xl bg-white/85 px-3 py-2 shadow-sm backdrop-blur-md dark:bg-zinc-900/80\">\n        <p className=\"truncate text-[13px] font-semibold text-zinc-900 dark:text-zinc-50\">{product.name}</p>\n        <p className=\"truncate text-xs text-zinc-500 tabular-nums\">\n          {product.color} · ${product.price}\n        </p>\n      </div>\n    </div>\n  );\n}\n\nfunction ProductPage({ product, onAdd }: { product: Product; onAdd: () => void }) {\n  const [size, setSize] = React.useState<string | null>(null);\n  const [added, setAdded] = React.useState(false);\n  const sizes = React.useId();\n\n  React.useEffect(() => {\n    if (!added) return;\n    const timer = window.setTimeout(() => setAdded(false), 1800);\n    return () => window.clearTimeout(timer);\n  }, [added]);\n\n  return (\n    <div className=\"px-5 pt-5 pb-10 sm:px-8\">\n      {/* Gallery: swipe for close-ups. */}\n      <div className=\"-mx-5 flex snap-x snap-mandatory gap-2 overflow-x-auto px-5 [scrollbar-width:none] sm:-mx-8 sm:px-8\">\n        {product.details.map((point, index) => (\n          <img\n            key={index}\n            src={detail(product.id, point)}\n            alt={`${product.name}, close-up ${index + 1}`}\n            draggable={false}\n            className=\"size-28 shrink-0 snap-start rounded-xl bg-zinc-100 object-cover dark:bg-zinc-900\"\n          />\n        ))}\n      </div>\n\n      <div className=\"mt-6 flex items-start justify-between gap-4\">\n        <div>\n          <h4 className=\"text-2xl font-semibold tracking-tight\">{product.name}</h4>\n          <p className=\"mt-0.5 text-sm text-zinc-500\">{product.color}</p>\n        </div>\n        <p className=\"text-xl font-semibold tabular-nums\">${product.price}</p>\n      </div>\n      <p className=\"mt-4 max-w-prose text-[15px] leading-relaxed text-zinc-600 dark:text-zinc-400\">\n        {product.about}\n      </p>\n\n      <fieldset className=\"mt-7\">\n        <div className=\"flex items-baseline justify-between\">\n          <legend id={sizes} className=\"text-sm font-medium\">\n            Size <span className=\"text-zinc-500\">(US)</span>\n          </legend>\n          <p className=\"text-xs text-zinc-500\">{size ? `US ${size} selected` : \"Pick a size\"}</p>\n        </div>\n        <div aria-labelledby={sizes} className=\"mt-3 grid grid-cols-5 gap-2\">\n          {SIZES.map((value) => {\n            const soldOut = product.soldOut.includes(value);\n            return (\n              <label\n                key={value}\n                className={\n                  \"relative grid h-11 cursor-pointer place-items-center rounded-xl text-sm font-medium tabular-nums ring-1 ring-zinc-200 transition-[background-color,color,box-shadow,scale] duration-150 ease-out select-none active:scale-95 dark:ring-zinc-800 \" +\n                  \"has-checked:bg-zinc-900 has-checked:text-white has-checked:ring-zinc-900 has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-zinc-900 \" +\n                  \"dark:has-checked:bg-white dark:has-checked:text-zinc-900 dark:has-checked:ring-white dark:has-focus-visible:outline-white \" +\n                  (soldOut ? \"cursor-not-allowed text-zinc-300 line-through active:scale-100 dark:text-zinc-700\" : \"hover:ring-zinc-400 dark:hover:ring-zinc-600\")\n                }\n              >\n                <input\n                  type=\"radio\"\n                  name={`${product.id}-size`}\n                  value={value}\n                  disabled={soldOut}\n                  checked={size === value}\n                  onChange={() => setSize(value)}\n                  className=\"sr-only\"\n                />\n                {value}\n              </label>\n            );\n          })}\n        </div>\n      </fieldset>\n\n      <button\n        type=\"button\"\n        disabled={!size}\n        onClick={() => {\n          onAdd();\n          setAdded(true);\n        }}\n        className=\"relative mt-6 flex h-12 w-full items-center justify-center overflow-hidden rounded-full bg-zinc-900 text-[15px] font-semibold text-white transition-[background-color,opacity,scale] duration-150 ease-out hover:bg-zinc-800 active:scale-[0.98] disabled:cursor-not-allowed disabled:opacity-40 disabled:active:scale-100 dark:bg-white dark:text-zinc-900 dark:hover:bg-zinc-200\"\n      >\n        <AnimatePresence initial={false} mode=\"popLayout\">\n          <motion.span\n            key={added ? \"added\" : \"add\"}\n            initial={{ opacity: 0, y: 12 }}\n            animate={{ opacity: 1, y: 0 }}\n            exit={{ opacity: 0, y: -12 }}\n            transition={{ type: \"spring\", visualDuration: 0.25, bounce: 0.2 }}\n            className=\"flex items-center gap-2\"\n          >\n            {added ? (\n              <>\n                <svg aria-hidden viewBox=\"0 0 24 24\" className=\"size-4\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2.5} strokeLinecap=\"round\" strokeLinejoin=\"round\">\n                  <path d=\"M5 12l5 5L20 7\" />\n                </svg>\n                Added to bag\n              </>\n            ) : (\n              \"Add to bag\"\n            )}\n          </motion.span>\n        </AnimatePresence>\n      </button>\n      <p className=\"mt-3 text-center text-xs text-zinc-500\">Free returns within 30 days</p>\n\n      <dl className=\"mt-8 divide-y divide-zinc-200 border-y border-zinc-200 text-sm dark:divide-zinc-800 dark:border-zinc-800\">\n        {[\n          [\"Fit\", \"True to size. Between sizes? Go up half.\"],\n          [\"Upper\", \"Engineered knit with a suede heel\"],\n          [\"Sole\", \"Rubber outsole, recycled foam midsole\"],\n          [\"Shipping\", \"Free over $100. Arrives in 2–4 days.\"],\n        ].map(([term, value]) => (\n          <div key={term} className=\"flex gap-4 py-3\">\n            <dt className=\"w-20 shrink-0 text-zinc-500\">{term}</dt>\n            <dd className=\"text-zinc-800 dark:text-zinc-200\">{value}</dd>\n          </div>\n        ))}\n      </dl>\n    </div>\n  );\n}\n\nfunction Bag({ count }: { count: number }) {\n  const reduceMotion = useReducedMotion();\n  const pop = count > 0 && !reduceMotion;\n\n  return (\n    <div className=\"relative grid size-10 place-items-center rounded-full bg-zinc-100 text-zinc-900 dark:bg-zinc-900 dark:text-zinc-50\">\n      <motion.svg\n        key={count}\n        aria-hidden\n        viewBox=\"0 0 24 24\"\n        className=\"size-[18px]\"\n        fill=\"none\"\n        stroke=\"currentColor\"\n        strokeWidth={1.75}\n        strokeLinecap=\"round\"\n        strokeLinejoin=\"round\"\n        initial={pop ? { scale: 1.25, rotate: -8 } : false}\n        animate={{ scale: 1, rotate: 0 }}\n        transition={{ type: \"spring\", visualDuration: 0.4, bounce: 0.5 }}\n      >\n        <path d=\"M6 8h12l-1 12H7zM9 8V6a3 3 0 0 1 6 0v2\" />\n      </motion.svg>\n      <span role=\"status\" className=\"sr-only\">\n        {count} {count === 1 ? \"item\" : \"items\"} in your bag\n      </span>\n      <AnimatePresence>\n        {count > 0 ? (\n          <motion.span\n            aria-hidden\n            initial={{ opacity: 0 }}\n            animate={{ opacity: 1 }}\n            exit={{ opacity: 0 }}\n            transition={{ duration: 0.15 }}\n            className=\"absolute -top-1 -right-1\"\n          >\n            {/* Remounts on every change, so each new item pops the badge. */}\n            <motion.span\n              key={count}\n              initial={pop ? { scale: count === 1 ? 0.3 : 1.35 } : false}\n              animate={{ scale: 1 }}\n              transition={{ type: \"spring\", visualDuration: 0.35, bounce: 0.45 }}\n              className=\"grid h-5 min-w-5 place-items-center rounded-full bg-rose-500 px-1 text-[11px] font-bold text-white tabular-nums ring-2 ring-white dark:ring-zinc-950\"\n            >\n              {count}\n            </motion.span>\n          </motion.span>\n        ) : null}\n      </AnimatePresence>\n    </div>\n  );\n}\n"
    }
  ]
}