@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.
- package/README.md +439 -132
- package/bin/atelic-check-sentry.ts +5 -0
- package/dist/gate/middleware.js +15 -1
- package/dist/monitoring/server.d.ts +72 -0
- package/dist/monitoring/server.js +201 -0
- package/dist/vite/index.d.ts +1 -1
- package/dist/vite/index.js +1 -1
- package/dist/vite/marketing-config.d.ts +28 -1
- package/dist/vite/marketing-config.js +62 -0
- package/package.json +23 -11
- package/src/app/ErrorFallback.tsx +6 -2
- package/src/app/context/AppContext.tsx +10 -1
- package/src/app/index.ts +0 -1
- package/src/app/layout/AppPage.tsx +36 -7
- package/src/app/layout/DesktopRail.tsx +15 -6
- package/src/app/layout/MobileMenu.tsx +14 -5
- package/src/app/layout/MobileTabBar.tsx +3 -2
- package/src/app/layout/PageError.tsx +7 -4
- package/src/app/layout/PageSkeleton.tsx +33 -26
- package/src/app/layout/SectionCards.tsx +7 -2
- package/src/app/layout/UserMenu.tsx +13 -7
- package/src/app/ui/alert.tsx +42 -12
- package/src/app/ui/badge.tsx +1 -1
- package/src/app/ui/button.tsx +2 -1
- package/src/app/ui/command.tsx +86 -21
- package/src/app/ui/country-dropdown.tsx +26 -47
- package/src/app/ui/form.tsx +48 -9
- package/src/app/ui/pagination.tsx +1 -1
- package/src/app/ui/progress.tsx +26 -12
- package/src/app/ui/search-input.tsx +16 -3
- package/src/app/ui/select.tsx +8 -3
- package/src/app/ui/slider.tsx +62 -15
- package/src/artifact/AppErrorBoundary.tsx +12 -7
- package/src/artifact/ArtifactShell.tsx +5 -1
- package/src/artifact/ErrorFallback.tsx +8 -1
- package/src/artifact/artifactConfig.ts +1 -1
- package/src/chrome/BrandLockup.tsx +102 -17
- package/src/chrome/ClosingBar.tsx +5 -3
- package/src/chrome/ContactDock.tsx +361 -0
- package/src/chrome/Footer.tsx +126 -31
- package/src/chrome/NavBadge.tsx +8 -0
- package/src/chrome/NavMegaPanel.tsx +399 -0
- package/src/chrome/SiteHeader.tsx +268 -23
- package/src/chrome/SiteMenu.tsx +200 -19
- package/src/chrome/SiteShell.tsx +151 -14
- package/src/chrome/StickyCTABar.tsx +60 -2
- package/src/chrome/brandMark.ts +56 -0
- package/src/chrome/icons.ts +58 -0
- package/src/chrome/index.ts +16 -0
- package/src/chrome/navSections.ts +55 -0
- package/src/components/ColumnChart.tsx +27 -2
- package/src/components/DataTable.tsx +104 -85
- package/src/components/Disclosure.tsx +3 -1
- package/src/components/Hint.tsx +3 -24
- package/src/components/NotFound.tsx +7 -3
- package/src/components/StarRating.tsx +45 -19
- package/src/components/ThresholdScale.tsx +36 -26
- package/src/email/atoms.tsx +13 -57
- package/src/email/frame.tsx +4 -6
- package/src/email/index.ts +4 -10
- package/src/email/scoreboard.tsx +107 -186
- package/src/email/text.ts +30 -0
- package/src/email/theme.tsx +76 -9
- package/src/gate/middleware.ts +15 -1
- package/src/hooks/useDismiss.ts +39 -0
- package/src/lib/emailText.tsx +26 -0
- package/src/lib/phoneText.tsx +40 -0
- package/src/lib/useScrollsSideways.ts +26 -0
- package/src/monitoring/ErrorCatcherScript.tsx +15 -0
- package/src/monitoring/catcher.ts +118 -0
- package/src/monitoring/index.ts +25 -0
- package/src/monitoring/sdk.ts +112 -0
- package/src/monitoring/server.ts +244 -0
- package/src/monitoring/start.ts +118 -0
- package/src/primitives/Button.tsx +5 -1
- package/src/primitives/Eyebrow.tsx +6 -2
- package/src/primitives/ProseBlocks.tsx +6 -1
- package/src/primitives/SectionHeading.tsx +3 -1
- package/src/primitives/StarRow.tsx +23 -8
- package/src/routing/index.ts +1 -0
- package/src/routing/miss.ts +32 -0
- package/src/scripts/check-sentry.ts +77 -0
- package/src/sections/BlogIndex.tsx +17 -3
- package/src/sections/BlogPost.tsx +10 -1
- package/src/sections/CTASection.tsx +2 -2
- package/src/sections/CalloutPanel.tsx +34 -0
- package/src/sections/ComparisonTable.tsx +23 -2
- package/src/sections/ContactForm.tsx +61 -17
- package/src/sections/FAQBrowser.tsx +11 -2
- package/src/sections/FeatureGrid.tsx +6 -2
- package/src/sections/FullBleedVideo.tsx +167 -0
- package/src/sections/Gallery.tsx +6 -4
- package/src/sections/Hero.tsx +70 -39
- package/src/sections/JumpRail.tsx +7 -0
- package/src/sections/LegalPage.tsx +10 -2
- package/src/sections/LinkColumns.tsx +80 -0
- package/src/sections/LocationSection.tsx +28 -5
- package/src/sections/Locations.tsx +18 -5
- package/src/sections/LogoMarquee.tsx +43 -11
- package/src/sections/MapEmbed.tsx +13 -9
- package/src/sections/PageHero.tsx +16 -2
- package/src/sections/ProcessSteps.tsx +27 -4
- package/src/sections/ProfileCards.tsx +12 -2
- package/src/sections/ProofStrip.tsx +44 -0
- package/src/sections/RevealSlider.tsx +28 -7
- package/src/sections/ReviewCarousel.tsx +17 -4
- package/src/sections/ReviewWall.tsx +2 -2
- package/src/sections/SplitSection.tsx +2 -1
- package/src/sections/index.ts +15 -6
- package/src/sections/siteConfig.ts +101 -8
- package/src/styles/app.css +33 -2
- package/src/styles/artifact.css +20 -8
- package/src/styles/base.css +68 -13
- package/src/styles/chrome.css +1134 -56
- package/src/styles/components.css +104 -65
- package/src/styles/defaults.css +140 -0
- package/src/styles/gate.css +21 -10
- package/src/styles/primitives.css +108 -39
- package/src/styles/sections.css +500 -437
- package/src/styles/star-rating.css +1 -4
- package/src/tokens/palettes.ts +24 -4
- package/src/types.ts +220 -3
- package/src/vite/index.ts +4 -0
- package/src/vite/marketing-config.ts +81 -1
- package/src/app/CardErrorBoundary.tsx +0 -39
- package/src/sections/CTABanner.tsx +0 -93
- package/src/sections/DeviceShowcase.tsx +0 -39
- package/src/sections/MediaBand.tsx +0 -20
- package/src/sections/MenuList.tsx +0 -44
- package/src/sections/PressQuotes.tsx +0 -51
- package/src/sections/SocialStrip.tsx +0 -83
package/src/chrome/Footer.tsx
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { Mail, Star, UserRound } from "lucide-react";
|
|
2
|
-
import type { ComponentProps, CSSProperties } from "react";
|
|
2
|
+
import type { ComponentProps, CSSProperties, Ref } from "react";
|
|
3
|
+
import { breakableEmail } from "../lib/emailText";
|
|
3
4
|
import { newTabProps } from "../lib/newTabProps";
|
|
4
|
-
import type {
|
|
5
|
+
import type {
|
|
6
|
+
Brand,
|
|
7
|
+
FooterColumn,
|
|
8
|
+
FooterColumnLink,
|
|
9
|
+
HoursRow,
|
|
10
|
+
Phone,
|
|
11
|
+
PostalAddress,
|
|
12
|
+
} from "../types";
|
|
13
|
+
import { LockupParts, LogoTile, lockupWords } from "./BrandLockup";
|
|
14
|
+
import { resolveMark, tintClass } from "./brandMark";
|
|
5
15
|
import { ClosingBar } from "./ClosingBar";
|
|
6
16
|
import { Copyright } from "./Copyright";
|
|
7
17
|
|
|
@@ -129,9 +139,22 @@ export interface FooterProps {
|
|
|
129
139
|
brand: Brand;
|
|
130
140
|
/**
|
|
131
141
|
* The Google rating as printed, e.g. "4.8 on Google". It sits under the
|
|
132
|
-
* logo beside five stars,
|
|
142
|
+
* logo beside five stars, which are hidden from assistive technology, so
|
|
143
|
+
* the line is named by these words. Plain text unless `ratingHref` is given.
|
|
133
144
|
*/
|
|
134
145
|
rating?: string;
|
|
146
|
+
/**
|
|
147
|
+
* Where the rating links: the business's Google profile, where the
|
|
148
|
+
* reviews are. Given, the whole line (the stars and the words) is one
|
|
149
|
+
* link, opening in a new tab as the address does.
|
|
150
|
+
*/
|
|
151
|
+
ratingHref?: string;
|
|
152
|
+
/**
|
|
153
|
+
* The rating link's accessible name, when it should say more than the
|
|
154
|
+
* words shown, e.g. "4.8 on Google, opens the Google profile". Defaults
|
|
155
|
+
* to `rating`.
|
|
156
|
+
*/
|
|
157
|
+
ratingLabel?: string;
|
|
135
158
|
/**
|
|
136
159
|
* The one address, the headquarters. Omit it for a business with no
|
|
137
160
|
* storefront, and the phone and email stand alone.
|
|
@@ -141,6 +164,14 @@ export interface FooterProps {
|
|
|
141
164
|
addressHref?: string;
|
|
142
165
|
phone?: Phone;
|
|
143
166
|
email?: string;
|
|
167
|
+
/**
|
|
168
|
+
* The opening hours, already formatted by the site (`SiteShell` formats
|
|
169
|
+
* the config's `hours`), drawn as their own column beside the link
|
|
170
|
+
* columns: each row's days and its range. Left out when empty.
|
|
171
|
+
*/
|
|
172
|
+
hours?: HoursRow[];
|
|
173
|
+
/** The hours column's heading. Defaults to "Hours". */
|
|
174
|
+
hoursHeading?: string;
|
|
144
175
|
/**
|
|
145
176
|
* The link columns beside the brand column. The default footer carries
|
|
146
177
|
* four: Company, Resources, Social, and Legal. A column with no links is
|
|
@@ -157,28 +188,57 @@ export interface FooterProps {
|
|
|
157
188
|
* prints either way.
|
|
158
189
|
*/
|
|
159
190
|
credit?: boolean;
|
|
191
|
+
/**
|
|
192
|
+
* The level of the link columns' headings. Defaults to 2: the footer is a
|
|
193
|
+
* landmark beside the page's main content, so its sections sit one level
|
|
194
|
+
* under the page's `h1` whatever the page's own outline ends on, and a
|
|
195
|
+
* page never skips a level into its footer. A site whose footer sits
|
|
196
|
+
* inside a deeper outline passes its own.
|
|
197
|
+
*/
|
|
198
|
+
headingLevel?: 2 | 3 | 4 | 5 | 6;
|
|
199
|
+
/** The footer element, for a caller that measures it (`SiteShell` hands it to the contact dock). */
|
|
200
|
+
ref?: Ref<HTMLElement>;
|
|
160
201
|
}
|
|
161
202
|
|
|
162
203
|
/**
|
|
163
204
|
* The site footer: a brand column (the logo, the Google rating, the address
|
|
164
|
-
* linked to the Google profile, the phone, and the email), the
|
|
165
|
-
* beside it, and the closing bar under it
|
|
205
|
+
* linked to the Google profile, the phone, and the email), the hours when the
|
|
206
|
+
* site gives them, the link columns beside it, and the closing bar under it
|
|
207
|
+
* all. The logo is the header's lockup: the mark with the wordmark beside it,
|
|
208
|
+
* or the mark alone when `logo.wordmark` is false.
|
|
166
209
|
*/
|
|
167
210
|
export function Footer({
|
|
168
211
|
brand,
|
|
169
212
|
rating,
|
|
213
|
+
ratingHref,
|
|
214
|
+
ratingLabel,
|
|
170
215
|
address,
|
|
171
216
|
addressHref,
|
|
172
217
|
phone,
|
|
173
218
|
email,
|
|
219
|
+
hours,
|
|
220
|
+
hoursHeading = "Hours",
|
|
174
221
|
columns,
|
|
175
222
|
attribution,
|
|
176
223
|
note,
|
|
177
224
|
credit = true,
|
|
225
|
+
headingLevel = 2,
|
|
226
|
+
ref,
|
|
178
227
|
}: FooterProps) {
|
|
179
228
|
const { name, logo } = brand;
|
|
180
|
-
|
|
229
|
+
// The footer always names the business beside a glyph tile.
|
|
230
|
+
const wordmark = logo?.wordmark === false ? name : (logo?.wordmark ?? name);
|
|
231
|
+
// The band is a dark surface, resolved by the order the header uses.
|
|
232
|
+
const mark = resolveMark(logo, "dark");
|
|
181
233
|
const shown = (columns ?? []).filter((column) => column.links.length > 0);
|
|
234
|
+
const hoursShown = hours && hours.length > 0 ? hours : null;
|
|
235
|
+
const stars = (
|
|
236
|
+
<span className="footer-stars" aria-hidden="true">
|
|
237
|
+
{STARS.map((star) => (
|
|
238
|
+
<Star key={star} size={16} fill="currentColor" />
|
|
239
|
+
))}
|
|
240
|
+
</span>
|
|
241
|
+
);
|
|
182
242
|
const addressLines = address && (
|
|
183
243
|
<>
|
|
184
244
|
{/* A business that publishes a service area but no storefront leaves
|
|
@@ -193,39 +253,48 @@ export function Footer({
|
|
|
193
253
|
|
|
194
254
|
return (
|
|
195
255
|
<>
|
|
196
|
-
<footer className="footer">
|
|
256
|
+
<footer ref={ref} className="footer">
|
|
197
257
|
<div className="wrap">
|
|
198
258
|
<div
|
|
199
|
-
className="footer-grid"
|
|
200
|
-
style={{ "--footer-columns": shown.length } as CSSProperties}
|
|
259
|
+
className={hoursShown ? "footer-grid has-hours" : "footer-grid"}
|
|
260
|
+
style={{ "--footer-columns": shown.length + (hoursShown ? 1 : 0) } as CSSProperties}
|
|
201
261
|
>
|
|
202
262
|
<div className="footer-brand">
|
|
203
263
|
{logo?.tile ? (
|
|
204
264
|
<p className="footer-wordmark">
|
|
205
|
-
<
|
|
206
|
-
{logo.tile}
|
|
207
|
-
</span>
|
|
265
|
+
<LogoTile glyph={logo.tile} />
|
|
208
266
|
{wordmark}
|
|
209
267
|
{logo.run && <span className="wordmark-run" aria-hidden="true" />}
|
|
210
268
|
</p>
|
|
211
|
-
) : logo
|
|
212
|
-
|
|
269
|
+
) : mark && lockupWords(name, logo) === null ? (
|
|
270
|
+
// Artwork that already spells the name stands alone, named by its alt.
|
|
271
|
+
<img className={tintClass(mark)} src={mark.src} alt={logo?.alt ?? name} />
|
|
213
272
|
) : (
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
)}
|
|
219
|
-
{rating && (
|
|
220
|
-
<p className="footer-rating">
|
|
221
|
-
<span className="footer-stars" aria-hidden="true">
|
|
222
|
-
{STARS.map((star) => (
|
|
223
|
-
<Star key={star} size={16} fill="currentColor" />
|
|
224
|
-
))}
|
|
225
|
-
</span>
|
|
226
|
-
{rating}
|
|
273
|
+
// The header's lockup on the dark band: the mark with the wordmark
|
|
274
|
+
// beside it, or the words alone when there is no image.
|
|
275
|
+
<p className={mark ? "footer-wordmark footer-lockup" : "footer-wordmark"}>
|
|
276
|
+
<LockupParts name={name} logo={logo} surface="dark" />
|
|
227
277
|
</p>
|
|
228
278
|
)}
|
|
279
|
+
{rating &&
|
|
280
|
+
(ratingHref ? (
|
|
281
|
+
<p className="footer-rating">
|
|
282
|
+
<a
|
|
283
|
+
className="footer-rating-link"
|
|
284
|
+
href={ratingHref}
|
|
285
|
+
aria-label={ratingLabel}
|
|
286
|
+
{...newTabProps(ratingHref, true)}
|
|
287
|
+
>
|
|
288
|
+
{stars}
|
|
289
|
+
{rating}
|
|
290
|
+
</a>
|
|
291
|
+
</p>
|
|
292
|
+
) : (
|
|
293
|
+
<p className="footer-rating">
|
|
294
|
+
{stars}
|
|
295
|
+
{rating}
|
|
296
|
+
</p>
|
|
297
|
+
))}
|
|
229
298
|
{(address || phone || email) && (
|
|
230
299
|
<address className="nap">
|
|
231
300
|
{address &&
|
|
@@ -241,15 +310,41 @@ export function Footer({
|
|
|
241
310
|
<span className="nap-address">{addressLines}</span>
|
|
242
311
|
))}
|
|
243
312
|
{phone && <a href={`tel:${phone.e164}`}>{phone.display}</a>}
|
|
244
|
-
{email && <a href={`mailto:${email}`}>{email}</a>}
|
|
313
|
+
{email && <a href={`mailto:${email}`}>{breakableEmail(email)}</a>}
|
|
245
314
|
</address>
|
|
246
315
|
)}
|
|
247
316
|
</div>
|
|
317
|
+
{hoursShown && (
|
|
318
|
+
<div className="footer-column footer-hours">
|
|
319
|
+
{/* biome-ignore lint/a11y/useSemanticElements: a heading by role, as the link columns' are (see below) */}
|
|
320
|
+
<div className="footer-heading" role="heading" aria-level={headingLevel}>
|
|
321
|
+
{hoursHeading}
|
|
322
|
+
</div>
|
|
323
|
+
<dl>
|
|
324
|
+
{hoursShown.map((row, at) => (
|
|
325
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: two rows may share a label (a split day), so the place keeps the key unique; rows never reorder
|
|
326
|
+
<div key={`${at} ${row.label}`}>
|
|
327
|
+
<dt>{row.label}</dt>
|
|
328
|
+
<dd>{row.range}</dd>
|
|
329
|
+
</div>
|
|
330
|
+
))}
|
|
331
|
+
</dl>
|
|
332
|
+
</div>
|
|
333
|
+
)}
|
|
248
334
|
{shown.map((column) => (
|
|
249
335
|
<nav key={column.heading} className="footer-column" aria-label={column.heading}>
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
336
|
+
{/* A heading by role rather than by element: a site's own bare
|
|
337
|
+
h2 rule (unlayered, so it beats any rule in the package's
|
|
338
|
+
layer whatever its weight) is written for a page's section
|
|
339
|
+
titles and would restyle these small labels. A div that says
|
|
340
|
+
it is a heading keeps the outline and matches no such rule. */}
|
|
341
|
+
{/* biome-ignore lint/a11y/useSemanticElements: an h2 element would take a site's bare h2 rules, see above */}
|
|
342
|
+
<div className="footer-heading" role="heading" aria-level={headingLevel}>
|
|
343
|
+
{column.heading}
|
|
344
|
+
</div>
|
|
345
|
+
{column.links.map((link, at) => (
|
|
346
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: two links may share a label and a page, so the place keeps the key unique; links never reorder
|
|
347
|
+
<ColumnLink key={at} link={link} />
|
|
253
348
|
))}
|
|
254
349
|
</nav>
|
|
255
350
|
))}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A short word in a pill after a nav link's label ("Popular"), drawn the
|
|
3
|
+
* same on the desktop panel and in the phone's menu, each with its own
|
|
4
|
+
* class for the surface it sits on. Nothing without words.
|
|
5
|
+
*/
|
|
6
|
+
export function NavBadge({ text, className }: { text?: string; className: string }) {
|
|
7
|
+
return text ? <span className={className}>{text}</span> : null;
|
|
8
|
+
}
|
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
import { ChevronRight } from "lucide-react";
|
|
2
|
+
import { newTabProps } from "../lib/newTabProps";
|
|
3
|
+
import { holdPhoneNumbers, isTel } from "../lib/phoneText";
|
|
4
|
+
import { Button } from "../primitives/Button";
|
|
5
|
+
import { TickList } from "../primitives/TickList";
|
|
6
|
+
import type {
|
|
7
|
+
NavCardsSection,
|
|
8
|
+
NavGroupChildLink,
|
|
9
|
+
NavGroupColumn,
|
|
10
|
+
NavIconRowsSection,
|
|
11
|
+
NavLink,
|
|
12
|
+
NavPanelSection,
|
|
13
|
+
NavPictureSection,
|
|
14
|
+
} from "../types";
|
|
15
|
+
import { navIcons } from "./icons";
|
|
16
|
+
import { NavBadge } from "./NavBadge";
|
|
17
|
+
import { isLinkColumn, panelSections } from "./navSections";
|
|
18
|
+
|
|
19
|
+
export interface NavMegaPanelProps {
|
|
20
|
+
id: string;
|
|
21
|
+
/** The group whose sections and feature card the panel holds. */
|
|
22
|
+
group: NavLink;
|
|
23
|
+
open: boolean;
|
|
24
|
+
currentPath?: string;
|
|
25
|
+
/** Called when a link in the panel is followed, so the header can close it. */
|
|
26
|
+
onNavigate?: () => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The key a section is listed under: its place and its kind. Two sections
|
|
31
|
+
* may share a heading or an href, so the place keeps every key unique.
|
|
32
|
+
*/
|
|
33
|
+
function sectionKey(section: NavPanelSection, index: number): string {
|
|
34
|
+
return `${index} ${isLinkColumn(section) ? "links" : section.kind}`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function Badge({ text }: { text?: string }) {
|
|
38
|
+
return <NavBadge text={text} className="nav-mega-badge" />;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Says whether a link is the panel's current item, as its `aria-current`,
|
|
43
|
+
* by the link's place in the panel (`linkKey`).
|
|
44
|
+
*/
|
|
45
|
+
type Current = (key: string) => "page" | undefined;
|
|
46
|
+
|
|
47
|
+
/** A link's place in the panel: which section, and where inside it. */
|
|
48
|
+
function linkKey(section: number, ...place: (number | string)[]): string {
|
|
49
|
+
return [section, ...place].join(" ");
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The place of the panel's one current item: the first link, in reading
|
|
54
|
+
* order, to the page being read. A panel may link one page several times
|
|
55
|
+
* (the group's own page as its "all" link and a column's head, a child
|
|
56
|
+
* sharing its parent's href), and a reader is told the page is here once.
|
|
57
|
+
* Worked out from the props alone, in the order the links render, so any
|
|
58
|
+
* render (StrictMode's second, a child's on its own) marks the same link.
|
|
59
|
+
*/
|
|
60
|
+
function currentKey(
|
|
61
|
+
group: NavLink,
|
|
62
|
+
sections: NavPanelSection[],
|
|
63
|
+
currentPath?: string,
|
|
64
|
+
): string | undefined {
|
|
65
|
+
if (currentPath === undefined) return undefined;
|
|
66
|
+
if (group.allLabel && group.href === currentPath) return "all";
|
|
67
|
+
for (const [index, section] of sections.entries()) {
|
|
68
|
+
if (isLinkColumn(section)) {
|
|
69
|
+
if (section.href === currentPath) return linkKey(index, "head");
|
|
70
|
+
for (const [at, link] of section.links.entries()) {
|
|
71
|
+
if (link.href === currentPath) return linkKey(index, at);
|
|
72
|
+
for (const [child, sub] of (link.children ?? []).entries()) {
|
|
73
|
+
if (sub.href === currentPath) return linkKey(index, at, child);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
} else if (section.kind === "picture") {
|
|
77
|
+
if (section.href === currentPath) return linkKey(index, "picture");
|
|
78
|
+
} else if (section.kind === "rows") {
|
|
79
|
+
for (const [at, row] of section.rows.entries()) {
|
|
80
|
+
if (row.href === currentPath) return linkKey(index, "row", at);
|
|
81
|
+
}
|
|
82
|
+
} else if (section.kind === "cards") {
|
|
83
|
+
for (const [at, card] of section.cards.entries()) {
|
|
84
|
+
if (card.href === currentPath) return linkKey(index, "card", at);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
interface SectionProps {
|
|
92
|
+
/** The section's place in the panel, which its links' keys begin with. */
|
|
93
|
+
index: number;
|
|
94
|
+
current: Current;
|
|
95
|
+
onNavigate?: () => void;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function LinkColumn({
|
|
99
|
+
column,
|
|
100
|
+
index,
|
|
101
|
+
current,
|
|
102
|
+
onNavigate,
|
|
103
|
+
}: { column: NavGroupColumn } & SectionProps) {
|
|
104
|
+
// A child may share its parent's href, and two links may share one, so
|
|
105
|
+
// every key carries its place.
|
|
106
|
+
const child = (parent: number) => (link: NavGroupChildLink, at: number) => (
|
|
107
|
+
<li key={`${at} ${link.href}`}>
|
|
108
|
+
<a
|
|
109
|
+
className="nav-mega-sub"
|
|
110
|
+
href={link.href}
|
|
111
|
+
onClick={onNavigate}
|
|
112
|
+
aria-current={current(linkKey(index, parent, at))}
|
|
113
|
+
{...newTabProps(link.href, link.external)}
|
|
114
|
+
>
|
|
115
|
+
{isTel(link.href) ? holdPhoneNumbers(link.label) : link.label}
|
|
116
|
+
<Badge text={link.badge} />
|
|
117
|
+
</a>
|
|
118
|
+
</li>
|
|
119
|
+
);
|
|
120
|
+
return (
|
|
121
|
+
<div className="nav-mega-sec is-links">
|
|
122
|
+
{column.href ? (
|
|
123
|
+
<a
|
|
124
|
+
className="nav-mega-head"
|
|
125
|
+
href={column.href}
|
|
126
|
+
onClick={onNavigate}
|
|
127
|
+
aria-current={current(linkKey(index, "head"))}
|
|
128
|
+
>
|
|
129
|
+
{column.heading}
|
|
130
|
+
</a>
|
|
131
|
+
) : (
|
|
132
|
+
<p className="nav-mega-head">{column.heading}</p>
|
|
133
|
+
)}
|
|
134
|
+
<ul>
|
|
135
|
+
{column.links.map((link, at) => (
|
|
136
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: two links may share an href, so the place keeps the key unique; a panel's links never reorder
|
|
137
|
+
<li key={`${at} ${link.href}`}>
|
|
138
|
+
<a
|
|
139
|
+
className={link.quiet ? "nav-mega-link is-quiet" : "nav-mega-link"}
|
|
140
|
+
href={link.href}
|
|
141
|
+
onClick={onNavigate}
|
|
142
|
+
aria-current={current(linkKey(index, at))}
|
|
143
|
+
{...newTabProps(link.href, link.external)}
|
|
144
|
+
>
|
|
145
|
+
<span className="nav-mega-label">
|
|
146
|
+
{isTel(link.href) ? holdPhoneNumbers(link.label) : link.label}
|
|
147
|
+
<Badge text={link.badge} />
|
|
148
|
+
</span>
|
|
149
|
+
{link.description && (
|
|
150
|
+
<span className="nav-mega-desc">
|
|
151
|
+
{isTel(link.href) ? holdPhoneNumbers(link.description) : link.description}
|
|
152
|
+
</span>
|
|
153
|
+
)}
|
|
154
|
+
</a>
|
|
155
|
+
{link.children && link.children.length > 0 && (
|
|
156
|
+
<ul className="nav-mega-children">{link.children.map(child(at))}</ul>
|
|
157
|
+
)}
|
|
158
|
+
</li>
|
|
159
|
+
))}
|
|
160
|
+
</ul>
|
|
161
|
+
</div>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function PictureSection({
|
|
166
|
+
section,
|
|
167
|
+
index,
|
|
168
|
+
current,
|
|
169
|
+
onNavigate,
|
|
170
|
+
}: { section: NavPictureSection } & SectionProps) {
|
|
171
|
+
return (
|
|
172
|
+
<a
|
|
173
|
+
className="nav-mega-sec is-picture"
|
|
174
|
+
href={section.href}
|
|
175
|
+
onClick={onNavigate}
|
|
176
|
+
aria-current={current(linkKey(index, "picture"))}
|
|
177
|
+
{...newTabProps(section.href, section.external)}
|
|
178
|
+
>
|
|
179
|
+
<img
|
|
180
|
+
className="nav-mega-picture"
|
|
181
|
+
src={section.image.src}
|
|
182
|
+
alt={section.image.alt ?? ""}
|
|
183
|
+
loading="lazy"
|
|
184
|
+
decoding="async"
|
|
185
|
+
/>
|
|
186
|
+
<span className="nav-mega-caption">{section.caption}</span>
|
|
187
|
+
</a>
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function RowsSection({
|
|
192
|
+
section,
|
|
193
|
+
index,
|
|
194
|
+
current,
|
|
195
|
+
onNavigate,
|
|
196
|
+
}: { section: NavIconRowsSection } & SectionProps) {
|
|
197
|
+
return (
|
|
198
|
+
<div className="nav-mega-sec is-rows">
|
|
199
|
+
{section.heading && <p className="nav-mega-head">{section.heading}</p>}
|
|
200
|
+
<ul className="nav-mega-rows">
|
|
201
|
+
{section.rows.map((row, at) => {
|
|
202
|
+
const Icon = navIcons[row.icon];
|
|
203
|
+
return (
|
|
204
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: two links may share an href, so the place keeps the key unique; a panel's links never reorder
|
|
205
|
+
<li key={`${at} ${row.href}`}>
|
|
206
|
+
<a
|
|
207
|
+
className={["nav-mega-row", row.highlight && "is-highlight"]
|
|
208
|
+
.filter(Boolean)
|
|
209
|
+
.join(" ")}
|
|
210
|
+
href={row.href}
|
|
211
|
+
onClick={onNavigate}
|
|
212
|
+
aria-current={current(linkKey(index, "row", at))}
|
|
213
|
+
{...newTabProps(row.href, row.external)}
|
|
214
|
+
>
|
|
215
|
+
<span className="nav-mega-row-icon">
|
|
216
|
+
<Icon size={21} strokeWidth={1.75} aria-hidden="true" />
|
|
217
|
+
</span>
|
|
218
|
+
<span className="nav-mega-row-text">
|
|
219
|
+
<span className="nav-mega-row-label">
|
|
220
|
+
{isTel(row.href) ? holdPhoneNumbers(row.label) : row.label}
|
|
221
|
+
</span>
|
|
222
|
+
{row.description && (
|
|
223
|
+
<span className="nav-mega-row-desc">
|
|
224
|
+
{isTel(row.href) ? holdPhoneNumbers(row.description) : row.description}
|
|
225
|
+
</span>
|
|
226
|
+
)}
|
|
227
|
+
</span>
|
|
228
|
+
<ChevronRight className="nav-mega-row-go" size={16} aria-hidden="true" />
|
|
229
|
+
</a>
|
|
230
|
+
</li>
|
|
231
|
+
);
|
|
232
|
+
})}
|
|
233
|
+
</ul>
|
|
234
|
+
</div>
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function CardsSection({
|
|
239
|
+
section,
|
|
240
|
+
index,
|
|
241
|
+
current,
|
|
242
|
+
onNavigate,
|
|
243
|
+
}: { section: NavCardsSection } & SectionProps) {
|
|
244
|
+
return (
|
|
245
|
+
<div className="nav-mega-sec is-cards">
|
|
246
|
+
{section.heading && <p className="nav-mega-head">{section.heading}</p>}
|
|
247
|
+
<ul className="nav-mega-cards">
|
|
248
|
+
{section.cards.map((card, at) => (
|
|
249
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: two links may share an href, so the place keeps the key unique; a panel's links never reorder
|
|
250
|
+
<li key={`${at} ${card.href}`}>
|
|
251
|
+
<a
|
|
252
|
+
className="nav-mega-card-link"
|
|
253
|
+
href={card.href}
|
|
254
|
+
onClick={onNavigate}
|
|
255
|
+
aria-current={current(linkKey(index, "card", at))}
|
|
256
|
+
{...newTabProps(card.href, card.external)}
|
|
257
|
+
>
|
|
258
|
+
{card.image ? (
|
|
259
|
+
<img
|
|
260
|
+
className="nav-mega-thumb"
|
|
261
|
+
src={card.image.src}
|
|
262
|
+
alt={card.image.alt ?? ""}
|
|
263
|
+
loading="lazy"
|
|
264
|
+
decoding="async"
|
|
265
|
+
/>
|
|
266
|
+
) : (
|
|
267
|
+
<span className="nav-mega-thumb" aria-hidden="true" />
|
|
268
|
+
)}
|
|
269
|
+
<span className="nav-mega-card-text">
|
|
270
|
+
{card.kicker && <span className="nav-mega-kicker">{card.kicker}</span>}
|
|
271
|
+
<span className="nav-mega-card-title">{card.title}</span>
|
|
272
|
+
{card.meta && <span className="nav-mega-meta">{card.meta}</span>}
|
|
273
|
+
</span>
|
|
274
|
+
</a>
|
|
275
|
+
</li>
|
|
276
|
+
))}
|
|
277
|
+
</ul>
|
|
278
|
+
</div>
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* The desktop panel a nav group opens: one card under the bar, as wide as
|
|
284
|
+
* the page's wrap, holding the group's sections left to right (link columns,
|
|
285
|
+
* a picture, icon rows, small cards) and, when the group has one, the
|
|
286
|
+
* feature card at the right. It renders whether open or not, `inert` while
|
|
287
|
+
* closed, so the links ship in the static HTML and leave the tab order until
|
|
288
|
+
* it opens. The header owns the open state; this draws it.
|
|
289
|
+
*/
|
|
290
|
+
export function NavMegaPanel({ id, group, open, currentPath, onNavigate }: NavMegaPanelProps) {
|
|
291
|
+
const { feature, allLabel, href } = group;
|
|
292
|
+
// A section of a kind this version does not know is left out, never drawn as another kind.
|
|
293
|
+
const columns = panelSections(group);
|
|
294
|
+
const claim = currentKey(group, columns, currentPath);
|
|
295
|
+
const current: Current = (key) => (key === claim ? "page" : undefined);
|
|
296
|
+
return (
|
|
297
|
+
<div
|
|
298
|
+
id={id}
|
|
299
|
+
className={["nav-mega", open && "is-open"].filter(Boolean).join(" ")}
|
|
300
|
+
inert={!open}
|
|
301
|
+
>
|
|
302
|
+
<div className="nav-mega-card">
|
|
303
|
+
<div className="nav-mega-body">
|
|
304
|
+
{allLabel && (
|
|
305
|
+
<a
|
|
306
|
+
className="nav-mega-all"
|
|
307
|
+
href={href}
|
|
308
|
+
onClick={onNavigate}
|
|
309
|
+
aria-current={current("all")}
|
|
310
|
+
>
|
|
311
|
+
{allLabel}
|
|
312
|
+
</a>
|
|
313
|
+
)}
|
|
314
|
+
<div className="nav-mega-sections">
|
|
315
|
+
{columns.map((section, index) => {
|
|
316
|
+
const key = sectionKey(section, index);
|
|
317
|
+
if (isLinkColumn(section)) {
|
|
318
|
+
return (
|
|
319
|
+
<LinkColumn
|
|
320
|
+
key={key}
|
|
321
|
+
index={index}
|
|
322
|
+
column={section}
|
|
323
|
+
current={current}
|
|
324
|
+
onNavigate={onNavigate}
|
|
325
|
+
/>
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
if (section.kind === "picture") {
|
|
329
|
+
return (
|
|
330
|
+
<PictureSection
|
|
331
|
+
key={key}
|
|
332
|
+
index={index}
|
|
333
|
+
section={section}
|
|
334
|
+
current={current}
|
|
335
|
+
onNavigate={onNavigate}
|
|
336
|
+
/>
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
if (section.kind === "rows") {
|
|
340
|
+
return (
|
|
341
|
+
<RowsSection
|
|
342
|
+
key={key}
|
|
343
|
+
index={index}
|
|
344
|
+
section={section}
|
|
345
|
+
current={current}
|
|
346
|
+
onNavigate={onNavigate}
|
|
347
|
+
/>
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
if (section.kind === "cards") {
|
|
351
|
+
return (
|
|
352
|
+
<CardsSection
|
|
353
|
+
key={key}
|
|
354
|
+
index={index}
|
|
355
|
+
section={section}
|
|
356
|
+
current={current}
|
|
357
|
+
onNavigate={onNavigate}
|
|
358
|
+
/>
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
return null;
|
|
362
|
+
})}
|
|
363
|
+
</div>
|
|
364
|
+
</div>
|
|
365
|
+
{feature && (
|
|
366
|
+
// The card is the primary field, so its button turns light (.on-primary).
|
|
367
|
+
<div className="nav-feature on-primary">
|
|
368
|
+
{feature.image && (
|
|
369
|
+
<img
|
|
370
|
+
className="nav-feature-img"
|
|
371
|
+
src={feature.image.src}
|
|
372
|
+
alt={feature.image.alt}
|
|
373
|
+
loading="lazy"
|
|
374
|
+
decoding="async"
|
|
375
|
+
/>
|
|
376
|
+
)}
|
|
377
|
+
<div className="nav-feature-body">
|
|
378
|
+
{feature.eyebrow && <p className="nav-feature-eyebrow">{feature.eyebrow}</p>}
|
|
379
|
+
<p className="nav-feature-title">{feature.title}</p>
|
|
380
|
+
{feature.text && <p className="nav-feature-text">{feature.text}</p>}
|
|
381
|
+
{feature.points && feature.points.length > 0 && (
|
|
382
|
+
<TickList className="nav-feature-points" items={feature.points} />
|
|
383
|
+
)}
|
|
384
|
+
<Button
|
|
385
|
+
className="nav-feature-cta"
|
|
386
|
+
href={feature.cta.href}
|
|
387
|
+
newTab={feature.cta.external}
|
|
388
|
+
onClick={onNavigate}
|
|
389
|
+
arrow
|
|
390
|
+
>
|
|
391
|
+
{feature.cta.label}
|
|
392
|
+
</Button>
|
|
393
|
+
</div>
|
|
394
|
+
</div>
|
|
395
|
+
)}
|
|
396
|
+
</div>
|
|
397
|
+
</div>
|
|
398
|
+
);
|
|
399
|
+
}
|