@atelic-action/ui 7.2.0 → 8.1.0

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 (131) hide show
  1. package/README.md +439 -132
  2. package/bin/atelic-check-sentry.ts +5 -0
  3. package/dist/gate/middleware.js +15 -1
  4. package/dist/monitoring/server.d.ts +72 -0
  5. package/dist/monitoring/server.js +201 -0
  6. package/dist/vite/index.d.ts +1 -1
  7. package/dist/vite/index.js +1 -1
  8. package/dist/vite/marketing-config.d.ts +28 -1
  9. package/dist/vite/marketing-config.js +62 -0
  10. package/package.json +23 -11
  11. package/src/app/ErrorFallback.tsx +6 -2
  12. package/src/app/context/AppContext.tsx +10 -1
  13. package/src/app/index.ts +0 -1
  14. package/src/app/layout/AppPage.tsx +36 -7
  15. package/src/app/layout/DesktopRail.tsx +15 -6
  16. package/src/app/layout/MobileMenu.tsx +14 -5
  17. package/src/app/layout/MobileTabBar.tsx +3 -2
  18. package/src/app/layout/PageError.tsx +7 -4
  19. package/src/app/layout/PageSkeleton.tsx +33 -26
  20. package/src/app/layout/SectionCards.tsx +7 -2
  21. package/src/app/layout/UserMenu.tsx +13 -7
  22. package/src/app/ui/alert.tsx +42 -12
  23. package/src/app/ui/badge.tsx +1 -1
  24. package/src/app/ui/button.tsx +2 -1
  25. package/src/app/ui/command.tsx +86 -21
  26. package/src/app/ui/country-dropdown.tsx +26 -47
  27. package/src/app/ui/form.tsx +48 -9
  28. package/src/app/ui/pagination.tsx +1 -1
  29. package/src/app/ui/progress.tsx +26 -12
  30. package/src/app/ui/search-input.tsx +16 -3
  31. package/src/app/ui/select.tsx +8 -3
  32. package/src/app/ui/slider.tsx +62 -15
  33. package/src/artifact/AppErrorBoundary.tsx +12 -7
  34. package/src/artifact/ArtifactShell.tsx +5 -1
  35. package/src/artifact/ErrorFallback.tsx +8 -1
  36. package/src/artifact/artifactConfig.ts +1 -1
  37. package/src/chrome/BrandLockup.tsx +102 -17
  38. package/src/chrome/ClosingBar.tsx +5 -3
  39. package/src/chrome/ContactDock.tsx +361 -0
  40. package/src/chrome/Footer.tsx +126 -31
  41. package/src/chrome/NavBadge.tsx +8 -0
  42. package/src/chrome/NavMegaPanel.tsx +399 -0
  43. package/src/chrome/SiteHeader.tsx +268 -23
  44. package/src/chrome/SiteMenu.tsx +200 -19
  45. package/src/chrome/SiteShell.tsx +151 -14
  46. package/src/chrome/StickyCTABar.tsx +60 -2
  47. package/src/chrome/brandMark.ts +56 -0
  48. package/src/chrome/icons.ts +58 -0
  49. package/src/chrome/index.ts +16 -0
  50. package/src/chrome/navSections.ts +55 -0
  51. package/src/components/ColumnChart.tsx +27 -2
  52. package/src/components/DataTable.tsx +104 -85
  53. package/src/components/Disclosure.tsx +3 -1
  54. package/src/components/Hint.tsx +3 -24
  55. package/src/components/NotFound.tsx +7 -3
  56. package/src/components/StarRating.tsx +45 -19
  57. package/src/components/ThresholdScale.tsx +36 -26
  58. package/src/email/atoms.tsx +13 -57
  59. package/src/email/frame.tsx +4 -6
  60. package/src/email/index.ts +4 -10
  61. package/src/email/scoreboard.tsx +107 -186
  62. package/src/email/text.ts +30 -0
  63. package/src/email/theme.tsx +76 -9
  64. package/src/gate/middleware.ts +15 -1
  65. package/src/hooks/useDismiss.ts +39 -0
  66. package/src/lib/emailText.tsx +26 -0
  67. package/src/lib/phoneText.tsx +40 -0
  68. package/src/lib/useScrollsSideways.ts +26 -0
  69. package/src/monitoring/ErrorCatcherScript.tsx +15 -0
  70. package/src/monitoring/catcher.ts +118 -0
  71. package/src/monitoring/index.ts +25 -0
  72. package/src/monitoring/sdk.ts +112 -0
  73. package/src/monitoring/server.ts +244 -0
  74. package/src/monitoring/start.ts +118 -0
  75. package/src/primitives/Button.tsx +5 -1
  76. package/src/primitives/Eyebrow.tsx +6 -2
  77. package/src/primitives/ProseBlocks.tsx +6 -1
  78. package/src/primitives/SectionHeading.tsx +3 -1
  79. package/src/primitives/StarRow.tsx +23 -8
  80. package/src/routing/index.ts +1 -0
  81. package/src/routing/miss.ts +32 -0
  82. package/src/scripts/check-sentry.ts +77 -0
  83. package/src/sections/BlogIndex.tsx +17 -3
  84. package/src/sections/BlogPost.tsx +10 -1
  85. package/src/sections/CTASection.tsx +2 -2
  86. package/src/sections/CalloutPanel.tsx +34 -0
  87. package/src/sections/ComparisonTable.tsx +23 -2
  88. package/src/sections/ContactForm.tsx +61 -17
  89. package/src/sections/FAQBrowser.tsx +11 -2
  90. package/src/sections/FeatureGrid.tsx +6 -2
  91. package/src/sections/FullBleedVideo.tsx +167 -0
  92. package/src/sections/Gallery.tsx +6 -4
  93. package/src/sections/Hero.tsx +70 -39
  94. package/src/sections/JumpRail.tsx +7 -0
  95. package/src/sections/LegalPage.tsx +10 -2
  96. package/src/sections/LinkColumns.tsx +80 -0
  97. package/src/sections/LocationSection.tsx +28 -5
  98. package/src/sections/Locations.tsx +18 -5
  99. package/src/sections/LogoMarquee.tsx +43 -11
  100. package/src/sections/MapEmbed.tsx +13 -9
  101. package/src/sections/PageHero.tsx +16 -2
  102. package/src/sections/ProcessSteps.tsx +27 -4
  103. package/src/sections/ProfileCards.tsx +12 -2
  104. package/src/sections/ProofStrip.tsx +44 -0
  105. package/src/sections/RevealSlider.tsx +28 -7
  106. package/src/sections/ReviewCarousel.tsx +17 -4
  107. package/src/sections/ReviewWall.tsx +2 -2
  108. package/src/sections/SplitSection.tsx +2 -1
  109. package/src/sections/index.ts +15 -6
  110. package/src/sections/siteConfig.ts +101 -8
  111. package/src/styles/app.css +33 -2
  112. package/src/styles/artifact.css +20 -8
  113. package/src/styles/base.css +68 -13
  114. package/src/styles/chrome.css +1134 -56
  115. package/src/styles/components.css +104 -65
  116. package/src/styles/defaults.css +140 -0
  117. package/src/styles/gate.css +21 -10
  118. package/src/styles/primitives.css +108 -39
  119. package/src/styles/sections.css +500 -437
  120. package/src/styles/star-rating.css +1 -4
  121. package/src/tokens/palettes.ts +24 -4
  122. package/src/types.ts +220 -3
  123. package/src/vite/index.ts +4 -0
  124. package/src/vite/marketing-config.ts +81 -1
  125. package/src/app/CardErrorBoundary.tsx +0 -39
  126. package/src/sections/CTABanner.tsx +0 -93
  127. package/src/sections/DeviceShowcase.tsx +0 -39
  128. package/src/sections/MediaBand.tsx +0 -20
  129. package/src/sections/MenuList.tsx +0 -44
  130. package/src/sections/PressQuotes.tsx +0 -51
  131. package/src/sections/SocialStrip.tsx +0 -83
