{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "price-list-menu",
  "title": "Price List / Menu",
  "description": "A printed-menu style price list for cafés, salons and studios: section tabs with a sliding pill, dotted leaders to each price, sizes side by side, favourites and diet filters.",
  "dependencies": [
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/price-list-menu/price-list-menu.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport type PriceListTheme = \"dark\" | \"light\";\n\nexport interface PriceListVariant {\n  label: string;\n  price: number;\n}\n\nexport interface PriceListItem {\n  name: string;\n  description?: string;\n  /** One price, or several sizes such as [{ label: \"S\", price: 3.5 }, { label: \"L\", price: 4.5 }]. */\n  price: number | PriceListVariant[];\n  /** Short labels people can filter by, e.g. \"Vegan\". */\n  tags?: string[];\n  /** Marks the item as a favourite. */\n  popular?: boolean;\n}\n\nexport interface PriceListSection {\n  title: string;\n  note?: string;\n  items: PriceListItem[];\n}\n\nexport interface PriceListMenuProps extends Omit<\n  React.ComponentPropsWithoutRef<\"div\">,\n  \"title\"\n> {\n  theme?: PriceListTheme;\n  eyebrow?: string;\n  title?: string;\n  sections?: PriceListSection[];\n  currency?: string;\n  /** Small print under the list. */\n  footnote?: string;\n  /** Two columns on wide screens. */\n  columns?: 1 | 2;\n  /** Show filter chips built from the items' tags. */\n  showFilters?: boolean;\n}\n\nconst PALETTES = {\n  dark: {\n    bg: \"#12100D\",\n    border: \"rgba(244,236,222,0.12)\",\n    text: \"#F4ECDE\",\n    sub: \"rgba(244,236,222,0.6)\",\n    faint: \"rgba(244,236,222,0.36)\",\n    chip: \"rgba(244,236,222,0.08)\",\n    pill: \"#F4ECDE\",\n    pillText: \"#12100D\",\n    accent: \"#E0A458\",\n  },\n  light: {\n    bg: \"#FBF7EF\",\n    border: \"rgba(44,33,20,0.14)\",\n    text: \"#2C2114\",\n    sub: \"rgba(44,33,20,0.62)\",\n    faint: \"rgba(44,33,20,0.4)\",\n    chip: \"rgba(44,33,20,0.06)\",\n    pill: \"#2C2114\",\n    pillText: \"#FBF7EF\",\n    accent: \"#A8651C\",\n  },\n};\n\nconst SERIF =\n  \"'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif\";\n\nconst DEFAULT_SECTIONS: PriceListSection[] = [\n  {\n    title: \"Coffee\",\n    note: \"Oat or almond milk +0.60\",\n    items: [\n      {\n        name: \"Espresso\",\n        description: \"Single origin, changes weekly\",\n        price: [\n          { label: \"S\", price: 2.8 },\n          { label: \"D\", price: 3.4 },\n        ],\n        tags: [\"Vegan\"],\n      },\n      {\n        name: \"Flat white\",\n        description: \"Double shot, silky milk\",\n        price: 4.2,\n        popular: true,\n      },\n      {\n        name: \"Filter of the day\",\n        description: \"Ask us what's on the bar\",\n        price: 3.8,\n        tags: [\"Vegan\"],\n      },\n      {\n        name: \"Cortado\",\n        description: \"Equal parts espresso and milk\",\n        price: 3.9,\n      },\n      {\n        name: \"Iced latte\",\n        description: \"Slow-poured over clear ice\",\n        price: 4.6,\n      },\n      {\n        name: \"Hot chocolate\",\n        description: \"70% cocoa, whole milk\",\n        price: 4.4,\n      },\n    ],\n  },\n  {\n    title: \"Brunch\",\n    note: \"Served until 15:00\",\n    items: [\n      {\n        name: \"Sourdough & eggs\",\n        description: \"Soft scrambled, chives, cultured butter\",\n        price: 11.5,\n        tags: [\"Vegetarian\"],\n        popular: true,\n      },\n      {\n        name: \"Çılbır\",\n        description: \"Poached eggs, garlic yoghurt, Aleppo butter\",\n        price: 12.5,\n        tags: [\"Vegetarian\"],\n      },\n      {\n        name: \"Green shakshuka\",\n        description: \"Chard, leeks, feta, flatbread\",\n        price: 13,\n        tags: [\"Vegetarian\"],\n      },\n      {\n        name: \"Roast squash bowl\",\n        description: \"Freekeh, tahini, pickled onion\",\n        price: 12,\n        tags: [\"Vegan\"],\n      },\n    ],\n  },\n  {\n    title: \"Bakery\",\n    note: \"Baked here from 06:00\",\n    items: [\n      {\n        name: \"Cardamom bun\",\n        description: \"Our best seller, gone by noon\",\n        price: 4.2,\n        tags: [\"Vegetarian\"],\n        popular: true,\n      },\n      {\n        name: \"Butter croissant\",\n        description: \"Laminated over three days\",\n        price: 3.6,\n        tags: [\"Vegetarian\"],\n      },\n      {\n        name: \"Olive & thyme focaccia\",\n        description: \"Sea salt, good olive oil\",\n        price: 4.4,\n        tags: [\"Vegan\"],\n      },\n      {\n        name: \"Almond cake\",\n        description: \"Flourless, orange blossom\",\n        price: 4.8,\n        tags: [\"Gluten free\"],\n      },\n    ],\n  },\n];\n\nfunction useReducedMotion() {\n  return React.useSyncExternalStore(\n    (callback) => {\n      const query = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n      query.addEventListener(\"change\", callback);\n      return () => query.removeEventListener(\"change\", callback);\n    },\n    () => window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches,\n    () => false,\n  );\n}\n\nconst fmt = (v: number) => (v % 1 ? v.toFixed(2) : String(v));\n\nexport function PriceListMenu({\n  theme = \"dark\",\n  eyebrow = \"Harbour Street Café\",\n  title = \"The menu\",\n  sections = DEFAULT_SECTIONS,\n  currency = \"€\",\n  footnote = \"Tell us about any allergies before you order. Service is never added to your bill.\",\n  columns = 2,\n  showFilters = true,\n  className,\n  style,\n  ...props\n}: PriceListMenuProps) {\n  const pal = PALETTES[theme];\n  const reduce = useReducedMotion();\n  const id = React.useId();\n  const [tab, setTab] = React.useState(0);\n  const [filter, setFilter] = React.useState<string | null>(null);\n  const tabsRef = React.useRef<HTMLDivElement>(null);\n  const pillRef = React.useRef<HTMLSpanElement>(null);\n  const tabLabels = [\"All\", ...sections.map((s) => s.title)];\n  const tags = [\n    ...new Set(sections.flatMap((s) => s.items.flatMap((i) => i.tags ?? []))),\n  ];\n\n  // The pill slides under the active tab; written straight to the element so nothing re-renders.\n  React.useLayoutEffect(() => {\n    const place = () => {\n      const btn =\n        tabsRef.current?.querySelectorAll<HTMLElement>(\"[role=tab]\")[tab];\n      const pill = pillRef.current;\n      if (!btn || !pill) return;\n      pill.style.width = `${btn.offsetWidth}px`;\n      pill.style.transform = `translateX(${btn.offsetLeft}px)`;\n    };\n    place();\n    const ro = new ResizeObserver(place);\n    if (tabsRef.current) ro.observe(tabsRef.current);\n    return () => ro.disconnect();\n  }, [tab, sections]);\n\n  const onTabKey = (e: React.KeyboardEvent) => {\n    const dir = e.key === \"ArrowRight\" ? 1 : e.key === \"ArrowLeft\" ? -1 : 0;\n    if (!dir) return;\n    e.preventDefault();\n    const next = (tab + dir + tabLabels.length) % tabLabels.length;\n    setTab(next);\n    tabsRef.current?.querySelectorAll<HTMLElement>(\"[role=tab]\")[next]?.focus();\n  };\n\n  const shown = (tab === 0 ? sections : [sections[tab - 1]])\n    .map((s) => ({\n      ...s,\n      items: s.items.filter((i) => !filter || i.tags?.includes(filter)),\n    }))\n    .filter((s) => s.items.length > 0);\n  let order = 0;\n\n  return (\n    <div\n      className={cn(\n        \"w-full rounded-[20px] px-5 py-8 sm:px-10 sm:py-10\",\n        className,\n      )}\n      style={{\n        background: pal.bg,\n        border: `1px solid ${pal.border}`,\n        color: pal.text,\n        fontFamily: \"Inter, -apple-system, BlinkMacSystemFont, sans-serif\",\n        ...style,\n      }}\n      {...props}\n    >\n      <style>{`@keyframes plm-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }`}</style>\n      <header className=\"text-center\">\n        <p\n          className=\"m-0 text-[11px] font-medium tracking-[0.22em] uppercase\"\n          style={{ color: pal.accent }}\n        >\n          {eyebrow}\n        </p>\n        <h2\n          className=\"m-0 mt-2 text-[34px] leading-tight font-normal sm:text-[42px]\"\n          style={{ fontFamily: SERIF }}\n        >\n          {title}\n        </h2>\n      </header>\n\n      <div className=\"mt-6 flex flex-col items-center gap-3\">\n        <div className=\"max-w-full overflow-x-auto [scrollbar-width:none]\">\n          <div\n            ref={tabsRef}\n            role=\"tablist\"\n            aria-label=\"Menu sections\"\n            onKeyDown={onTabKey}\n            className=\"relative flex w-max rounded-full p-1\"\n            style={{ background: pal.chip }}\n          >\n            <span\n              ref={pillRef}\n              aria-hidden=\"true\"\n              className=\"absolute top-1 bottom-1 left-0 rounded-full motion-safe:transition-[transform,width] motion-safe:duration-300\"\n              style={{ background: pal.pill }}\n            />\n            {tabLabels.map((label, i) => (\n              <button\n                key={label}\n                type=\"button\"\n                role=\"tab\"\n                id={`${id}-t${i}`}\n                aria-selected={tab === i}\n                aria-controls={`${id}-panel`}\n                tabIndex={tab === i ? 0 : -1}\n                onClick={() => setTab(i)}\n                className=\"relative cursor-pointer rounded-full px-4 py-1.5 text-[13px] font-medium whitespace-nowrap transition-colors duration-300\"\n                style={{ color: tab === i ? pal.pillText : pal.sub }}\n              >\n                {label}\n              </button>\n            ))}\n          </div>\n        </div>\n        {showFilters && tags.length > 0 && (\n          <div\n            className=\"flex flex-wrap justify-center gap-1.5\"\n            role=\"group\"\n            aria-label=\"Filter by diet\"\n          >\n            {tags.map((t) => (\n              <button\n                key={t}\n                type=\"button\"\n                aria-pressed={filter === t}\n                onClick={() => setFilter((f) => (f === t ? null : t))}\n                className=\"cursor-pointer rounded-full px-2.5 py-1 text-[11.5px] font-medium transition-colors\"\n                style={{\n                  border: `1px solid ${filter === t ? pal.accent : pal.border}`,\n                  color: filter === t ? pal.accent : pal.sub,\n                }}\n              >\n                {t}\n              </button>\n            ))}\n          </div>\n        )}\n      </div>\n\n      <div\n        id={`${id}-panel`}\n        role=\"tabpanel\"\n        aria-labelledby={`${id}-t${tab}`}\n        key={`${tab}-${filter}`}\n        className={cn(\"mt-7 gap-x-12\", columns === 2 && \"sm:columns-2\")}\n      >\n        {shown.length === 0 && (\n          <p\n            className=\"m-0 py-8 text-center text-[14px]\"\n            style={{ color: pal.sub }}\n          >\n            Nothing here with that filter.\n          </p>\n        )}\n        {shown.map((s) => (\n          <section key={s.title} className=\"mb-7 break-inside-avoid last:mb-0\">\n            {tab === 0 && (\n              <div\n                className=\"mb-3 flex items-baseline justify-between gap-3 border-b pb-2\"\n                style={{ borderColor: pal.border }}\n              >\n                <h3\n                  className=\"m-0 text-[21px] leading-tight font-normal\"\n                  style={{ fontFamily: SERIF }}\n                >\n                  {s.title}\n                </h3>\n                {s.note && (\n                  <span className=\"text-[11.5px]\" style={{ color: pal.faint }}>\n                    {s.note}\n                  </span>\n                )}\n              </div>\n            )}\n            {tab !== 0 && s.note && (\n              <p className=\"m-0 mb-3 text-[12px]\" style={{ color: pal.faint }}>\n                {s.note}\n              </p>\n            )}\n            <ul className=\"m-0 flex list-none flex-col gap-3.5 p-0\">\n              {s.items.map((item) => {\n                const delay = Math.min(order++, 14) * 28;\n                return (\n                  <li\n                    key={item.name}\n                    className=\"break-inside-avoid\"\n                    style={{\n                      animation: reduce\n                        ? undefined\n                        : `plm-in 360ms ${delay}ms both ease-out`,\n                    }}\n                  >\n                    <div className=\"flex items-baseline gap-2\">\n                      <span className=\"text-[15.5px] font-medium\">\n                        {item.name}\n                        {item.popular && (\n                          <span\n                            aria-label=\"Favourite\"\n                            className=\"ml-1.5 text-[12px]\"\n                            style={{ color: pal.accent }}\n                          >\n                            ★\n                          </span>\n                        )}\n                      </span>\n                      <span\n                        aria-hidden=\"true\"\n                        className=\"min-w-5 flex-1 translate-y-[-3px] border-b border-dotted\"\n                        style={{ borderColor: pal.faint }}\n                      />\n                      {Array.isArray(item.price) ? (\n                        <span className=\"flex gap-2.5 text-[14.5px] tabular-nums\">\n                          {item.price.map((v) => (\n                            <span key={v.label}>\n                              <span\n                                className=\"mr-1 text-[10.5px]\"\n                                style={{ color: pal.faint }}\n                              >\n                                {v.label}\n                              </span>\n                              {currency}\n                              {fmt(v.price)}\n                            </span>\n                          ))}\n                        </span>\n                      ) : (\n                        <span className=\"text-[14.5px] tabular-nums\">\n                          {currency}\n                          {fmt(item.price)}\n                        </span>\n                      )}\n                    </div>\n                    {(item.description || item.tags?.length) && (\n                      <p\n                        className=\"m-0 mt-0.5 text-[12.5px] leading-snug\"\n                        style={{ color: pal.sub }}\n                      >\n                        {item.description}\n                        {item.tags?.map((t) => (\n                          <span\n                            key={t}\n                            className=\"ml-1.5 text-[10.5px] tracking-[0.04em] whitespace-nowrap uppercase\"\n                            style={{ color: pal.faint }}\n                          >\n                            {t}\n                          </span>\n                        ))}\n                      </p>\n                    )}\n                  </li>\n                );\n              })}\n            </ul>\n          </section>\n        ))}\n      </div>\n\n      {footnote && (\n        <p\n          className=\"m-0 mt-7 border-t pt-4 text-center text-[11.5px]\"\n          style={{ borderColor: pal.border, color: pal.faint }}\n        >\n          {footnote}\n        </p>\n      )}\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}