@bearmenu/ui 0.8.9 → 0.8.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/dist/chunk-24RFI4RQ.js +167 -0
  2. package/dist/chunk-2XCZJWTV.js +121 -0
  3. package/dist/chunk-5RWTOT5Y.js +72 -0
  4. package/dist/{chunk-AXV5O2IZ.js → chunk-AKQ57NXY.js} +3 -3
  5. package/dist/chunk-CLLY6XB3.js +41 -0
  6. package/dist/chunk-DTXNDLSE.js +125 -0
  7. package/dist/chunk-F6FMZJDG.js +113 -0
  8. package/dist/{chunk-2WDJR6K7.js → chunk-G7IFL4Z4.js} +4 -1
  9. package/dist/chunk-MZL7CGCL.js +109 -0
  10. package/dist/chunk-SY6RV476.js +48 -0
  11. package/dist/chunk-UDN7UHJW.js +60 -0
  12. package/dist/{chunk-TT3WFS6S.js → chunk-YOKHBAIH.js} +11 -11
  13. package/dist/components/badge.d.ts +1 -1
  14. package/dist/components/button.d.ts +1 -1
  15. package/dist/components/command.d.ts +7 -7
  16. package/dist/components/concept-compare-rail.d.ts +50 -0
  17. package/dist/components/concept-compare-rail.js +5 -0
  18. package/dist/components/concept-compare.d.ts +75 -38
  19. package/dist/components/concept-compare.js +209 -133
  20. package/dist/components/concept-convergence.d.ts +41 -0
  21. package/dist/components/concept-convergence.js +53 -0
  22. package/dist/components/convergence.d.ts +25 -0
  23. package/dist/components/convergence.js +4 -0
  24. package/dist/components/date-input.d.ts +1 -1
  25. package/dist/components/event-card.js +1 -1
  26. package/dist/components/event-compact-row.js +1 -1
  27. package/dist/components/event-detail-panel.js +1 -1
  28. package/dist/components/event-index-row.js +1 -1
  29. package/dist/components/event-list-row-wide.js +1 -1
  30. package/dist/components/event-list-row.js +2 -2
  31. package/dist/components/explainer-steps.d.ts +34 -0
  32. package/dist/components/explainer-steps.js +36 -0
  33. package/dist/components/glass-ground.d.ts +66 -0
  34. package/dist/components/glass-ground.js +3 -0
  35. package/dist/components/hub-surface.js +11 -1
  36. package/dist/components/hue-chip.d.ts +70 -0
  37. package/dist/components/hue-chip.js +3 -0
  38. package/dist/components/kitchen-dossier.d.ts +88 -0
  39. package/dist/components/kitchen-dossier.js +187 -0
  40. package/dist/components/menu-dead-end.d.ts +56 -0
  41. package/dist/components/menu-dead-end.js +49 -0
  42. package/dist/components/menu-family-block.d.ts +99 -0
  43. package/dist/components/menu-family-block.js +155 -0
  44. package/dist/components/menu-family-card.d.ts +33 -27
  45. package/dist/components/menu-family-card.js +43 -85
  46. package/dist/components/menu-field.js +92 -2
  47. package/dist/components/menu-filter-chips.d.ts +86 -0
  48. package/dist/components/menu-filter-chips.js +122 -0
  49. package/dist/components/menu-group-rows.d.ts +53 -0
  50. package/dist/components/menu-group-rows.js +67 -0
  51. package/dist/components/menu-index-header.d.ts +37 -0
  52. package/dist/components/menu-index-header.js +68 -0
  53. package/dist/components/menu-index-list.d.ts +48 -0
  54. package/dist/components/menu-index-list.js +96 -0
  55. package/dist/components/menu-intent-hero.d.ts +69 -0
  56. package/dist/components/menu-intent-hero.js +87 -0
  57. package/dist/components/menu-kitchen-list.d.ts +82 -0
  58. package/dist/components/menu-kitchen-list.js +5 -0
  59. package/dist/components/menu-mocks.d.ts +37 -2
  60. package/dist/components/menu-mocks.js +152 -27
  61. package/dist/components/menu-types.d.ts +182 -6
  62. package/dist/components/motion-icon-controls.js +2 -2
  63. package/dist/components/motion-icon-set.js +6 -6
  64. package/dist/components/motion-icon.d.ts +22 -1
  65. package/dist/components/motion-icon.js +1 -1
  66. package/dist/components/photo-ground.d.ts +64 -0
  67. package/dist/components/photo-ground.js +3 -0
  68. package/dist/components/place-about-tab.js +2 -2
  69. package/dist/components/place-details-mobile.js +2 -2
  70. package/dist/components/place-types.d.ts +2 -2
  71. package/dist/components/qa-block.d.ts +36 -0
  72. package/dist/components/qa-block.js +24 -0
  73. package/dist/components/scroll-fade.js +3 -121
  74. package/dist/components/snap-rail.d.ts +24 -1
  75. package/dist/components/snap-rail.js +3 -109
  76. package/dist/components/spinner.d.ts +2 -2
  77. package/dist/components/story.d.ts +34 -0
  78. package/dist/components/story.js +3 -0
  79. package/dist/components/text.d.ts +3 -3
  80. package/dist/components/top-comparison.d.ts +28 -0
  81. package/dist/components/top-comparison.js +76 -0
  82. package/dist/components/top-cross-link.d.ts +34 -0
  83. package/dist/components/top-cross-link.js +101 -0
  84. package/dist/components/top-ranking-entry.d.ts +53 -0
  85. package/dist/components/top-ranking-entry.js +217 -0
  86. package/dist/components/top-ranking-hero.d.ts +61 -0
  87. package/dist/components/top-ranking-hero.js +99 -0
  88. package/dist/components/top-ranking-legend.d.ts +69 -0
  89. package/dist/components/top-ranking-legend.js +124 -0
  90. package/dist/components/top-types.d.ts +109 -0
  91. package/dist/components/top-types.js +1 -0
  92. package/dist/components/venue-grade-dimensions.d.ts +3 -1
  93. package/dist/components/venue-grade-dimensions.js +1 -1
  94. package/dist/components/weekend-panel.js +2 -2
  95. package/package.json +1 -1
  96. package/src/components/concept-compare-rail.tsx +131 -0
  97. package/src/components/concept-compare.stories.tsx +122 -54
  98. package/src/components/concept-compare.tsx +363 -196
  99. package/src/components/concept-convergence.stories.tsx +53 -0
  100. package/src/components/concept-convergence.tsx +90 -0
  101. package/src/components/convergence.stories.tsx +54 -0
  102. package/src/components/convergence.tsx +177 -0
  103. package/src/components/explainer-steps.stories.tsx +46 -0
  104. package/src/components/explainer-steps.tsx +74 -0
  105. package/src/components/glass-ground.tsx +129 -0
  106. package/src/components/hub-surface.tsx +11 -1
  107. package/src/components/hue-chip.stories.tsx +76 -0
  108. package/src/components/hue-chip.test.tsx +62 -0
  109. package/src/components/hue-chip.tsx +99 -0
  110. package/src/components/kitchen-dossier.stories.tsx +108 -0
  111. package/src/components/kitchen-dossier.tsx +322 -0
  112. package/src/components/menu-dead-end.stories.tsx +67 -0
  113. package/src/components/menu-dead-end.tsx +127 -0
  114. package/src/components/menu-family-block.stories.tsx +91 -0
  115. package/src/components/menu-family-block.tsx +314 -0
  116. package/src/components/menu-family-card.stories.tsx +43 -35
  117. package/src/components/menu-family-card.tsx +122 -142
  118. package/src/components/menu-filter-chips.stories.tsx +107 -0
  119. package/src/components/menu-filter-chips.tsx +238 -0
  120. package/src/components/menu-group-rows.stories.tsx +54 -0
  121. package/src/components/menu-group-rows.tsx +133 -0
  122. package/src/components/menu-index-header.stories.tsx +72 -0
  123. package/src/components/menu-index-header.tsx +125 -0
  124. package/src/components/menu-index-list.stories.tsx +50 -0
  125. package/src/components/menu-index-list.tsx +149 -0
  126. package/src/components/menu-intent-hero.stories.tsx +67 -0
  127. package/src/components/menu-intent-hero.tsx +189 -0
  128. package/src/components/menu-kitchen-list.stories.tsx +67 -0
  129. package/src/components/menu-kitchen-list.test.tsx +78 -0
  130. package/src/components/menu-kitchen-list.tsx +284 -0
  131. package/src/components/menu-mocks.ts +198 -23
  132. package/src/components/menu-types.ts +189 -6
  133. package/src/components/motion-icon-controls.tsx +11 -11
  134. package/src/components/motion-icon-set.tsx +6 -5
  135. package/src/components/motion-icon.test.tsx +23 -1
  136. package/src/components/motion-icon.tsx +20 -0
  137. package/src/components/photo-ground.tsx +147 -0
  138. package/src/components/place-types.ts +2 -2
  139. package/src/components/qa-block.stories.tsx +43 -0
  140. package/src/components/qa-block.tsx +60 -0
  141. package/src/components/snap-rail.tsx +58 -15
  142. package/src/components/story.tsx +225 -0
  143. package/src/components/top-comparison.stories.tsx +78 -0
  144. package/src/components/top-comparison.tsx +151 -0
  145. package/src/components/top-cross-link.stories.tsx +84 -0
  146. package/src/components/top-cross-link.tsx +171 -0
  147. package/src/components/top-ranking-entry.stories.tsx +171 -0
  148. package/src/components/top-ranking-entry.test.tsx +105 -0
  149. package/src/components/top-ranking-entry.tsx +425 -0
  150. package/src/components/top-ranking-hero.stories.tsx +76 -0
  151. package/src/components/top-ranking-hero.tsx +218 -0
  152. package/src/components/top-ranking-legend.stories.tsx +78 -0
  153. package/src/components/top-ranking-legend.tsx +239 -0
  154. package/src/components/top-types.ts +110 -0
  155. package/src/components/venue-grade-dimensions.tsx +2 -2
  156. package/dist/chunk-THOVPZNN.js +0 -37
  157. package/dist/chunk-YS6BHKZO.js +0 -92
  158. package/dist/components/ranked-venue-list.d.ts +0 -49
  159. package/dist/components/ranked-venue-list.js +0 -87
  160. package/dist/components/signature-line-list.d.ts +0 -45
  161. package/dist/components/signature-line-list.js +0 -99
  162. package/dist/components/venue-busyness-strip.d.ts +0 -35
  163. package/dist/components/venue-busyness-strip.js +0 -37
  164. package/dist/components/venue-signature-block.d.ts +0 -39
  165. package/dist/components/venue-signature-block.js +0 -6
  166. package/dist/components/venue-spotlight.d.ts +0 -74
  167. package/dist/components/venue-spotlight.js +0 -138
  168. package/src/components/ranked-venue-list.stories.tsx +0 -80
  169. package/src/components/ranked-venue-list.tsx +0 -177
  170. package/src/components/signature-line-list.stories.tsx +0 -85
  171. package/src/components/signature-line-list.tsx +0 -136
  172. package/src/components/venue-busyness-strip.stories.tsx +0 -66
  173. package/src/components/venue-busyness-strip.tsx +0 -64
  174. package/src/components/venue-signature-block.stories.tsx +0 -68
  175. package/src/components/venue-signature-block.tsx +0 -71
  176. package/src/components/venue-spotlight.stories.tsx +0 -141
  177. package/src/components/venue-spotlight.tsx +0 -236
  178. package/dist/{chunk-XWMRABZW.js → chunk-HSIYYA2E.js} +1 -1