@@ -1,8 +1,20 @@
1
- import { useEffect, useId, useState } from "react";
1
+ import { ChevronDown, Phone as PhoneIcon } from "lucide-react";
2
+ import {
3
+ type FocusEvent,
4
+ type KeyboardEvent,
5
+ type PointerEvent,
6
+ useEffect,
7
+ useId,
8
+ useRef,
9
+ useState,
10
+ } from "react";
11
+ import { useDismiss } from "../hooks/useDismiss";
2
12
  import { type PageStop, useScrollSpy } from "../hooks/useScrollSpy";
3
13
  import { newTabProps } from "../lib/newTabProps";
4
- import type { Brand, CallToAction, MenuContact, NavLink } from "../types";
14
+ import type { Brand, CallToAction, HeaderPhone, MenuContact, NavLink } from "../types";
5
15
  import { BrandLockup } from "./BrandLockup";
16
+ import { NavMegaPanel } from "./NavMegaPanel";
17
+ import { groupHrefs, isGroup } from "./navSections";
6
18
  import { SiteMenu } from "./SiteMenu";
7
19
 
8
20
  /**
@@ -14,7 +26,11 @@ export type SiteHeaderVariant = "transparent" | "solid" | "dark";
14
26
  export interface SiteHeaderProps {
15
27
  /** The identity the lockup renders. */
