@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,13 +1,16 @@
1
- import type { ReactNode } from "react";
1
+ import { type ReactNode, useCallback, useRef } from "react";
2
2
  import { Watermark } from "../components/Watermark";
3
3
  import type { PageStop } from "../hooks/useScrollSpy";
4
+ import { formatHoursRange } from "../lib/hours";
4
5
  import { BasePathProvider } from "../routing/BasePathProvider";
5
6
  import { joinBase, normalizeBasePath, stripBase } from "../routing/basePath";
6
- import type { NavItem, SiteConfig } from "../sections/siteConfig";
7
- import type { FooterColumn } from "../types";
7
+ import type { Density, NavItem, SiteConfig } from "../sections/siteConfig";
8
+ import type { FooterColumn, NavLink, NavPanelSection } from "../types";
8
9
  import { ClosingBar } from "./ClosingBar";
10
+ import { ContactDock } from "./ContactDock";
9
11
  import { Copyright } from "./Copyright";
10
12
  import { Footer } from "./Footer";
13
+ import { isKnownSection, isLinkColumn } from "./navSections";
11
14
  import { SiteHeader, type SiteHeaderVariant } from "./SiteHeader";
12
15
  import { SkipLink } from "./SkipLink";
13
16
  import { StickyCTABar } from "./StickyCTABar";
@@ -57,6 +60,17 @@ export interface SiteShellProps {
57
60
  * side empty unless the site gives a note. The copyright prints either way.
58
61
  */
59
62
  credit?: boolean;
63
+ /**
64
+ * The section spacing, set on the `.atelic-ui` root as `data-density`.
65
+ * Defaults to `site.density`, then `default`; `comfortable` is the roomier
66
+ * spacing sites had before 8.0.0, close to it though not to the pixel.
67
+ */
68
+ density?: Density;
69
+ /**
70
+ * Mounts the contact dock when the config supplies `contactDock`.
71
+ * Defaults on; a page that closes on its own ask turns it off.
72
+ */
73
+ contactDock?: boolean;
60
74
  children: ReactNode;
61
75
  }
62
76
 