@@ -0,0 +1,238 @@
1
+ import { X } from "lucide-react";
2
+ import { cn } from "../lib/utils";
3
+ import { ScrollFade } from "./scroll-fade";
4
+ import { Skeleton } from "./skeleton";
5
+ import type { MenuFilterChip } from "./menu-types";
6
+
7
+ /**
8
+ * MenuFilterChips — the intent page's filter row.
9
+ *
10
+ * ## One unit, one list that moves
11
+ *
12
+ * Every chip counts KITCHENS, whatever facet is behind it. A dietary chip reads
13
+ * "has a vegetarian dish" and counts venues; a dish-group chip reads "has a
14
+ * pizza" and counts venues. The earlier version mixed venue counts and dish
15
+ * counts in one row and became unreadable — you could not tell what a number
16
+ * was counting without reading the label that produced it. The unit is stated
17
+ * once, at the head of the row (`unitLabel`, e.g. "KITCHENS · 247"), and never
18
+ * again.
19
+ *
20
+ * ## A zero-count chip is dimmed, not disabled
21
+ *
22
+ * `empty` chips stay tappable. Pressing one swaps it in and drops whichever
23
+ * active filter conflicts with it, and the caller says which in a line beneath.
24
+ * Disabling it would refuse the reader the thing they asked for and give no
25
+ * reason; this way the row answers the question by being pressed. Facets the
26
+ * API says are unavailable for this intent are not passed in at all — not
27
+ * drawn, rather than drawn dead.
28
+ *
29
+ * ## The row scrolls; the escape hatch does not
30
+ *
31
+ * One line in every state. Chips scroll horizontally under a `<ScrollFade>`,
32
+ * and "More filters" is pinned opposite the unit label rather than wrapping,
33
+ * so the way out of a full row is always in the same place.
34
+ *
35
+ * Interactive: the consumer marks its own module `"use client"`.
36
+ */
37
+
38
+ export type MenuFilterChipsProps = {
39
+ chips: MenuFilterChip[];
40
+ onToggle: (key: string) => void;
41
+ /** The unit and the current total, composed by the caller, e.g. "KITCHENS · 247". */
42
+ unitLabel?: string;
43
+ /** Opens the full filter sheet. Omit for a row where every facet is a chip. */
44
+ onMore?: () => void;
45
+ moreLabel?: string;
46
+ /**
47
+ * A glyph for the phone's icon-only "more filters" button.
48
+ *
49
+ * The label is the widest fixed element in the row — "More filters" is ~80px
50
+ * of a 358px viewport, and it is the one thing that never scrolls, so it eats
51
+ * the chips' runway on every phone. Given an icon, the button collapses to a
52
+ * square below `lg` and keeps `moreLabel` as its accessible name.
53
+ *
54
+ * A node rather than a name because the app owns its iconography, and this
55
+ * one is animated on press — the DS neither knows the glyph nor drives it.
56
+ */
57
+ moreIcon?: React.ReactNode;
58
+ /** Press handler for the icon button, e.g. to replay the glyph's animation. */
59
+ onMorePointerDown?: () => void;
60
+ /** Locale-aware integer formatter for the counts. Defaults to `String`. */
61
+ formatCount?: (value: number) => string;
62
+ /** Accessible name for the row. */
63
+ ariaLabel?: string;
64
+ className?: string;
65
+ };
66
+
67
+ export function MenuFilterChips({
68
+ chips,
69
+ onToggle,
70
+ unitLabel,
71
+ onMore,
72
+ moreLabel,
73
+ moreIcon,
74
+ onMorePointerDown,
75
+ formatCount = String,
76
+ ariaLabel,
77
+ className,
78
+ }: MenuFilterChipsProps) {
79
+ return (
80
+ <div className={cn("relative flex items-center gap-2", className)}>
81
+ {/* Desktop only. It states a unit and a total that the section heading
82
+ directly below already gives in full ("The kitchens Cluj-Napoca rates
83
+ for Italian · 247"), and on a phone it is a fixed 110px bitten out of
84
+ the one row that needs every pixel to scroll. */}
85
+ {unitLabel && (
86
+ <span className="hidden shrink-0 pr-0.5 text-[11px] font-extrabold uppercase tracking-[0.1em] text-muted-foreground lg:inline">
87
+ {unitLabel}
88
+ </span>
89
+ )}
90
+
91
+ <ScrollFade
92
+ orientation="horizontal"
93
+ size="sm"
94
+ className="min-w-0 flex-1"
95
+ scrollClassName="scrollbar-hide"
96
+ >
97
+ <div className="flex items-center gap-2" role="group" aria-label={ariaLabel}>
98
+ {chips.map((chip) => (
99
+ <Chip
100
+ key={chip.key}
101
+ chip={chip}
102
+ onToggle={() => onToggle(chip.key)}
103
+ formatCount={formatCount}
104
+ />
105
+ ))}
106
+ </div>
107
+ </ScrollFade>
108
+
109
+ {onMore && (
110
+ <>
111
+ {/* One control, two shapes. On a phone it is a 40px square carrying
112
+ the caller's glyph, with `moreLabel` as its accessible name; from
113
+ `lg` it is the text link it has always been. Two elements rather
114
+ than one so neither has to carry the other's padding, and both
115
+ stay `shrink-0` against the scrolling chips. */}
116
+ {moreIcon && (
117
+ <button
118
+ type="button"
119
+ onClick={onMore}
120
+ onPointerDown={onMorePointerDown}
121
+ aria-label={moreLabel}
122
+ aria-haspopup="dialog"
123
+ className="inline-flex size-10 shrink-0 items-center justify-center rounded-full border border-border text-accent transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring motion-reduce:transition-none lg:hidden"
124
+ >
125
+ {moreIcon}
126
+ </button>
127
+ )}
128
+ <button
129
+ type="button"
130
+ onClick={onMore}
131
+ className={cn(
132
+ "shrink-0 rounded-md pl-2 text-[12.5px] font-bold text-accent transition-colors hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring motion-reduce:transition-none",
133
+ moreIcon && "hidden lg:inline"
134
+ )}
135
+ >
136
+ {moreLabel}
137
+ </button>
138
+ </>
139
+ )}
140
+ </div>
141
+ );
142
+ }
143
+
144
+ function Chip({
145
+ chip,
146
+ onToggle,
147
+ formatCount,
148
+ }: {
149
+ chip: MenuFilterChip;
150
+ onToggle: () => void;
151
+ formatCount: (value: number) => string;
152
+ }) {
153
+ return (
154
+ <button
155
+ type="button"
156
+ onClick={onToggle}
157
+ aria-pressed={chip.active}
158
+ className={cn(
159
+ "inline-flex h-9 shrink-0 items-center gap-1.5 whitespace-nowrap rounded-full border px-4 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring motion-reduce:transition-none",
160
+ chip.active
161
+ ? "border-accent font-semibold text-accent shadow-[0_1px_2px_oklch(0.51_0.095_45_/_0.08)]"
162
+ : "border-border bg-card text-foreground hover:border-accent/40",
163
+ // Dimmed, never disabled — pressing it is how the reader finds out
164
+ // which active filter is in the way.
165
+ chip.empty && "opacity-45"
166
+ )}
167
+ >
168
+ {chip.icon}
169
+ {chip.label}
170
+ {chip.count !== undefined && (
171
+ <span className={cn("tabular-nums", chip.active ? "text-accent" : "text-muted-foreground")}>
172
+ {formatCount(chip.count)}
173
+ </span>
174
+ )}
175
+ {chip.active && <X className="h-3 w-3 shrink-0" aria-hidden />}
176
+ </button>
177
+ );
178
+ }
179
+
180
+ /**
181
+ * MenuFilterSummary — what the active filters did, and the way out.
182
+ *
183
+ * Sits under the row whenever anything is on. The sentence is composed by the
184
+ * caller because it is a real sentence in two languages ("Three filters · 34 of
185
+ * 247 kitchens are mid-range, have a vegetarian Italian dish, and are open
186
+ * now") and assembling it from fragments here would produce translated
187
+ * word-salad in one of them.
188
+ */
189
+ export type MenuFilterSummaryProps = {
190
+ /** The composed sentence. */
191
+ summary: React.ReactNode;
192
+ clearLabel: string;
193
+ onClear: () => void;
194
+ className?: string;
195
+ };
196
+
197
+ export function MenuFilterSummary({
198
+ summary,
199
+ clearLabel,
200
+ onClear,
201
+ className,
202
+ }: MenuFilterSummaryProps) {
203
+ return (
204
+ <div className={cn("flex flex-wrap items-center gap-2.5 pt-3.5", className)}>
205
+ <span className="text-[13px] text-muted-foreground [&_b]:font-bold [&_b]:text-foreground">
206
+ {summary}
207
+ </span>
208
+ <button
209
+ type="button"
210
+ onClick={onClear}
211
+ className="ml-auto shrink-0 rounded-md text-[12.5px] font-bold text-accent transition-colors hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring motion-reduce:transition-none"
212
+ >
213
+ {clearLabel}
214
+ </button>
215
+ </div>
216
+ );
217
+ }
218
+
219
+ // ─── Skeleton ───────────────────────────────────────────────────────────────
220
+
221
+ /**
222
+ * One line, as the row itself renders — never a wrapped block.
223
+ *
224
+ * The widths vary deliberately: six identical pills read as a progress bar, and
225
+ * the real row is a set of labels of different lengths.
226
+ */
227
+ const CHIP_WIDTHS = [128, 104, 96, 148, 112, 88];
228
+
229
+ export function MenuFilterChipsSkeleton({ className }: { className?: string }) {
230
+ return (
231
+ <div className={cn("flex items-center gap-2 overflow-hidden", className)} aria-hidden>
232
+ <Skeleton className="h-3 w-[92px] shrink-0" />
233
+ {CHIP_WIDTHS.map((width, index) => (
234
+ <Skeleton key={index} className="h-9 shrink-0 rounded-full" style={{ width }} />
235
+ ))}
236
+ </div>
237
+ );
238
+ }
@@ -0,0 +1,54 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { MenuGroupRows } from "./menu-group-rows";
3
+ import { mockGradients } from "./menu-mocks";
4
+
5
+ const meta: Meta<typeof MenuGroupRows> = {
6
+ title: "Menu/MenuGroupRows",
7
+ component: MenuGroupRows,
8
+ tags: ["autodocs"],
9
+ decorators: [
10
+ (Story) => (
11
+ <div className="w-[380px] bg-background p-4">
12
+ <Story />
13
+ </div>
14
+ ),
15
+ ],
16
+ parameters: {
17
+ docs: {
18
+ description: {
19
+ component:
20
+ "What an intent consists of — the `dish_groups` facet on a cuisine page, digest tags and graded strengths on a going-out page. One component for both, because both are the same object: a facet value, its venue count and a range. The counts are VENUES: no endpoint counts dishes per cuisine, so *120* is a hundred and twenty kitchens that make a pizza, and the `meta` line is composed by the caller so it can say which.",
21
+ },
22
+ },
23
+ },
24
+ };
25
+
26
+ export default meta;
27
+ type Story = StoryObj<typeof MenuGroupRows>;
28
+
29
+ export const Cuisine: Story = {
30
+ args: {
31
+ rows: [
32
+ { slug: "pizza", name: "Pizza", meta: "120 kitchens", rangeLabel: "30—68", href: "#", gradient: mockGradients.pasta },
33
+ { slug: "pasta", name: "Pasta", meta: "96 kitchens", rangeLabel: "38—84", href: "#", gradient: mockGradients.pasta },
34
+ { slug: "salad", name: "Salad", meta: "88 kitchens", rangeLabel: "22—56", href: "#", gradient: mockGradients.greens },
35
+ { slug: "beef", name: "Beef", meta: "77 kitchens", rangeLabel: "34—72", href: "#", gradient: mockGradients.meat },
36
+ ],
37
+ },
38
+ };
39
+
40
+ /** The going-out side: tags and strengths, and no price range behind them. */
41
+ export const GoingOut: Story = {
42
+ args: {
43
+ rows: [
44
+ { slug: "cocktails", name: "Cocktails", meta: "63 places", href: "#", gradient: mockGradients.cocktail },
45
+ { slug: "late_night", name: "Open late", meta: "59 places", href: "#", gradient: mockGradients.meat },
46
+ { slug: "drinks_quality", name: "Strong on drinks", meta: "131 places", href: "#", gradient: mockGradients.sweet },
47
+ ],
48
+ },
49
+ };
50
+
51
+ /** No gradient and no range — the row still reads. */
52
+ export const Bare: Story = {
53
+ args: { rows: [{ slug: "soup", name: "Soup", meta: "169 kitchens" }] },
54
+ };
@@ -0,0 +1,133 @@
1
+ import { ChevronRight } from "lucide-react";
2
+ import { cn } from "../lib/utils";
3
+ import { Skeleton } from "./skeleton";
4
+ import type { MenuLinkComponent, MenuLinkProps } from "./menu-types";
5
+
6
+ /**
7
+ * MenuGroupRows — what an intent consists of.
8
+ *
9
+ * On a cuisine page this is the `dish_groups` facet narrowed by the cuisine
10
+ * ("Pizza · 120 kitchens · 30–68"); on a going-out page it is the digest tags
11
+ * and graded strengths ("Cocktails · 63 places"). One component for both,
12
+ * because both are the same object: a facet value, its venue count, and a range.
13
+ *
14
+ * ## The counts are VENUES, and the label has to say so
15
+ *
16
+ * There is no endpoint that counts dishes per cuisine — `/dishes` accepts
17
+ * `cuisine_slugs` and ignores it — so "120" here is a hundred and twenty
18
+ * kitchens that make a pizza, not a hundred and twenty pizzas. The `meta` line
19
+ * is composed by the caller precisely so that it can say which, in a language
20
+ * where the two words differ.
21
+ *
22
+ * ## Not `<ConceptCard>`
23
+ *
24
+ * That one is a cover-led card for a thing with a date and a venue. This is a
25
+ * row in a sidebar: a hue bar, a name, a count and a range. Giving it a cover
26
+ * would mean finding a photograph of "pasta", which is the kind of picture that
27
+ * makes a page look generated.
28
+ */
29
+
30
+ /** @deprecated Alias of `MenuLinkProps`; kept for symmetry with the other menu surfaces. */
31
+ export type MenuGroupRowsLinkProps = MenuLinkProps;
32
+
33
+ function DefaultLink({ href, ...props }: MenuGroupRowsLinkProps) {
34
+ return <a href={href} {...props} />;
35
+ }
36
+
37
+ export type MenuGroupRow = {
38
+ slug: string;
39
+ name: string;
40
+ /** Venue count line, e.g. "120 kitchens". Pluralised by the caller. */
41
+ meta: string;
42
+ /** Price range, already formatted, e.g. "30—68". Omitted where none is known. */
43
+ rangeLabel?: string;
44
+ href?: string;
45
+ /** Finished CSS gradient for the bar. A missing one falls back to the border colour. */
46
+ gradient?: string;
47
+ };
48
+
49
+ export type MenuGroupRowsProps = {
50
+ rows: MenuGroupRow[];
51
+ linkComponent?: MenuLinkComponent;
52
+ className?: string;
53
+ };
54
+
55
+ export function MenuGroupRows({
56
+ rows,
57
+ linkComponent: LinkComponent = DefaultLink,
58
+ className,
59
+ }: MenuGroupRowsProps) {
60
+ return (
61
+ <ul className={cn("flex flex-col", className)}>
62
+ {rows.map((row) => {
63
+ const body = (
64
+ <>
65
+ <span
66
+ aria-hidden
67
+ className={cn(
68
+ "h-[34px] w-2 shrink-0 rounded-full",
69
+ !row.gradient && "bg-border"
70
+ )}
71
+ style={row.gradient ? { backgroundImage: row.gradient } : undefined}
72
+ />
73
+ <span className="min-w-0 flex-1">
74
+ <span className="block truncate text-sm font-bold">{row.name}</span>
75
+ <span className="mt-px block truncate text-[11.5px] text-muted-foreground">
76
+ {row.meta}
77
+ </span>
78
+ </span>
79
+ {row.rangeLabel && (
80
+ <span className="shrink-0 font-mono text-xs tabular-nums text-muted-foreground">
81
+ {row.rangeLabel}
82
+ </span>
83
+ )}
84
+ <ChevronRight className="h-3.5 w-3.5 shrink-0 text-muted-foreground" aria-hidden />
85
+ </>
86
+ );
87
+
88
+ return (
89
+ <li key={row.slug} className="border-t border-border first:border-t-0">
90
+ {row.href ? (
91
+ <LinkComponent
92
+ href={row.href}
93
+ className="flex items-center gap-3 py-3 transition-colors hover:bg-muted/30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring motion-reduce:transition-none"
94
+ >
95
+ {body}
96
+ </LinkComponent>
97
+ ) : (
98
+ <span className="flex items-center gap-3 py-3">{body}</span>
99
+ )}
100
+ </li>
101
+ );
102
+ })}
103
+ </ul>
104
+ );
105
+ }
106
+
107
+ // ─── Skeleton ───────────────────────────────────────────────────────────────
108
+
109
+ export function MenuGroupRowsSkeleton({
110
+ rows = 5,
111
+ className,
112
+ }: {
113
+ rows?: number;
114
+ className?: string;
115
+ }) {
116
+ return (
117
+ <div className={cn("flex flex-col", className)} aria-hidden>
118
+ {Array.from({ length: rows }, (_, index) => (
119
+ <div
120
+ key={index}
121
+ className="flex items-center gap-3 border-t border-border py-3 first:border-t-0"
122
+ >
123
+ <Skeleton className="h-[34px] w-2 rounded-full" />
124
+ <div className="flex min-w-0 flex-1 flex-col gap-1.5">
125
+ <Skeleton className="h-3.5 w-[50%]" />
126
+ <Skeleton className="h-3 w-[35%]" />
127
+ </div>
128
+ <Skeleton className="h-3 w-[52px]" />
129
+ </div>
130
+ ))}
131
+ </div>
132
+ );
133
+ }
@@ -0,0 +1,72 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { UtensilsCrossed, Wine } from "lucide-react";
3
+ import { MenuIndexHeader, MenuJumpStrip } from "./menu-index-header";
4
+ import { SegmentedNav } from "./segmented-nav";
5
+ import { mockIndexEntries } from "./menu-mocks";
6
+
7
+ const scopeSwitch = (
8
+ <SegmentedNav
9
+ label="Menu scope"
10
+ activeId="food"
11
+ items={[
12
+ { id: "food", href: "/menu/cuisines", label: "Food", icon: <UtensilsCrossed className="h-4 w-4" /> },
13
+ { id: "drinks", href: "/menu/drinks/families", label: "Drinks", icon: <Wine className="h-4 w-4" /> },
14
+ ]}
15
+ />
16
+ );
17
+
18
+ const meta: Meta<typeof MenuIndexHeader> = {
19
+ title: "Menu/MenuIndexHeader",
20
+ component: MenuIndexHeader,
21
+ tags: ["autodocs"],
22
+ args: {
23
+ eyebrow: "MENU · CLUJ-NAPOCA",
24
+ title: "Browse by cuisine",
25
+ count: "38 cuisines",
26
+ subtitle: "Kitchens, the plates that define them, and what they cost.",
27
+ scopeSwitch,
28
+ },
29
+ decorators: [
30
+ (Story) => (
31
+ <div className="w-[1100px] bg-background p-4">
32
+ <Story />
33
+ </div>
34
+ ),
35
+ ],
36
+ parameters: {
37
+ docs: {
38
+ description: {
39
+ component:
40
+ "The hub's own section title, opened up — so the page reads as that section rather than as somewhere new, which is what the *All 38 cuisines* link promised. The scope switch is a slot, not a prop set: the two scopes are two ROUTES, so the caller passes a `SegmentedNav` with real hrefs and the DS stays out of routing.",
41
+ },
42
+ },
43
+ },
44
+ };
45
+
46
+ export default meta;
47
+ type Story = StoryObj<typeof MenuIndexHeader>;
48
+
49
+ export const Default: Story = {};
50
+
51
+ export const Drinks: Story = {
52
+ args: {
53
+ title: "Where to go out",
54
+ count: "5 kinds of night",
55
+ subtitle: "Bars, the glass that defines them, and what it costs.",
56
+ },
57
+ };
58
+
59
+ /** The strip lists only the families drawn in full — otherwise it is the index, twice. */
60
+ export const JumpStrip: StoryObj<typeof MenuJumpStrip> = {
61
+ render: () => <MenuJumpStrip entries={mockIndexEntries.slice(0, 8)} ariaLabel="Jump to a cuisine" />,
62
+ };
63
+
64
+ export const Mobile: Story = {
65
+ decorators: [
66
+ (Story) => (
67
+ <div className="w-[390px] bg-background p-3">
68
+ <Story />
69
+ </div>
70
+ ),
71
+ ],
72
+ };
@@ -0,0 +1,125 @@
1
+ import { cn } from "../lib/utils";
2
+ import { ScrollFade } from "./scroll-fade";
3
+ import type { MenuIndexEntry, MenuLinkComponent, MenuLinkProps } from "./menu-types";
4
+
5
+ /**
6
+ * MenuIndexHeader — the head of a browse index.
7
+ *
8
+ * The hub's own section title, opened up: the page reads as that section rather
9
+ * than as a new place, which is the whole promise of the "All 38 cuisines" link
10
+ * that got the reader here.
11
+ *
12
+ * The scope switch is a slot rather than a prop set, because the two scopes are
13
+ * two ROUTES — the caller passes a `<SegmentedNav>` with real hrefs and the DS
14
+ * stays out of routing.
15
+ */
16
+
17
+ function DefaultLink({ href, ...props }: MenuLinkProps) {
18
+ return <a href={href} {...props} />;
19
+ }
20
+
21
+ export type MenuIndexHeaderProps = {
22
+ /** Small caps over the title, e.g. "MENU · CLUJ-NAPOCA". */
23
+ eyebrow?: string;
24
+ title: string;
25
+ /** Sits beside the title, e.g. "38 cuisines". Pluralised by the caller. */
26
+ count?: string;
27
+ subtitle?: string;
28
+ /** The Food / Drinks control. A `<SegmentedNav>`, composed by the caller. */
29
+ scopeSwitch?: React.ReactNode;
30
+ className?: string;
31
+ };
32
+
33
+ export function MenuIndexHeader({
34
+ eyebrow,
35
+ title,
36
+ count,
37
+ subtitle,
38
+ scopeSwitch,
39
+ className,
40
+ }: MenuIndexHeaderProps) {
41
+ return (
42
+ <div className={cn("flex flex-col gap-4 lg:flex-row lg:items-start lg:gap-8", className)}>
43
+ <div className="min-w-0 flex-1">
44
+ {eyebrow && (
45
+ <p className="text-[11px] font-bold uppercase tracking-[0.1em] text-muted-foreground">
46
+ {eyebrow}
47
+ </p>
48
+ )}
49
+ <h1 className="mt-1.5 text-[30px] font-black leading-[1.05] tracking-[-0.035em] lg:text-[40px]">
50
+ {title}
51
+ {count && (
52
+ <span className="ml-2.5 align-middle text-base font-semibold text-muted-foreground lg:text-lg">
53
+ {count}
54
+ </span>
55
+ )}
56
+ </h1>
57
+ {subtitle && (
58
+ <p className="mt-2 max-w-[60ch] text-sm text-muted-foreground">{subtitle}</p>
59
+ )}
60
+ </div>
61
+
62
+ {/* Sticky under the header on the phone: the list below is several screens
63
+ and a reader who wants the other scope should not have to scroll back
64
+ up to a control they can see from anywhere else on the page. */}
65
+ {scopeSwitch && (
66
+ <div className="sticky top-0 z-10 -mx-[var(--page-gutter)] bg-background px-[var(--page-gutter)] py-2 lg:static lg:mx-0 lg:bg-transparent lg:px-0 lg:py-0">
67
+ {scopeSwitch}
68
+ </div>
69
+ )}
70
+ </div>
71
+ );
72
+ }
73
+
74
+ /**
75
+ * MenuJumpStrip — the page's contents, as chips.
76
+ *
77
+ * It answers "move between families without going back to the hub", and it
78
+ * doubles as a table of contents: each chip carries the family's mark and its
79
+ * count, so the strip says how long the page is before the reader scrolls it.
80
+ *
81
+ * Only the families drawn in full belong here. A strip listing every value in
82
+ * the index below would be the index, twice.
83
+ */
84
+ export type MenuJumpStripProps = {
85
+ entries: MenuIndexEntry[];
86
+ formatCount?: (value: number) => string;
87
+ ariaLabel?: string;
88
+ linkComponent?: MenuLinkComponent;
89
+ className?: string;
90
+ };
91
+
92
+ export function MenuJumpStrip({
93
+ entries,
94
+ formatCount = String,
95
+ ariaLabel,
96
+ linkComponent: LinkComponent = DefaultLink,
97
+ className,
98
+ }: MenuJumpStripProps) {
99
+ return (
100
+ <ScrollFade
101
+ orientation="horizontal"
102
+ size="sm"
103
+ className={className}
104
+ scrollClassName="scrollbar-hide"
105
+ >
106
+ <nav aria-label={ariaLabel} className="flex items-center gap-2">
107
+ {entries.map((entry) => (
108
+ <LinkComponent
109
+ key={entry.slug}
110
+ href={entry.href}
111
+ className="inline-flex h-9 shrink-0 items-center gap-2 whitespace-nowrap rounded-full border border-border bg-card px-4 text-sm transition-colors hover:border-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring motion-reduce:transition-none"
112
+ >
113
+ <span
114
+ aria-hidden
115
+ className={cn("h-2.5 w-2.5 shrink-0 rounded-[3px]", !entry.gradient && "bg-border")}
116
+ style={entry.gradient ? { backgroundImage: entry.gradient } : undefined}
117
+ />
118
+ {entry.name}
119
+ <span className="tabular-nums text-muted-foreground">{formatCount(entry.count)}</span>
120
+ </LinkComponent>
121
+ ))}
122
+ </nav>
123
+ </ScrollFade>
124
+ );
125
+ }
@@ -0,0 +1,50 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { MenuIndexList } from "./menu-index-list";
3
+ import { mockIndexEntries } from "./menu-mocks";
4
+
5
+ const meta: Meta<typeof MenuIndexList> = {
6
+ title: "Menu/MenuIndexList",
7
+ component: MenuIndexList,
8
+ tags: ["autodocs"],
9
+ args: {
10
+ entries: mockIndexEntries,
11
+ title: `All ${mockIndexEntries.length} cuisines`,
12
+ subtitle: "Ordered by kitchens — every one has its own page",
13
+ },
14
+ decorators: [
15
+ (Story) => (
16
+ <div className="w-[1100px] bg-background p-4">
17
+ <Story />
18
+ </div>
19
+ ),
20
+ ],
21
+ parameters: {
22
+ docs: {
23
+ description: {
24
+ component:
25
+ "The complete set, four across — and the reason the page below it can be progressive. This block carries a crawlable link to **every** destination the city has, so the richer blocks underneath are free to load ten at a time behind a *show more* without hiding anything a crawler needs. Get that backwards and the page silently stops linking to the twenty-eight it is supposed to index. Note the counts overlap: cuisines are non-exclusive tags (Cluj's thirty-eight sum to 3,182 against 767 places), so this is a ranked list of ways in, never a breakdown.",
26
+ },
27
+ },
28
+ },
29
+ };
30
+
31
+ export default meta;
32
+ type Story = StoryObj<typeof MenuIndexList>;
33
+
34
+ export const Default: Story = {};
35
+
36
+ /** The long tail, which is where a layout tuned on the head of the list breaks. */
37
+ export const Tail: Story = {
38
+ args: { entries: mockIndexEntries.slice(-8), title: "The tail" },
39
+ };
40
+
41
+ /** Two columns, not one: thirty-eight rows in one column is four screens. */
42
+ export const Mobile: Story = {
43
+ decorators: [
44
+ (Story) => (
45
+ <div className="w-[390px] bg-background p-3">
46
+ <Story />
47
+ </div>
48
+ ),
49
+ ],
50
+ };