16
28
  brand: Brand;
17
- /** The site's primary nav. Omit on a page with no site nav, such as an artifact. */
29
+ /**
30
+ * The site's primary nav. Omit on a page with no site nav, such as an
31
+ * artifact. An entry with `columns` is a group: on a desktop it opens a
32
+ * mega menu panel, and in the phone's menu an accordion.
33
+ */
18
34
  links?: NavLink[];
19
35
  /** The primary action, in the bar on desktop and in the menu. */
20
36
  primaryCTA?: CallToAction;
@@ -32,12 +48,54 @@ export interface SiteHeaderProps {
32
48
  hideCTA?: boolean;
33
49
  /** The contact block at the foot of the menu. */
34
50
  contact?: MenuContact;
51
+ /**
52
+ * Up to two numbers the bar shows on a desktop, each a tel link, with the
53
+ * first as a call button beside the burger on a phone. A third is dropped.
54
+ */
55
+ phones?: HeaderPhone[];
56
+ /**
57
+ * Words shown beside the burger, e.g. "Menu", which also name it. Absent,
58
+ * the burger is its three lines alone, named "Open menu" or "Close menu".
59
+ */
60
+ menuLabel?: string;
61
+ }
62
+
63
+ /** The keys that move focus along the bar and down into an open panel. */
64
+ const BAR_ITEMS = ".nav-links > a, .nav-links .nav-group-btn";
65
+ const PANEL_ITEMS = "a[href], button:not([disabled])";
66
+
67
+ /**
68
+ * A keyboard focus opens a group the way a hover does; a click focuses the
69
+ * control too, and that focus must not count. jsdom and older engines that
70
+ * cannot answer the question get the keyboard reading.
71
+ */
72
+ function isKeyboardFocus(element: Element): boolean {
73
+ try {
74
+ return element.matches(":focus-visible");
75
+ } catch {
76
+ return true;
77
+ }
78
+ }
79
+
80
+ /** The spoken name of a header number: its label, then the number. */
81
+ function phoneName(phone: HeaderPhone): string {
82
+ return phone.label ? `${phone.label} ${phone.display}` : phone.display;
35
83
  }
36
84
 
37
85
  /**
38
86
  * The fixed header every page wears: the lockup, the nav or the page's
39
- * stops, the CTA, and the burger that opens the menu. It takes the current
40
- * path as a prop rather than asking a router, so it runs under any of them.
87
+ * stops, the numbers, the CTA, and the burger that opens the menu. It takes
88
+ * the current path as a prop rather than asking a router, so it runs under
89
+ * any of them.
90
+ *
91
+ * A nav group opens its panel on a mouse hover or a keyboard focus, and a
92
+ * click on its control pins it open (a second click closes it). Escape, a
93
+ * click outside the header, the pointer leaving the header, and focus
94
+ * leaving the group close an unpinned panel; Escape, an outside click, and
95
+ * focus leaving the group close a pinned one too. Left and right arrows walk the bar, the down arrow
96
+ * steps into a panel, and up and down walk the panel's links. A closed panel
97
+ * stays in the HTML, `inert`, so its links are crawlable and out of the tab
98
+ * order.
41
99
  */