@@ -79,23 +93,104 @@ export function SiteShell({
79
93
  navOnDark = false,
80
94
  hideNavCTA = false,
81
95
  credit = true,
96
+ density,
97
+ contactDock = true,
82
98
  children,
83
99
  }: SiteShellProps) {
84
100
  const base = normalizeBasePath(basePath ?? site.basePath);
85
- const withBase = (path: string) => joinBase(base, path);
86
101
  // Every href and src handed to the chrome carries the base path (a no op at
87
- // the root). The current path is compared against those hrefs, so it is
88
- // put in the same form whether or not the router reports it with the base.
102
+ // the root), through these helpers alone: a path, a path that may be
103
+ // absent, and a list or a picture whose own path takes it. The current path
104
+ // is compared against those hrefs, so it is put in the same form whether
105
+ // or not the router reports it with the base.
106
+ const withBase = (path: string) => joinBase(base, path);
107
+ const maybeBase = <T extends string | undefined>(path: T): T =>
108
+ (path === undefined ? path : withBase(path)) as T;
109
+ const based = <T extends { href: string }>(items: T[] | undefined) =>
110
+ items?.map((item) => ({ ...item, href: withBase(item.href) }));
111
+ function image<T extends { src: string }>(picture: T): T;
112
+ function image<T extends { src: string }>(picture: T | undefined): T | undefined;
113
+ function image<T extends { src: string }>(picture: T | undefined) {
114
+ return picture && { ...picture, src: withBase(picture.src) };
115
+ }
89
116
  const pathname = withBase(stripBase(base, currentPath));
90
117
  const brand = {
91
118
  name: site.name,
92
119
  href: withBase("/"),
93
- logo: { ...site.logo, src: site.logo.src === undefined ? undefined : withBase(site.logo.src) },
120
+ logo: {
121
+ ...site.logo,
122
+ src: maybeBase(site.logo.src),
123
+ onLight: maybeBase(site.logo.onLight),
124
+ onDark: maybeBase(site.logo.onDark),
125
+ },
94
126
  };
95
- const links = (nav ?? site.nav).map((item) => ({ label: item.label, href: withBase(item.to) }));
127
+ // The contact dock rides above the shell's own footer, or the closing bar
128
+ // standing in for it, held by ref rather than found by a selector.
129
+ const footerRef = useRef<HTMLElement>(null);
130
+ const closingRef = useRef<HTMLDivElement>(null);
131
+ // The room the phone's sticky bar takes while it shows, which the closing
132
+ // bar pads its foot by. The bar reports it and the shell writes it straight
133
+ // onto its root as --sticky-cta-space, outside React's render, so a change
134
+ // in the bar's height never renders the whole shell again. The root's style
135
+ // is never a prop, so no render of the shell clears what this sets.
136
+ const rootRef = useRef<HTMLDivElement>(null);
137
+ const setBarSpace = useCallback((pixels: number) => {
138
+ const root = rootRef.current;
139
+ if (!root) return;
140
+ if (pixels > 0) root.style.setProperty("--sticky-cta-space", `${pixels}px`);
141
+ else root.style.removeProperty("--sticky-cta-space");
142
+ }, []);
96
143
  const cta = { ...site.cta, href: withBase(site.cta.href) };
97
- const based = <T extends { href: string }>(items: T[] | undefined) =>
98
- items?.map((item) => ({ ...item, href: withBase(item.href) }));
144
+ // The phone's sticky bar may carry its own words (`cta.stickyLabel`).
145
+ const stickyLink = { ...cta, label: site.cta.stickyLabel ?? cta.label };
146
+ // Every link and picture a panel section holds, based.
147
+ const section = (part: NavPanelSection): NavPanelSection => {
148
+ if (isLinkColumn(part)) {
149
+ return {
150
+ ...part,
151
+ href: maybeBase(part.href),
152
+ links: part.links.map((link) => ({
153
+ ...link,
154
+ href: withBase(link.href),
155
+ children: based(link.children),
156
+ })),
157
+ };
158
+ }
159
+ if (part.kind === "picture") {
160
+ return {
161
+ ...part,
162
+ href: withBase(part.href),
163
+ image: image(part.image),
164
+ };
165
+ }
166
+ if (part.kind === "rows") return { ...part, rows: based(part.rows) ?? [] };
167
+ return {
168
+ ...part,
169
+ cards: part.cards.map((card) => ({
170
+ ...card,
171
+ href: withBase(card.href),
172
+ image: image(card.image),
173
+ })),
174
+ };
175
+ };
176
+ // A group carries its sections and its card into the header, every link based.
177
+ const headerLinks: NavLink[] = (nav ?? site.nav).map((item) => ({
178
+ label: item.label,
179
+ href: withBase(item.to),
180
+ allLabel: item.allLabel,
181
+ // A section of a kind this version does not know is dropped here, before
182
+ // the mapping below would read fields it does not have.
183
+ columns: item.columns?.filter(isKnownSection).map(section),
184
+ feature: item.feature && {
185
+ ...item.feature,
186
+ cta: { ...item.feature.cta, href: withBase(item.feature.cta.href) },
187
+ image: image(item.feature.image),
188
+ },
189
+ }));
190
+ // The footer's Company column lists the entries themselves, never a group's links.
191
+ const links = headerLinks.map(({ label, href }) => ({ label, href }));
192
+ const setting = density ?? site.density;
193
+ const dock = contactDock ? site.contactDock : undefined;
99
194
  // The default footer's four columns, drawn from what the config already
100
195
  // holds; a site that wants other columns names them in `footer.columns`.
101
196
  const footerColumns: FooterColumn[] = site.footer?.columns?.map((column) => ({
@@ -110,6 +205,19 @@ export function SiteShell({
110
205
  },
111
206
  { heading: "Legal", links: based(site.legalLinks) ?? [] },
112
207
  ];
208
+ // The footer's hours, formatted as the footer prints them, unless the site
209
+ // keeps them out; the config's hours still feed its structured data.
210
+ const footerHours =
211
+ site.footer?.showHours === false
212
+ ? undefined
213
+ : site.hours?.map((row) => ({
214
+ label: row.labelShort,
215
+ range: formatHoursRange(row, { short: true, clock: site.clock }),
216
+ }));
217
+ // The rating links to the Google profile: the site's own link for it, else
218
+ // the profile the address already links to.
219
+ const rating = site.footer?.rating;
220
+ const ratingHref = rating ? (site.footer?.ratingHref ?? site.mapLinkURL) : undefined;
113
221
  // The header takes one variant. A hero page wins over a dark one: the bar
114
222
  // sits transparent over the hero either way, and only its scrolled state
115
223
  // differed.
@@ -117,43 +225,72 @@ export function SiteShell({
117
225
 
118
226
  return (
119
227
  <BasePathProvider base={base}>
120
- <div className="atelic-ui">
228
+ <div
229
+ ref={rootRef}
230
+ className="atelic-ui"
231
+ data-density={setting && setting !== "default" ? setting : undefined}
232
+ >
121
233
  <SkipLink />
122
234
  <SiteHeader
123
235
  brand={brand}
124
- links={links}
236
+ links={headerLinks}
125
237
  primaryCTA={cta}
126
238
  variant={variant}
127
239
  currentPath={pathname}
128
240
  stops={pageNav}
129
241
  hideCTA={hideNavCTA}
130
242
  contact={{ phone: site.phone, email: site.email, address: site.address }}
243
+ phones={site.header?.phones}
244
+ menuLabel={site.menuLabel}
131
245
  />
132
246
  <main id="main" className={heroNav ? undefined : "clears-nav"}>
133
247
  {children}
134
248
  </main>
135
249
  {/* An interior page's first screen has no booking button of its own, so
136
250
  the bar is there from the top; the hero home page keeps the slide in. */}
137
- {stickyCTA && <StickyCTABar primaryCTA={cta} phone={site.phone} fromTop={!heroNav} />}
251
+ {stickyCTA && (
252
+ <StickyCTABar
253
+ primaryCTA={stickyLink}
254
+ phone={site.phone}
255
+ fromTop={!heroNav}
256
+ onSpaceChange={setBarSpace}
257
+ />
258
+ )}
138
259
  {footer ? (
139
260
  <Footer
140
261
  brand={brand}
141
- rating={site.footer?.rating}
262
+ rating={rating}
263
+ ratingHref={ratingHref}
264
+ ratingLabel={site.footer?.ratingLabel}
142
265
  address={site.footer?.showAddress === false ? undefined : site.address}
143
266
  addressHref={site.mapLinkURL}
144
267
  phone={site.phone}
145
268
  email={site.email}
269
+ hours={footerHours}
146
270
  columns={footerColumns}
147
271
  attribution={site.attribution}
148
272
  note={site.footer?.note}
149
273
  credit={credit}
274
+ ref={footerRef}
150
275
  />
151
276
  ) : (
152
277
  <ClosingBar
278
+ ref={closingRef}
153
279
  left={<Copyright name={brand.name} attribution={site.attribution} />}
154
280
  right={site.footer?.note ?? (credit ? undefined : null)}
155
281
  />
156
282
  )}
283
+ {dock && (
284
+ <ContactDock
285
+ {...dock}
286
+ // The shell's own footer, or the closing bar standing in for it, never
287
+ // a footer element some section on the page holds.
288
+ avoid={footer ? footerRef : closingRef}
289
+ items={dock.items.map((item) =>
290
+ item.href === undefined ? item : { ...item, href: withBase(item.href) },
291
+ )}
292
+ />
293
+ )}
157
294
  <Watermark />
158
295
  </div>
159
296
  </BasePathProvider>
@@ -1,5 +1,5 @@
1
1
  import { Phone as PhoneIcon } from "lucide-react";
2
- import { useEffect, useState } from "react";
2
+ import { useEffect, useRef, useState } from "react";
3
3
  import { newTabProps } from "../lib/newTabProps";
4
4
  import type { CallToAction, Phone } from "../types";
5
5
 
@@ -20,6 +20,14 @@ export interface StickyCTABarProps {
20
20
  fromTop?: boolean;
21
21
  /** The call shortcut's accessible name. Defaults to "Call us". */
22
22
  callLabel?: string;
23
+ /**
24
+ * Hears the room the bar takes at the foot of the screen, in pixels: its
25
+ * measured height while it shows, and 0 while it is hidden (scrolled
26
+ * above its threshold, or on a desktop, where the stylesheet hides it).
27
+ * `SiteShell` pads the page's closing bar by it, so the copyright and the
28
+ * credit are never under the bar.
29
+ */
30
+ onSpaceChange?: (pixels: number) => void;
23
31
  }
24
32
 
25
33
  /** The phone only bottom bar: the primary CTA and a call shortcut, sliding in once scrolled, or there from the top. */
@@ -29,8 +37,16 @@ export function StickyCTABar({
29
37
  threshold = 520,
30
38
  fromTop = false,
31
39
  callLabel = "Call us",
40
+ onSpaceChange,
32
41
  }: StickyCTABarProps) {
33
42
  const [show, setShow] = useState(fromTop);
43
+ const barRef = useRef<HTMLDivElement>(null);
44
+ // The latest listener, so a caller passing a new function each render
45
+ // never restarts the measuring below. Whether there is one at all does:
46
+ // a listener supplied after mount starts the measuring then.
47
+ const spaceRef = useRef(onSpaceChange);
48
+ spaceRef.current = onSpaceChange;
49
+ const listening = onSpaceChange !== undefined;
34
50
 
35
51
  useEffect(() => {
36
52
  if (fromTop) {
@@ -43,9 +59,51 @@ export function StickyCTABar({
43
59
  return () => window.removeEventListener("scroll", onScroll);
44
60
  }, [threshold, fromTop]);
45
61
 
62
+ // The bar's real height while it shows, measured again whenever it changes
63
+ // size (a phone turned, a font loading, a label wrapping), never assumed.
64
+ // Hidden by the stylesheet its height reads 0, so a desktop reserves nothing.
65
+ useEffect(() => {
66
+ const bar = barRef.current;
67
+ if (!bar || !listening) return;
68
+ let last = -1;
69
+ // The listener last told a height: the one holding the space, which
70
+ // the cleanup hands back. Never the caller's latest, which after a
71
+ // swap is a listener that was never told anything.
72
+ let heard: ((pixels: number) => void) | undefined;
73
+ const report = () => {
74
+ const next = show ? bar.offsetHeight : 0;
75
+ const listener = spaceRef.current;
76
+ if (next === last && listener === heard) return;
77
+ // A caller swapped listeners since the last report: the old one
78
+ // gives its space back before the new one is told the height.
79
+ if (heard && heard !== listener) heard(0);
80
+ last = next;
81
+ heard = listener;
82
+ heard?.(next);
83
+ };
84
+ report();
85
+ const sizes = typeof ResizeObserver === "undefined" ? undefined : new ResizeObserver(report);
86
+ sizes?.observe(bar);
87
+ window.addEventListener("resize", report);
88
+ return () => {
89
+ sizes?.disconnect();
90
+ window.removeEventListener("resize", report);
91
+ // A final 0 on unmount, on hiding, and when the listener goes, to the
92
+ // listener that holds the space, so no foot padding outlives the bar.
93
+ heard?.(0);
94
+ };
95
+ }, [show, listening]);
96
+
46
97
  return (
47
98
  // Inert while offscreen, so its links take no keyboard focus before it slides in.
48
- <div className={show ? "sticky-cta show" : "sticky-cta"} inert={!show}>
99
+ // data-dock-lift and data-showing tell the contact dock to ride above it.
100
+ <div
101
+ ref={barRef}
102
+ className={show ? "sticky-cta show" : "sticky-cta"}
103
+ inert={!show}
104
+ data-dock-lift=""
105
+ data-showing={show ? "true" : "false"}
106
+ >
49
107
  <a
50
108
  className="btn btn-primary"
51
109
  href={primaryCTA.href}
@@ -0,0 +1,56 @@
1
+ import type { BrandLogo } from "../types";
2
+
3
+ /**
4
+ * The two grounds a mark is drawn on: `light` is the solid light bar, and
5
+ * `dark` is everything else the chrome puts a mark on (the dark bar, the
6
+ * transparent bar over a hero, and the footer band).
7
+ */
8
+ export type MarkSurface = "light" | "dark";
9
+
10
+ /**
11
+ * A mark as one surface draws it: the image, and the silhouette it is
12
+ * flattened to when the image was cut for the other ground. `ink` flattens
13
+ * it dark for a light ground, `light` flattens it white for a dark ground,
14
+ * and `null` draws the artwork as given.
15
+ */
16
+ export interface ResolvedMark {
17
+ src: string;
18
+ tint: "ink" | "light" | null;
19
+ }
20
+
21
+ /**
22
+ * Which image a surface draws, and how, by one order the header and the
23
+ * footer share.
24
+ *
25
+ * - A cut made for the surface (`onLight` on light, `onDark` on dark) is drawn
26
+ * as given, never recolored.
27
+ * - Failing that, `src`, the single light mark sites have always passed: drawn
28
+ * as given on a dark ground and flattened to ink on a light one.
29
+ * - Failing that, the cut made for the other ground, flattened to the
30
+ * surface's silhouette, since drawn as given it would vanish (a light only
31
+ * mark on the light bar, an ink only mark on the footer).
32
+ *
33
+ * Null when the logo carries no image at all.
34
+ */
35
+ export function resolveMark(
36
+ logo: BrandLogo | undefined,
37
+ surface: MarkSurface,
38
+ ): ResolvedMark | null {
39
+ if (!logo) return null;
40
+ const own = surface === "light" ? logo.onLight : logo.onDark;
41
+ if (own) return { src: own, tint: null };
42
+ if (logo.src) return { src: logo.src, tint: surface === "light" ? "ink" : null };
43
+ const other = surface === "light" ? logo.onDark : logo.onLight;
44
+ if (other) return { src: other, tint: surface === "light" ? "ink" : "light" };
45
+ return null;
46
+ }
47
+
48
+ /** Whether the logo draws a mark of any kind: a glyph tile or an image. */
49
+ export function hasMark(logo: BrandLogo | undefined): boolean {
50
+ return Boolean(logo?.tile || logo?.src || logo?.onLight || logo?.onDark);
51
+ }
52
+
53
+ /** The class a resolved mark's silhouette wears, or none for artwork drawn as given. */
54
+ export function tintClass(mark: ResolvedMark): string | undefined {
55
+ return mark.tint === "ink" ? "is-tinted" : mark.tint === "light" ? "is-tinted-light" : undefined;
56
+ }
@@ -0,0 +1,58 @@
1
+ import {
2
+ Calculator,
3
+ CalendarDays,
4
+ CircleHelp,
5
+ CirclePlay,
6
+ ClipboardList,
7
+ CreditCard,
8
+ FileText,
9
+ House,
10
+ type LucideIcon,
11
+ Mail,
12
+ Map as MapIcon,
13
+ MapPin,
14
+ MessageCircle,
15
+ Phone,
16
+ Shield,
17
+ Star,
18
+ Truck,
19
+ Users,
20
+ Wrench,
21
+ } from "lucide-react";
22
+ import type { ContactDockIcon, NavIcon } from "../types";
23
+
24
+ /** The lucide icon each name in `NavIcon` draws, in a mega menu panel's icon rows. */
25
+ export const navIcons: Record<NavIcon, LucideIcon> = {
26
+ calculator: Calculator,
27
+ calendar: CalendarDays,
28
+ card: CreditCard,
29
+ chat: MessageCircle,
30
+ document: FileText,
31
+ help: CircleHelp,
32
+ home: House,
33
+ mail: Mail,
34
+ map: MapIcon,
35
+ phone: Phone,
36
+ pin: MapPin,
37
+ play: CirclePlay,
38
+ shield: Shield,
39
+ star: Star,
40
+ tool: Wrench,
41
+ truck: Truck,
42
+ users: Users,
43
+ };
44
+
45
+ /**
46
+ * The icon each name in `ContactDockIcon` draws, the same glyphs as the
47
+ * panel's where the names meet. The dock's `map` is the pin, since a dock
48
+ * item leads to a place, and its `form` is the clipboard.
49
+ */
50
+ export const dockIcons: Record<ContactDockIcon, LucideIcon> = {
51
+ chat: navIcons.chat,
52
+ phone: navIcons.phone,
53
+ calendar: navIcons.calendar,
54
+ mail: navIcons.mail,
55
+ form: ClipboardList,
56
+ calculator: navIcons.calculator,
57
+ map: navIcons.pin,
58
+ };
@@ -4,12 +4,27 @@ export type {
4
4
  Brand,
5
5
  BrandLogo,
6
6
  CallToAction,
7
+ ContactDockConfig,
8
+ ContactDockIcon,
9
+ ContactDockItem,
7
10
  FooterColumn,
8
11
  FooterColumnLink,
9
12
  FooterIcon,
13
+ HeaderPhone,
10
14
  HoursRow,
11
15
  MenuContact,
16
+ NavCard,
17
+ NavCardsSection,
18
+ NavFeature,
19
+ NavGroupChildLink,
20
+ NavGroupColumn,
21
+ NavGroupLink,
22
+ NavIcon,
23
+ NavIconRow,
24
+ NavIconRowsSection,
12
25
  NavLink,
26
+ NavPanelSection,
27
+ NavPictureSection,
13
28
  Phone,
14
29
  PostalAddress,
15
30
  SiteLink,
@@ -17,6 +32,7 @@ export type {
17
32
  } from "../types";
18
33
  export { BrandLockup, type BrandLockupProps } from "./BrandLockup";
19
34
  export { ClosingBar, type ClosingBarProps } from "./ClosingBar";
35
+ export { ContactDock, type ContactDockProps } from "./ContactDock";
20
36
  export { Copyright, type CopyrightProps } from "./Copyright";
21
37
  export { Credit } from "./Credit";
22
38
  export { Footer, type FooterProps } from "./Footer";
@@ -0,0 +1,55 @@
1
+ import type { NavGroupColumn, NavLink, NavPanelSection } from "../types";
2
+
3
+ /** Whether a panel section is a link column, the kind a section is when it names none. */
4
+ export function isLinkColumn(section: NavPanelSection): section is NavGroupColumn {
5
+ return section.kind === undefined || section.kind === "links";
6
+ }
7
+
8
+ const KNOWN_KINDS: ReadonlySet<string | undefined> = new Set([
9
+ undefined,
10
+ "links",
11
+ "picture",
12
+ "rows",
13
+ "cards",
14
+ ]);
15
+
16
+ /**
17
+ * Whether the chrome knows how to draw a section. A config written against a
18
+ * later version (or a typo the types never saw, from JSON) can name a kind
19
+ * this one lacks; that section is left out rather than drawn as the wrong
20
+ * kind, which would read fields it does not have.
21
+ */
22
+ export function isKnownSection(section: NavPanelSection): boolean {
23
+ return (
24
+ typeof section === "object" &&
25
+ section !== null &&
26
+ KNOWN_KINDS.has((section as { kind?: string }).kind)
27
+ );
28
+ }
29
+
30
+ /** A group's sections that the chrome can draw, in order. */
31
+ export function panelSections(link: NavLink): NavPanelSection[] {
32
+ return (link.columns ?? []).filter(isKnownSection);
33
+ }
34
+
35
+ /** Whether an entry is a group: it holds at least one section the chrome can draw. */
36
+ export function isGroup(link: NavLink): boolean {
37
+ return panelSections(link).length > 0;
38
+ }
39
+
40
+ /** Every href a group's panel holds, its column headings, links, and their children included. */
41
+ export function groupHrefs(group: NavLink): string[] {
42
+ const hrefs: string[] = [];
43
+ for (const section of panelSections(group)) {
44
+ if (isLinkColumn(section)) {
45
+ if (section.href) hrefs.push(section.href);
46
+ for (const link of section.links) {
47
+ hrefs.push(link.href);
48
+ for (const child of link.children ?? []) hrefs.push(child.href);
49
+ }
50
+ } else if (section.kind === "picture") hrefs.push(section.href);
51
+ else if (section.kind === "rows") for (const row of section.rows) hrefs.push(row.href);
52
+ else for (const card of section.cards) hrefs.push(card.href);
53
+ }
54
+ return hrefs;
55
+ }
@@ -26,6 +26,8 @@ export interface ColumnChartProps {
26
26
  legend?: Array<{ label: string; tone: Tone }>;
27
27
  /** The tallest a bar draws, in pixels. */
28
28
  height?: number;
29
+ /** What the chart says, shown and spoken, when it has no bars; defaults to "No data to show". */
30
+ emptyLabel?: string;
29
31
  className?: string;
30
32
  }
31
33
 
@@ -34,18 +36,41 @@ export interface ColumnChartProps {
34
36
  * their own label and total, so a reader compares a quarter with the one
35
37
  * before it and with the same quarter a year earlier in one picture.
36
38
  */
37
- export function ColumnChart({ groups, legend, height = 120, className }: ColumnChartProps) {
39
+ export function ColumnChart({
40
+ groups,
41
+ legend,
42
+ height = 120,
43
+ emptyLabel = "No data to show",
44
+ className,
45
+ }: ColumnChartProps) {
38
46
  const all = groups.flatMap((group) => group.bars);
39
47
  const max = Math.max(...all.map((bar) => bar.value), 1);
40
48
  const figure = (bar: ColumnChartBar) => bar.display ?? bar.value.toLocaleString("en-US");
49
+ // A bar marked apart from its group is told by its tone; the legend's
50
+ // words for that tone go into the picture's name, so the mark is never
51
+ // carried by color alone. A group's tone is named by the group's label.
52
+ const meaning = (tone: Tone) => legend?.find((entry) => entry.tone === tone)?.label;
53
+ const describe = (bar: ColumnChartBar, group: ColumnChartGroup) => {
54
+ const marked = bar.tone && bar.tone !== group.tone ? meaning(bar.tone) : undefined;
55
+ return `${bar.label} ${bar.value.toLocaleString("en-US")}${marked ? ` (${marked})` : ""}`;
56
+ };
41
57
  const summary = groups
42
58
  .map(
43
59
  (group) =>
44
60
  `${group.label ? `${group.label}${group.total ? `, ${group.total}` : ""}: ` : ""}${group.bars
45
- .map((bar) => `${bar.label} ${bar.value.toLocaleString("en-US")}`)
61
+ .map((bar) => describe(bar, group))
46
62
  .join(", ")}`,
47
63
  )
48
64
  .join("; ");
65
+ if (all.length === 0) {
66
+ return (
67
+ <div className={["column-chart", "is-empty", className].filter(Boolean).join(" ")}>
68
+ <div className="column-chart-plot" role="img" aria-label={emptyLabel}>
69
+ <p className="column-chart-empty">{emptyLabel}</p>
70
+ </div>
71
+ </div>
72
+ );
73
+ }
49
74
  return (
50
75
  <div className={["column-chart", className].filter(Boolean).join(" ")}>
51
76
  <div className="column-chart-plot" role="img" aria-label={summary}>