42
100
  export function SiteHeader({
43
101
  brand,
@@ -48,10 +106,18 @@ export function SiteHeader({
48
106
  stops,
49
107
  hideCTA = false,
50
108
  contact,
109
+ phones,
110
+ menuLabel,
51
111
  }: SiteHeaderProps) {
52
112
  const [scrolled, setScrolled] = useState(false);
53
113
  const [menuOpen, setMenuOpen] = useState(false);
54
- const menuId = useId();
114
+ // The open group's index, and whether a click pinned it open.
115
+ const [openGroup, setOpenGroup] = useState<number | null>(null);
116
+ const [pinned, setPinned] = useState(false);
117
+ const [focusPanel, setFocusPanel] = useState(false);
118
+ const headerRef = useRef<HTMLElement>(null);
119
+ const baseId = useId();
120
+ const menuId = `${baseId}menu`;
55
121
  const activeId = useScrollSpy(stops ? stops.map((stop) => stop.id) : []);
56
122
 
57
123
  useEffect(() => {
@@ -62,20 +128,89 @@ export function SiteHeader({
62
128
  return () => window.removeEventListener("scroll", onScroll);
63
129
  }, [variant]);
64
130
 
65
- const solid = variant !== "transparent" || scrolled;
131
+ const close = () => {
132
+ setOpenGroup(null);
133
+ setPinned(false);
134
+ };
135
+
136
+ // Escape and a click outside the header close whatever is open, pinned or
137
+ // not; Escape hands focus back to the group's control when it was inside.
138
+ useDismiss(openGroup !== null, headerRef, (reason) => {
139
+ if (reason === "escape" && headerRef.current?.contains(document.activeElement)) {
140
+ document.getElementById(`${baseId}g${openGroup}`)?.focus();
141
+ }
142
+ close();
143
+ });
144
+
145
+ // The down arrow opens a panel and moves into it once it is no longer inert.
146
+ useEffect(() => {
147
+ if (!focusPanel || openGroup === null) return;
148
+ setFocusPanel(false);
149
+ const panel = document.getElementById(`${baseId}p${openGroup}`);
150
+ panel?.querySelector<HTMLElement>(PANEL_ITEMS)?.focus();
151
+ }, [focusPanel, openGroup, baseId]);
152
+
153
+ const solid = variant !== "transparent" || scrolled || openGroup !== null;
66
154
  const menuLinks = stops
67
155
  ? stops.map((stop) => ({ label: stop.label, href: `#${stop.id}` }))
68
156
  : (links ?? []);
69
157
  const menuCTA = stops ? undefined : primaryCTA;
70
158
  const barCTA = hideCTA ? undefined : menuCTA;
71
159
  const hasMenu = menuLinks.length > 0 || menuCTA !== undefined;
160
+ const barPhones = stops ? [] : (phones ?? []).slice(0, 2);
161
+ const hasGroups = !stops && (links ?? []).some(isGroup);
162
+ // A bar holding groups or numbers needs more width before the burger steps aside.
163
+ const wide = hasGroups || barPhones.length > 0;
164
+
165
+ const isCurrent = (link: NavLink) =>
166
+ currentPath !== undefined &&
167
+ (link.href === currentPath || groupHrefs(link).includes(currentPath));
168
+
169
+ // One handler for the whole nav: left and right walk the bar's entries,
170
+ // up and down walk the links of the panel focus is in.
171
+ function onNavKeyDown(event: KeyboardEvent<HTMLElement>) {
172
+ const target = event.target as HTMLElement;
173
+ const panel = target.closest(".nav-mega");
174
+ const vertical = event.key === "ArrowDown" || event.key === "ArrowUp";
175
+ const horizontal = event.key === "ArrowLeft" || event.key === "ArrowRight";
176
+ if (!(panel ? vertical : horizontal)) return;
177
+ const scope = panel ?? event.currentTarget;
178
+ const items = Array.from(scope.querySelectorAll<HTMLElement>(panel ? PANEL_ITEMS : BAR_ITEMS));
179
+ const at = items.indexOf(target);
180
+ if (at === -1) return;
181
+ event.preventDefault();
182
+ const forward = event.key === "ArrowDown" || event.key === "ArrowRight";
183
+ const next = forward ? at + 1 : at - 1;
184
+ items[(next + items.length) % items.length]?.focus();
185
+ }
186
+
187
+ // Focus leaving the open group for anywhere else closes it. Focus lost to
188
+ // nothing is a click on the page, which the outside click closes.
189
+ function onNavBlur(event: FocusEvent<HTMLElement>) {
190
+ if (openGroup === null) return;
191
+ const next = event.relatedTarget as Node | null;
192
+ if (!next) return;
193
+ const item = document.getElementById(`${baseId}g${openGroup}`)?.closest(".nav-item");
194
+ if (item && !item.contains(next)) close();
195
+ }
196
+
197
+ function onHeaderLeave(event: PointerEvent<HTMLElement>) {
198
+ if (event.pointerType === "mouse" && !pinned) close();
199
+ }
72
200
 
73
201
  return (
74
202
  <>
75
203
  <header
76
- className={["nav", solid ? "is-solid" : "is-transparent", variant === "dark" && "nav-dark"]
204
+ ref={headerRef}
205
+ className={[
206
+ "nav",
207
+ solid ? "is-solid" : "is-transparent",
208
+ variant === "dark" && "nav-dark",
209
+ wide && "is-wide",
210
+ ]
77
211
  .filter(Boolean)
78
212
  .join(" ")}
213
+ onPointerLeave={onHeaderLeave}
79
214
  >
80
215
  <div className="nav-inner">
81
216
  <BrandLockup brand={brand} />
@@ -95,18 +230,97 @@ export function SiteHeader({
95
230
  )
96
231
  : links &&
97
232
  links.length > 0 && (
98
- <nav className="nav-links" aria-label="Primary">
99
- {links.map((link) => (
100
- <a
101
- key={link.href}
102
- href={link.href}
103
- aria-current={currentPath === link.href ? "page" : undefined}
104
- >
105
- {link.label}
106
- </a>
107
- ))}
233
+ <nav
234
+ className="nav-links"
235
+ aria-label="Primary"
236
+ onKeyDown={onNavKeyDown}
237
+ onBlur={onNavBlur}
238
+ >
239
+ {links.map((link, index) =>
240
+ isGroup(link) ? (
241
+ // biome-ignore lint/suspicious/noArrayIndexKey: a one page site points several entries at one page or anchor, so the place keeps the key unique; the bar never reorders
242
+ <div className="nav-item" key={index}>
243
+ <button
244
+ type="button"
245
+ id={`${baseId}g${index}`}
246
+ className={["nav-group-btn", isCurrent(link) && "is-current"]
247
+ .filter(Boolean)
248
+ .join(" ")}
249
+ aria-expanded={openGroup === index}
250
+ aria-controls={`${baseId}p${index}`}
251
+ onPointerEnter={(event) => {
252
+ if (event.pointerType !== "mouse") return;
253
+ if (openGroup !== index) {
254
+ setOpenGroup(index);
255
+ setPinned(false);
256
+ }
257
+ }}
258
+ onFocus={(event) => {
259
+ if (openGroup !== index && isKeyboardFocus(event.currentTarget)) {
260
+ setOpenGroup(index);
261
+ setPinned(false);
262
+ }
263
+ }}
264
+ onClick={() => {
265
+ if (openGroup === index && pinned) close();
266
+ else {
267
+ setOpenGroup(index);
268
+ setPinned(true);
269
+ }
270
+ }}
271
+ onKeyDown={(event) => {
272
+ if (event.key !== "ArrowDown") return;
273
+ event.preventDefault();
274
+ setOpenGroup(index);
275
+ setPinned(true);
276
+ setFocusPanel(true);
277
+ }}
278
+ >
279
+ {link.label}
280
+ <ChevronDown className="nav-chevron" size={16} aria-hidden="true" />
281
+ </button>
282
+ <NavMegaPanel
283
+ id={`${baseId}p${index}`}
284
+ group={link}
285
+ open={openGroup === index}
286
+ currentPath={currentPath}
287
+ onNavigate={close}
288
+ />
289
+ </div>
290
+ ) : (
291
+ <a
292
+ // biome-ignore lint/suspicious/noArrayIndexKey: as above, entries may share an href
293
+ key={index}
294
+ href={link.href}
295
+ aria-current={currentPath === link.href ? "page" : undefined}
296
+ onPointerEnter={(event) => {
297
+ if (event.pointerType === "mouse" && !pinned) close();
298
+ }}
299
+ >
300
+ {link.label}
301
+ </a>
302
+ ),
303
+ )}
108
304
  </nav>
109
305
  )}
306
+ {barPhones.length > 0 && (
307
+ <div className="nav-phones">
308
+ {barPhones.map((phone) => (
309
+ <a
310
+ key={phone.e164}
311
+ className="nav-phone"
312
+ href={`tel:${phone.e164}`}
313
+ aria-label={phoneName(phone)}
314
+ >
315
+ <PhoneIcon size={17} aria-hidden="true" />
316
+ <span className="nav-phone-text">
317
+ {phone.label && <span className="nav-phone-label">{phone.label}</span>}
318
+ <span className="nav-phone-number">{phone.display}</span>
319
+ </span>
320
+ </a>
321
+ ))}
322
+ </div>
323
+ )}
110
324
  {barCTA && (
111
325
  // The class sits on a wrapper, not the button: a site's own .btn
112
326
  // display rule lives outside the atelic-ui layer and would beat
@@ -118,21 +332,50 @@ export function SiteHeader({
118
332
  {...newTabProps(barCTA.href, barCTA.external)}
119
333
  >
120
334
  {barCTA.label}
335
+ {barCTA.arrow && (
336
+ <span className="arrow" aria-hidden="true">
337
+ →
338
+ </span>
339
+ )}
121
340
  </a>
122
341
  </span>
123
342
  )}
343
+ {barPhones[0] && (
344
+ <a
345
+ className="nav-call"
346
+ href={`tel:${barPhones[0].e164}`}
347
+ aria-label={phoneName(barPhones[0])}
348
+ >
349
+ <PhoneIcon size={19} aria-hidden="true" />
350
+ </a>
351
+ )}
124
352
  {hasMenu && (
125
353
  <button
126
354
  type="button"
127
- className="nav-burger"
128
- aria-label={menuOpen ? "Close menu" : "Open menu"}
355
+ className={menuLabel ? "nav-burger has-label" : "nav-burger"}
356
+ // Words beside the burger name it, so the name holds what a reader
357
+ // sees; the open state is aria-expanded's to say.
358
+ aria-label={menuLabel ? undefined : menuOpen ? "Close menu" : "Open menu"}
129
359
  aria-expanded={menuOpen}
130
360
  aria-controls={menuId}
131
361
  onClick={() => setMenuOpen((open) => !open)}
132
362
  >
133
- <span />
134
- <span />
135
- <span />
363
+ {menuLabel ? (
364
+ <>
365
+ <span className="nav-burger-label">{menuLabel}</span>
366
+ <span className="nav-burger-lines" aria-hidden="true">
367
+ <span />
368
+ <span />
369
+ <span />
370
+ </span>
371
+ </>
372
+ ) : (
373
+ <>
374
+ <span />
375
+ <span />
376
+ <span />
377
+ </>
378
+ )}
136
379
  </button>
137
380
  )}
138
381
  </div>
@@ -145,6 +388,8 @@ export function SiteHeader({
145
388
  links={menuLinks}
146
389
  primaryCTA={menuCTA}
147
390
  contact={stops ? undefined : contact}
391
+ phones={barPhones.length > 0 ? barPhones : undefined}
392
+ currentPath={currentPath}
148
393
  />
149
394
  )}
150
395
  </>
@@ -1,6 +1,17 @@
1
- import { useEffect, useRef } from "react";
1
+ import { ChevronDown } from "lucide-react";
2
+ import { useEffect, useId, useRef, useState } from "react";
2
3
  import { newTabProps } from "../lib/newTabProps";
3
- import type { CallToAction, MenuContact, NavLink } from "../types";
4
+ import { holdPhoneNumbers, isTel } from "../lib/phoneText";
5
+ import type {
6
+ CallToAction,
7
+ HeaderPhone,
8
+ MenuContact,
9
+ NavGroupChildLink,
10
+ NavLink,
11
+ NavPanelSection,
12
+ } from "../types";
13
+ import { NavBadge } from "./NavBadge";
14
+ import { isGroup, isLinkColumn, panelSections } from "./navSections";
4
15
 
5
16
  export interface SiteMenuProps {
6
17
  /** Whether the menu is showing. The owner holds this state. */
@@ -11,12 +22,22 @@ export interface SiteMenuProps {
11
22
  * the owner asked for, by passing `open={false}`, is not reported back.
12
23
  */
13
24
  onClose: () => void;
14
- /** The entries in order: a site's nav, or a page's own stops as `#id` links. */
25
+ /**
26
+ * The entries in order: a site's nav, or a page's own stops as `#id` links.
27
+ * An entry with `columns` is a group, an accordion that opens one at a time.
28
+ */
15
29
  links: NavLink[];
16
30
  /** The primary action, rendered as a standard button below the entries. */
17
31
  primaryCTA?: CallToAction;
18
32
  /** The phone, email, and address block at the foot. */
19
33
  contact?: MenuContact;
34
+ /**
35
+ * The numbers the header shows, each a tel link at the foot with its
36
+ * label, in place of the contact block's one phone.
37
+ */
38
+ phones?: HeaderPhone[];
39
+ /** The path being read, marking the matching link with aria-current. */
40
+ currentPath?: string;
20
41
  id?: string;
21
42
  /** The dialog's accessible name. Defaults to "Menu". */
22
43
  label?: string;
@@ -28,6 +49,12 @@ export interface SiteMenuProps {
28
49
  * return to the burger. The dialog renders closed on the server and opens
29
50
  * only in an effect, so the menu stays safe to prerender. Page scroll holds
30
51
  * still through chrome.css while the dialog is open.
52
+ *
53
+ * A group is an accordion: its label is a control that opens the group's
54
+ * columns under it and closes whichever group was open. Every group starts
55
+ * closed each time the menu opens, the one holding the current page
56
+ * included, so the menu always opens on the short list of entries. A closed
57
+ * group's links stay in the HTML, `inert`.
31
58
  */
32
59
  export function SiteMenu({
33
60
  open,
@@ -35,19 +62,30 @@ export function SiteMenu({
35
62
  links,
36
63
  primaryCTA,
37
64
  contact,
65
+ phones,
66
+ currentPath,
38
67
  id,
39
68
  label = "Menu",
40
69
  }: SiteMenuProps) {
70
+ const [openGroup, setOpenGroup] = useState<number | null>(null);
71
+ const groupId = useId();
41
72
  const dialogRef = useRef<HTMLDialogElement>(null);
42
73
  // Whether the owner already knows the menu is closed. Escape fires cancel
43
74
  // and then close, and a followed link closes the dialog and notifies
44
75
  // directly, so every path runs through reportClosed and reports once.
45
76
  const closedRef = useRef(true);
77
+ // Only a plain entry wears a number, so the numbers count those alone and
78
+ // run 01, 02, 03 down the menu whatever groups sit between them.
79
+ const numbers: number[] = [];
80
+ let counted = 0;
81
+ for (const link of links) numbers.push(isGroup(link) ? 0 : ++counted);
46
82
 
47
83
  useEffect(() => {
48
84
  const dialog = dialogRef.current;
49
85
  if (!dialog) return;
50
86
  closedRef.current = !open;
87
+ // No group is open when the menu opens, whatever page it opens on.
88
+ if (open) setOpenGroup(null);
51
89
  if (open && !dialog.open) dialog.showModal();
52
90
  if (!open && dialog.open) dialog.close();
53
91
  }, [open]);
@@ -80,12 +118,55 @@ export function SiteMenu({
80
118
  <span />
81
119
  <span />
82
120
  </button>
83
- {links.map((link, i) => (
84
- <a key={link.href} className="mm-link" href={link.href} onClick={close}>
85
- <span>{link.label}</span>
86
- <span className="idx">{String(i + 1).padStart(2, "0")}</span>
87
- </a>
88
- ))}
121
+ {links.map((link, i) =>
122
+ isGroup(link) ? (
123
+ // biome-ignore lint/suspicious/noArrayIndexKey: a one page site points several entries at one page or anchor, so the place keeps the key unique; the menu never reorders
124
+ <div className="mm-group" key={i}>
125
+ <button
126
+ type="button"
127
+ className="mm-link mm-group-btn"
128
+ aria-expanded={openGroup === i}
129
+ aria-controls={`${groupId}${i}`}
130
+ onClick={() => setOpenGroup((current) => (current === i ? null : i))}
131
+ >
132
+ <span>{link.label}</span>
133
+ <ChevronDown className="mm-chevron" size={22} aria-hidden="true" />
134
+ </button>
135
+ <div
136
+ id={`${groupId}${i}`}
137
+ className={["mm-group-panel", openGroup === i && "is-open"].filter(Boolean).join(" ")}
138
+ inert={openGroup !== i}
139
+ >
140
+ {link.allLabel && (
141
+ <a className="mm-group-all" href={link.href} onClick={close}>
142
+ {link.allLabel}
143
+ </a>
144
+ )}
145
+ {panelSections(link).map((section, index) => (
146
+ <MenuSection
147
+ // biome-ignore lint/suspicious/noArrayIndexKey: a group's sections never reorder while the menu is open
148
+ key={index}
149
+ section={section}
150
+ currentPath={currentPath}
151
+ onNavigate={close}
152
+ />
153
+ ))}
154
+ </div>
155
+ </div>
156
+ ) : (
157
+ <a
158
+ // biome-ignore lint/suspicious/noArrayIndexKey: as above, entries may share an href
159
+ key={i}
160
+ className="mm-link"
161
+ href={link.href}
162
+ onClick={close}
163
+ aria-current={currentPath === link.href ? "page" : undefined}
164
+ >
165
+ <span>{link.label}</span>
166
+ <span className="idx">{String(numbers[i]).padStart(2, "0")}</span>
167
+ </a>
168
+ ),
169
+ )}
89
170
  {primaryCTA && (
90
171
  <a
91
172
  className="btn btn-primary btn-lg mm-cta"
@@ -96,25 +177,125 @@ export function SiteMenu({
96
177
  {primaryCTA.label}
97
178
  </a>
98
179
  )}
99
- {contact && <ContactBlock contact={contact} />}
180
+ {(contact || phones) && <ContactBlock contact={contact ?? {}} phones={phones} />}
100
181
  </dialog>
101
182
  );
102
183
  }
103
184
 
104
- function ContactBlock({ contact: { phone, email, address } }: { contact: MenuContact }) {
185
+ /** A short word in a pill after a link's label, as on the desktop panel. */
186
+ function Badge({ text }: { text?: string }) {
187
+ return <NavBadge text={text} className="mm-badge" />;
188
+ }
189
+
190
+ /**
191
+ * One section of a group, as the phone draws it: a link column with its
192
+ * children indented under their parent, icon rows and cards as plain links
193
+ * of their labels and titles, and a picture as a plain link of its caption,
194
+ * so the page it leads to stays reachable without the photo.
195
+ */
196
+ function MenuSection({
197
+ section,
198
+ currentPath,
199
+ onNavigate,
200
+ }: {
201
+ section: NavPanelSection;
202
+ currentPath?: string;
203
+ onNavigate: () => void;
204
+ }) {
205
+ // A child may share its parent's href, and two rows may share one, so a
206
+ // link is keyed by its place, never its href alone.
207
+ const link = (
208
+ item: { label: string; href: string; external?: boolean; badge?: string },
209
+ className: string,
210
+ key: string,
211
+ ) => (
212
+ <a
213
+ key={key}
214
+ className={className}
215
+ href={item.href}
216
+ onClick={onNavigate}
217
+ aria-current={currentPath === item.href ? "page" : undefined}
218
+ {...newTabProps(item.href, item.external)}
219
+ >
220
+ {isTel(item.href) ? holdPhoneNumbers(item.label) : item.label}
221
+ <Badge text={item.badge} />
222
+ </a>
223
+ );
224
+ const heading = section.kind === "picture" ? undefined : section.heading;
225
+ const headHref = isLinkColumn(section) ? section.href : undefined;
226
+ if (section.kind === "picture") {
227
+ return (
228
+ <div className="mm-group-col">
229
+ {link(
230
+ { label: section.caption, href: section.href, external: section.external },
231
+ "mm-group-link",
232
+ "picture",
233
+ )}
234
+ </div>
235
+ );
236
+ }
237
+ return (
238
+ <div className="mm-group-col">
239
+ {heading &&
240
+ (headHref ? (
241
+ <a className="mm-group-head" href={headHref} onClick={onNavigate}>
242
+ {heading}
243
+ </a>
244
+ ) : (
245
+ <p className="mm-group-head">{heading}</p>
246
+ ))}
247
+ {isLinkColumn(section)
248
+ ? section.links.map((item, index) => (
249
+ // biome-ignore lint/suspicious/noArrayIndexKey: two links may share an href, so the place keeps the key unique; a group's links never reorder
250
+ <div className="mm-group-item" key={`${index} ${item.href}`}>
251
+ {link(item, "mm-group-link", "self")}
252
+ {item.children?.map((child: NavGroupChildLink, childIndex) =>
253
+ link(child, "mm-group-sub", `child ${childIndex}`),
254
+ )}
255
+ </div>
256
+ ))
257
+ : section.kind === "rows"
258
+ ? section.rows.map((row, index) => link(row, "mm-group-link", `row ${index}`))
259
+ : section.cards.map((card, index) =>
260
+ link(
261
+ { label: card.title, href: card.href, external: card.external },
262
+ "mm-group-link",
263
+ `card ${index}`,
264
+ ),
265
+ )}
266
+ </div>
267
+ );
268
+ }
269
+
270
+ function ContactBlock({
271
+ contact: { phone, email, address },
272
+ phones,
273
+ }: {
274
+ contact: MenuContact;
275
+ phones?: HeaderPhone[];
276
+ }) {
105
277
  return (
106
278
  <div className="mm-contact">
107
279
  {/* The number and the address are the two things a phone can act on, so
108
280
  each is a real link: a tel link dials, a mailto opens mail. Protocol
109
281
  links never open a new tab (rule 12). Plain text here read as friction. */}
110
- {phone && (
111
- <>
112
- <a className="mm-contact-link" href={`tel:${phone.e164}`}>
113
- CALL / TEXT&nbsp;&nbsp;{phone.display}
114
- </a>
115
- <br />
116
- </>
117
- )}
282
+ {phones
283
+ ? phones.map((line) => (
284
+ <span key={line.e164}>
285
+ <a className="mm-contact-link" href={`tel:${line.e164}`}>
286
+ {line.label ? line.label.toUpperCase() : "CALL / TEXT"}&nbsp;&nbsp;{line.display}
287
+ </a>
288
+ <br />
289
+ </span>
290
+ ))
291
+ : phone && (
292
+ <>
293
+ <a className="mm-contact-link" href={`tel:${phone.e164}`}>
294
+ CALL / TEXT&nbsp;&nbsp;{phone.display}
295
+ </a>
296
+ <br />
297
+ </>
298
+ )}
118
299
  {email && (
119
300
  <>
120
301
  <a className="mm-contact-link" href={`mailto:${email}`}>