@atelic-action/ui 8.0.0 → 8.2.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 +187 -22
- package/bin/atelic-check-sentry.ts +5 -0
- package/dist/gate/middleware.js +15 -1
- package/dist/monitoring/server.d.ts +122 -0
- package/dist/monitoring/server.js +302 -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 +10 -2
- package/src/app/layout/DesktopRail.tsx +6 -4
- package/src/app/layout/MobileMenu.tsx +10 -5
- package/src/app/layout/MobileTabBar.tsx +3 -2
- package/src/app/layout/PageError.tsx +2 -2
- package/src/app/layout/SectionCards.tsx +7 -2
- package/src/app/layout/UserMenu.tsx +1 -1
- package/src/app/ui/alert.tsx +1 -1
- package/src/app/ui/form.tsx +2 -2
- package/src/artifact/AppErrorBoundary.tsx +12 -7
- package/src/chrome/BrandLockup.tsx +46 -7
- package/src/chrome/ContactDock.tsx +59 -13
- package/src/chrome/Footer.tsx +97 -28
- package/src/chrome/NavMegaPanel.tsx +11 -6
- package/src/chrome/SiteHeader.tsx +68 -18
- package/src/chrome/SiteMenu.tsx +207 -72
- package/src/chrome/SiteShell.tsx +25 -3
- package/src/chrome/StickyCTABar.tsx +24 -8
- package/src/chrome/index.ts +2 -0
- package/src/components/NotFound.tsx +3 -2
- package/src/gate/middleware.ts +15 -1
- package/src/lib/emailText.tsx +26 -0
- package/src/lib/phoneText.tsx +49 -0
- package/src/monitoring/ErrorCatcherScript.tsx +26 -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 +368 -0
- package/src/monitoring/start.ts +118 -0
- package/src/primitives/Button.tsx +3 -1
- package/src/primitives/Eyebrow.tsx +6 -2
- package/src/routing/index.ts +11 -32
- package/src/routing/miss.ts +32 -0
- package/src/routing/routerErrors.tsx +57 -0
- package/src/routing/staticNotFound.tsx +64 -0
- package/src/scripts/check-sentry.ts +98 -0
- package/src/sections/CalloutPanel.tsx +4 -1
- package/src/sections/ContactInfoCard.tsx +1 -1
- package/src/sections/FullBleedVideo.tsx +13 -4
- package/src/sections/Hero.tsx +10 -3
- package/src/sections/LinkColumns.tsx +30 -14
- package/src/sections/Locations.tsx +1 -1
- package/src/sections/LogoMarquee.tsx +1 -1
- package/src/sections/PricingBand.tsx +1 -1
- package/src/sections/ProcessSteps.tsx +1 -1
- package/src/sections/siteConfig.ts +67 -5
- package/src/styles/app.css +9 -0
- package/src/styles/base.css +34 -2
- package/src/styles/chrome.css +449 -41
- package/src/styles/defaults.css +61 -2
- package/src/styles/primitives.css +20 -7
- package/src/styles/sections.css +52 -9
- package/src/types.ts +40 -2
- package/src/vite/index.ts +4 -0
- package/src/vite/marketing-config.ts +81 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component, type ReactNode } from "react";
|
|
2
|
-
|
|
2
|
+
import { reportError } from "../monitoring/catcher";
|
|
3
3
|
import { ErrorFallback } from "./ErrorFallback";
|
|
4
4
|
|
|
5
5
|
interface AppErrorBoundaryState {
|
|
@@ -8,12 +8,13 @@ interface AppErrorBoundaryState {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* Plain React error boundary rendering the dependency
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
11
|
+
* Plain React error boundary rendering the dependency free ErrorFallback, so
|
|
12
|
+
* no Sentry code sits in the critical bundle. A render crash it catches
|
|
13
|
+
* never reaches the window's error handlers (React keeps it), so it hands
|
|
14
|
+
* the error to the package's error reporting itself (`reportError`): to the
|
|
15
|
+
* Sentry SDK once `startErrorReporting` has loaded it, and to the early
|
|
16
|
+
* catcher's buffer before that, which the SDK replays when it arrives. With
|
|
17
|
+
* no DSN configured the buffer simply holds it and nothing is sent.
|
|
17
18
|
*/
|
|
18
19
|
export class AppErrorBoundary extends Component<{ children: ReactNode }, AppErrorBoundaryState> {
|
|
19
20
|
state: AppErrorBoundaryState = { error: null, hasError: false };
|
|
@@ -22,6 +23,10 @@ export class AppErrorBoundary extends Component<{ children: ReactNode }, AppErro
|
|
|
22
23
|
return { error, hasError: true };
|
|
23
24
|
}
|
|
24
25
|
|
|
26
|
+
componentDidCatch(error: unknown) {
|
|
27
|
+
reportError(error, "boundary");
|
|
28
|
+
}
|
|
29
|
+
|
|
25
30
|
render() {
|
|
26
31
|
if (this.state.hasError) {
|
|
27
32
|
return (
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Brand, BrandLogo } from "../types";
|
|
2
|
-
import { hasMark, type ResolvedMark, resolveMark, tintClass } from "./brandMark";
|
|
2
|
+
import { hasMark, type MarkSurface, type ResolvedMark, resolveMark, tintClass } from "./brandMark";
|
|
3
3
|
|
|
4
4
|
export interface BrandLockupProps {
|
|
5
5
|
brand: Brand;
|
|
@@ -8,6 +8,15 @@ export interface BrandLockupProps {
|
|
|
8
8
|
* brand's name when they are its name in another case), then "home".
|
|
9
9
|
*/
|
|
10
10
|
ariaLabel?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The one ground the lockup sits on, for a place outside the header that
|
|
13
|
+
* only ever wears one (the light phone menu's top row): that surface's
|
|
14
|
+
* mark alone, as the footer draws its own. Left out, the header draws
|
|
15
|
+
* both and its bar shows the one for its state.
|
|
16
|
+
*/
|
|
17
|
+
surface?: MarkSurface;
|
|
18
|
+
/** Called when the link is followed, before the browser navigates. */
|
|
19
|
+
onClick?: () => void;
|
|
11
20
|
}
|
|
12
21
|
|
|
13
22
|
/**
|
|
@@ -31,9 +40,15 @@ function MarkImage({ mark, surface }: { mark: ResolvedMark; surface?: "light" |
|
|
|
31
40
|
* The header's mark: a glyph tile, or the image each surface resolves to
|
|
32
41
|
* (`resolveMark`), one per surface, each shown on its own bar by chrome.css.
|
|
33
42
|
* When both surfaces draw the same image the same way, it is drawn once.
|
|
43
|
+
* Given a `surface`, it draws that surface's image alone, for a place that
|
|
44
|
+
* only ever wears one ground (the footer's dark band).
|
|
34
45
|
*/
|
|
35
|
-
function Mark({ logo }: { logo?: BrandLogo }) {
|
|
46
|
+
function Mark({ logo, surface }: { logo?: BrandLogo; surface?: MarkSurface }) {
|
|
36
47
|
if (logo?.tile) return <LogoTile glyph={logo.tile} />;
|
|
48
|
+
if (surface) {
|
|
49
|
+
const mark = resolveMark(logo, surface);
|
|
50
|
+
return mark ? <MarkImage mark={mark} /> : null;
|
|
51
|
+
}
|
|
37
52
|
const light = resolveMark(logo, "light");
|
|
38
53
|
const dark = resolveMark(logo, "dark");
|
|
39
54
|
if (!light || !dark) return null;
|
|
@@ -57,6 +72,32 @@ export function lockupWords(name: string, logo: BrandLogo | undefined): string |
|
|
|
57
72
|
return logo?.wordmark ?? name;
|
|
58
73
|
}
|
|
59
74
|
|
|
75
|
+
/**
|
|
76
|
+
* The lockup's parts, in the order the header draws them: the mark, the
|
|
77
|
+
* live words beside it (`lockupWords`), and the trailing run. The header
|
|
78
|
+
* wraps them in its home link; the footer sets them on its dark band, passing
|
|
79
|
+
* `surface` so only that ground's image is drawn. The mark's image carries
|
|
80
|
+
* empty alt text, since the words beside it name the lockup.
|
|
81
|
+
*/
|
|
82
|
+
export function LockupParts({
|
|
83
|
+
name,
|
|
84
|
+
logo,
|
|
85
|
+
surface,
|
|
86
|
+
}: {
|
|
87
|
+
name: string;
|
|
88
|
+
logo?: BrandLogo;
|
|
89
|
+
surface?: MarkSurface;
|
|
90
|
+
}) {
|
|
91
|
+
const wordmark = lockupWords(name, logo);
|
|
92
|
+
return (
|
|
93
|
+
<>
|
|
94
|
+
<Mark logo={logo} surface={surface} />
|
|
95
|
+
{wordmark !== null && <span className="wordmark">{wordmark}</span>}
|
|
96
|
+
{logo?.run && <span className="wordmark-run" aria-hidden="true" />}
|
|
97
|
+
</>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
60
101
|
/**
|
|
61
102
|
* The header's identity as one link: the mark (a glyph tile or an image),
|
|
62
103
|
* the wordmark, and the trailing run. The image carries empty alt text
|
|
@@ -71,7 +112,7 @@ export function lockupWords(name: string, logo: BrandLogo | undefined): string |
|
|
|
71
112
|
* every child, image alt included, and it always holds the words the link
|
|
72
113
|
* shows, so what a reader sees is what a voice user can say.
|
|
73
114
|
*/
|
|
74
|
-
export function BrandLockup({ brand, ariaLabel }: BrandLockupProps) {
|
|
115
|
+
export function BrandLockup({ brand, ariaLabel, surface, onClick }: BrandLockupProps) {
|
|
75
116
|
const { name, href = "/", logo, recipient } = brand;
|
|
76
117
|
const wordmark = lockupWords(name, logo);
|
|
77
118
|
// The visible words lead the name. A wordmark that is the name in another
|
|
@@ -80,10 +121,8 @@ export function BrandLockup({ brand, ariaLabel }: BrandLockupProps) {
|
|
|
80
121
|
wordmark === null || name.toLowerCase().includes(wordmark.toLowerCase()) ? name : wordmark;
|
|
81
122
|
const label = ariaLabel ?? (recipient ? `${words} × ${recipient.alt} home` : `${words} home`);
|
|
82
123
|
return (
|
|
83
|
-
<a className="nav-logo" href={href} aria-label={label}>
|
|
84
|
-
<
|
|
85
|
-
{wordmark !== null && <span className="wordmark">{wordmark}</span>}
|
|
86
|
-
{logo?.run && <span className="wordmark-run" aria-hidden="true" />}
|
|
124
|
+
<a className="nav-logo" href={href} aria-label={label} onClick={onClick}>
|
|
125
|
+
<LockupParts name={name} logo={logo} surface={surface} />
|
|
87
126
|
{recipient && (
|
|
88
127
|
<>
|
|
89
128
|
<span className="nav-x" aria-hidden="true">
|
|
@@ -2,6 +2,7 @@ import { ChevronRight, MessageCircle, X } from "lucide-react";
|
|
|
2
2
|
import { type RefObject, useEffect, useId, useRef, useState } from "react";
|
|
3
3
|
import { useDismiss } from "../hooks/useDismiss";
|
|
4
4
|
import { newTabProps } from "../lib/newTabProps";
|
|
5
|
+
import { telText } from "../lib/phoneText";
|
|
5
6
|
import type { ContactDockConfig } from "../types";
|
|
6
7
|
import { dockIcons } from "./icons";
|
|
7
8
|
|
|
@@ -21,6 +22,13 @@ export interface ContactDockProps extends ContactDockConfig {
|
|
|
21
22
|
* `.sticky-cta`. `null` lifts over nothing.
|
|
22
23
|
*/
|
|
23
24
|
lift?: string | null;
|
|
25
|
+
/**
|
|
26
|
+
* A selector for the fixed header the launcher never rises into: as the
|
|
27
|
+
* dock lifts over a tall footer it stops just under the header's bottom
|
|
28
|
+
* edge. Defaults to the package's own header (`header.nav`); `null`
|
|
29
|
+
* reads the screen's top edge alone.
|
|
30
|
+
*/
|
|
31
|
+
header?: string | null;
|
|
24
32
|
/**
|
|
25
33
|
* Whether the dock tracks the page: it lifts over the phone's sticky bar
|
|
26
34
|
* once that bar shows, and rises above the footer. Off holds it at its
|
|
@@ -39,6 +47,9 @@ export interface ContactDockProps extends ContactDockConfig {
|
|
|
39
47
|
defaultOpen?: boolean;
|
|
40
48
|
}
|
|
41
49
|
|
|
50
|
+
/** The default header: the package's own fixed bar. */
|
|
51
|
+
const DEFAULT_HEADER = "header.nav";
|
|
52
|
+
|
|
42
53
|
/** The default lift: the package's own bar, or a site's bar of the old class. */
|
|
43
54
|
const DEFAULT_LIFT = "[data-dock-lift], .sticky-cta";
|
|
44
55
|
|
|
@@ -64,14 +75,17 @@ const LAUNCHER_HEIGHT = 52;
|
|
|
64
75
|
* The corner the dock sits in: the same inset from the right and the bottom
|
|
65
76
|
* edge (16 on a phone, 24 above), lifted over the phone's sticky bar once
|
|
66
77
|
* that bar is showing, and never over the footer: as the footer's top edge
|
|
67
|
-
* comes up the viewport, the dock rides up to stay just above it
|
|
68
|
-
*
|
|
78
|
+
* comes up the viewport, the dock rides up to stay just above it, until it
|
|
79
|
+
* reaches the fixed header: it never rises into the header, and a footer
|
|
80
|
+
* taller than the room left holds it there rather than chasing the footer.
|
|
81
|
+
* Exported for the tests; a site never calls it.
|
|
69
82
|
*/
|
|
70
83
|
export function dockPlacement({
|
|
71
84
|
viewportWidth,
|
|
72
85
|
viewportHeight,
|
|
73
86
|
barHeight,
|
|
74
87
|
avoidTop,
|
|
88
|
+
headerBottom = 0,
|
|
75
89
|
}: {
|
|
76
90
|
viewportWidth: number;
|
|
77
91
|
viewportHeight: number;
|
|
@@ -79,15 +93,19 @@ export function dockPlacement({
|
|
|
79
93
|
barHeight: number;
|
|
80
94
|
/** The avoided element's top edge in the viewport, or null when there is none. */
|
|
81
95
|
avoidTop: number | null;
|
|
96
|
+
/** The fixed header's bottom edge in the viewport, or 0 with no header. */
|
|
97
|
+
headerBottom?: number;
|
|
82
98
|
}): { inset: number; bottom: number } {
|
|
83
99
|
const phone = viewportWidth <= PHONE_MAX;
|
|
84
100
|
const inset = phone ? 16 : 24;
|
|
85
101
|
const overBar = phone && barHeight > 0 ? barHeight + inset : inset;
|
|
86
102
|
const covered = avoidTop === null ? 0 : Math.max(0, viewportHeight - avoidTop);
|
|
87
103
|
const overFooter = covered > 0 ? covered + inset : 0;
|
|
88
|
-
// Never past the top of the screen: a footer taller
|
|
89
|
-
//
|
|
90
|
-
|
|
104
|
+
// Never into the header, nor past the top of the screen: a footer taller
|
|
105
|
+
// than the room left holds the launcher just under the header (the
|
|
106
|
+
// burger's row on a phone), still reachable and covering nothing of it.
|
|
107
|
+
const top = Math.max(0, headerBottom);
|
|
108
|
+
const ceiling = Math.max(inset, viewportHeight - top - LAUNCHER_HEIGHT - inset);
|
|
91
109
|
return { inset, bottom: Math.round(Math.min(ceiling, Math.max(overBar, overFooter))) };
|
|
92
110
|
}
|
|
93
111
|
|
|
@@ -108,6 +126,7 @@ export function ContactDock({
|
|
|
108
126
|
footnote,
|
|
109
127
|
avoid = "footer",
|
|
110
128
|
lift = DEFAULT_LIFT,
|
|
129
|
+
header = DEFAULT_HEADER,
|
|
111
130
|
track = true,
|
|
112
131
|
closeLabel = "Close",
|
|
113
132
|
panelCloseLabel = "Close panel",
|
|
@@ -135,6 +154,7 @@ export function ContactDock({
|
|
|
135
154
|
// the page's elements change, never on a scroll frame.
|
|
136
155
|
let bar: HTMLElement | null = null;
|
|
137
156
|
let footer: Element | null = null;
|
|
157
|
+
let head: Element | null = null;
|
|
138
158
|
const measure = () => {
|
|
139
159
|
const showing = barShowing(bar);
|
|
140
160
|
const next = dockPlacement({
|
|
@@ -142,6 +162,7 @@ export function ContactDock({
|
|
|
142
162
|
viewportHeight: window.innerHeight,
|
|
143
163
|
barHeight: showing && bar ? bar.getBoundingClientRect().height : 0,
|
|
144
164
|
avoidTop: footer ? footer.getBoundingClientRect().top : null,
|
|
165
|
+
headerBottom: head ? head.getBoundingClientRect().bottom : 0,
|
|
145
166
|
});
|
|
146
167
|
setPlace((current) =>
|
|
147
168
|
current && current.inset === next.inset && current.bottom === next.bottom ? current : next,
|
|
@@ -158,15 +179,23 @@ export function ContactDock({
|
|
|
158
179
|
const shows =
|
|
159
180
|
typeof MutationObserver === "undefined" ? undefined : new MutationObserver(schedule);
|
|
160
181
|
const findBar = () => (lift ? document.querySelector<HTMLElement>(lift) : null);
|
|
182
|
+
const findHeader = () => (header ? document.querySelector(header) : null);
|
|
161
183
|
const findFooter = () =>
|
|
162
184
|
avoid === null
|
|
163
185
|
? null
|
|
164
186
|
: typeof avoid === "string"
|
|
165
187
|
? document.querySelector(avoid)
|
|
166
188
|
: avoid.current;
|
|
189
|
+
// A transition ending inside the header (a pill's hover, a panel's
|
|
190
|
+
// chevron) moves nothing; only the header's own counts.
|
|
191
|
+
const onHeadTransition = (event: Event) => {
|
|
192
|
+
if (event.target === head) schedule();
|
|
193
|
+
};
|
|
167
194
|
const bind = () => {
|
|
195
|
+
head?.removeEventListener("transitionend", onHeadTransition);
|
|
168
196
|
bar = findBar();
|
|
169
197
|
footer = findFooter();
|
|
198
|
+
head = findHeader();
|
|
170
199
|
sizes?.disconnect();
|
|
171
200
|
shows?.disconnect();
|
|
172
201
|
// The page's own height moves the footer (a late image, an opened
|
|
@@ -177,6 +206,13 @@ export function ContactDock({
|
|
|
177
206
|
shows?.observe(bar, { attributes: true, attributeFilter: ["data-showing", "class"] });
|
|
178
207
|
}
|
|
179
208
|
if (footer) sizes?.observe(footer);
|
|
209
|
+
// The header sets the launcher's ceiling, so a change in its size (a
|
|
210
|
+
// logo that loads late, a bar that grows) measures again, and so does
|
|
211
|
+
// the end of its own transition, which moves it without resizing it.
|
|
212
|
+
if (head) {
|
|
213
|
+
sizes?.observe(head);
|
|
214
|
+
head.addEventListener("transitionend", onHeadTransition);
|
|
215
|
+
}
|
|
180
216
|
measure();
|
|
181
217
|
};
|
|
182
218
|
// A route change swaps the footer, and a bar can mount after the dock:
|
|
@@ -186,7 +222,7 @@ export function ContactDock({
|
|
|
186
222
|
// two selectors again: the dock rebinds, observing and measuring anew,
|
|
187
223
|
// only when the bar or the footer it finds is not the one it holds.
|
|
188
224
|
const check = () => {
|
|
189
|
-
if (findBar() !== bar || findFooter() !== footer) bind();
|
|
225
|
+
if (findBar() !== bar || findFooter() !== footer || findHeader() !== head) bind();
|
|
190
226
|
};
|
|
191
227
|
// The dock's own changes (its icon swapping as it opens) never move the bar
|
|
192
228
|
// or the footer, so they are not looked at.
|
|
@@ -207,11 +243,12 @@ export function ContactDock({
|
|
|
207
243
|
cancelAnimationFrame(bound);
|
|
208
244
|
window.removeEventListener("scroll", schedule);
|
|
209
245
|
window.removeEventListener("resize", schedule);
|
|
246
|
+
head?.removeEventListener("transitionend", onHeadTransition);
|
|
210
247
|
sizes?.disconnect();
|
|
211
248
|
shows?.disconnect();
|
|
212
249
|
added?.disconnect();
|
|
213
250
|
};
|
|
214
|
-
}, [avoid, lift, track]);
|
|
251
|
+
}, [avoid, lift, header, track]);
|
|
215
252
|
|
|
216
253
|
useDismiss(open, rootRef, (reason) => {
|
|
217
254
|
setOpen(false);
|
|
@@ -250,9 +287,13 @@ export function ContactDock({
|
|
|
250
287
|
>
|
|
251
288
|
<div className="cd-head">
|
|
252
289
|
<div className="cd-head-text">
|
|
253
|
-
|
|
290
|
+
{/* A heading by role, never an h2 element: a site's heading rules
|
|
291
|
+
and the brand's heading tokens are for its page titles, not
|
|
292
|
+
this small label (Component Rules 21). */}
|
|
293
|
+
{/* biome-ignore lint/a11y/useSemanticElements: an h2 element would take a site's heading rules and tokens, see above */}
|
|
294
|
+
<div className="cd-title" id={headingId} role="heading" aria-level={2}>
|
|
254
295
|
{heading}
|
|
255
|
-
</
|
|
296
|
+
</div>
|
|
256
297
|
{subtitle && <p className="cd-sub">{subtitle}</p>}
|
|
257
298
|
</div>
|
|
258
299
|
<button
|
|
@@ -268,23 +309,28 @@ export function ContactDock({
|
|
|
268
309
|
</button>
|
|
269
310
|
</div>
|
|
270
311
|
<ul className="cd-items">
|
|
271
|
-
{items.map((item) => {
|
|
312
|
+
{items.map((item, at) => {
|
|
272
313
|
const Icon = dockIcons[item.icon ?? "chat"];
|
|
314
|
+
// A call row holds its number whole and wraps its words.
|
|
315
|
+
const words = (text: string) => telText(item.href, text);
|
|
273
316
|
const inner = (
|
|
274
317
|
<>
|
|
275
318
|
<span className="cd-item-icon">
|
|
276
319
|
<Icon size={20} aria-hidden="true" />
|
|
277
320
|
</span>
|
|
278
321
|
<span className="cd-item-text">
|
|
279
|
-
<span className="cd-item-label">{item.label}</span>
|
|
280
|
-
{item.description &&
|
|
322
|
+
<span className="cd-item-label">{words(item.label)}</span>
|
|
323
|
+
{item.description && (
|
|
324
|
+
<span className="cd-item-desc">{words(item.description)}</span>
|
|
325
|
+
)}
|
|
281
326
|
</span>
|
|
282
327
|
<ChevronRight className="cd-item-go" size={18} aria-hidden="true" />
|
|
283
328
|
</>
|
|
284
329
|
);
|
|
285
330
|
const className = ["cd-item", item.lead && "is-lead"].filter(Boolean).join(" ");
|
|
286
331
|
return (
|
|
287
|
-
|
|
332
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: two items may share a label or a link, so the place keeps the key unique; items never reorder
|
|
333
|
+
<li key={at}>
|
|
288
334
|
{item.href !== undefined ? (
|
|
289
335
|
<a
|
|
290
336
|
className={className}
|
package/src/chrome/Footer.tsx
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { Mail, Star, UserRound } from "lucide-react";
|
|
2
|
-
import type { ComponentProps,
|
|
2
|
+
import type { ComponentProps, Ref } from "react";
|
|
3
|
+
import { breakableEmail } from "../lib/emailText";
|
|
3
4
|
import { newTabProps } from "../lib/newTabProps";
|
|
4
|
-
import type {
|
|
5
|
-
|
|
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";
|
|
6
14
|
import { resolveMark, tintClass } from "./brandMark";
|
|
7
15
|
import { ClosingBar } from "./ClosingBar";
|
|
8
16
|
import { Copyright } from "./Copyright";
|
|
@@ -131,9 +139,22 @@ export interface FooterProps {
|
|
|
131
139
|
brand: Brand;
|
|
132
140
|
/**
|
|
133
141
|
* The Google rating as printed, e.g. "4.8 on Google". It sits under the
|
|
134
|
-
* 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.
|
|
135
144
|
*/
|
|
136
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;
|
|
137
158
|
/**
|
|
138
159
|
* The one address, the headquarters. Omit it for a business with no
|
|
139
160
|
* storefront, and the phone and email stand alone.
|
|
@@ -143,6 +164,14 @@ export interface FooterProps {
|
|
|
143
164
|
addressHref?: string;
|
|
144
165
|
phone?: Phone;
|
|
145
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;
|
|
146
175
|
/**
|
|
147
176
|
* The link columns beside the brand column. The default footer carries
|
|
148
177
|
* four: Company, Resources, Social, and Legal. A column with no links is
|
|
@@ -173,16 +202,22 @@ export interface FooterProps {
|
|
|
173
202
|
|
|
174
203
|
/**
|
|
175
204
|
* The site footer: a brand column (the logo, the Google rating, the address
|
|
176
|
-
* linked to the Google profile, the phone, and the email), the
|
|
177
|
-
* 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.
|
|
178
209
|
*/
|
|
179
210
|
export function Footer({
|
|
180
211
|
brand,
|
|
181
212
|
rating,
|
|
213
|
+
ratingHref,
|
|
214
|
+
ratingLabel,
|
|
182
215
|
address,
|
|
183
216
|
addressHref,
|
|
184
217
|
phone,
|
|
185
218
|
email,
|
|
219
|
+
hours,
|
|
220
|
+
hoursHeading = "Hours",
|
|
186
221
|
columns,
|
|
187
222
|
attribution,
|
|
188
223
|
note,
|
|
@@ -191,11 +226,19 @@ export function Footer({
|
|
|
191
226
|
ref,
|
|
192
227
|
}: FooterProps) {
|
|
193
228
|
const { name, logo } = brand;
|
|
194
|
-
// The footer always names the business
|
|
229
|
+
// The footer always names the business beside a glyph tile.
|
|
195
230
|
const wordmark = logo?.wordmark === false ? name : (logo?.wordmark ?? name);
|
|
196
231
|
// The band is a dark surface, resolved by the order the header uses.
|
|
197
232
|
const mark = resolveMark(logo, "dark");
|
|
198
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
|
+
);
|
|
199
242
|
const addressLines = address && (
|
|
200
243
|
<>
|
|
201
244
|
{/* A business that publishes a service area but no storefront leaves
|
|
@@ -212,10 +255,7 @@ export function Footer({
|
|
|
212
255
|
<>
|
|
213
256
|
<footer ref={ref} className="footer">
|
|
214
257
|
<div className="wrap">
|
|
215
|
-
<div
|
|
216
|
-
className="footer-grid"
|
|
217
|
-
style={{ "--footer-columns": shown.length } as CSSProperties}
|
|
218
|
-
>
|
|
258
|
+
<div className={hoursShown ? "footer-grid has-hours" : "footer-grid"}>
|
|
219
259
|
<div className="footer-brand">
|
|
220
260
|
{logo?.tile ? (
|
|
221
261
|
<p className="footer-wordmark">
|
|
@@ -223,24 +263,35 @@ export function Footer({
|
|
|
223
263
|
{wordmark}
|
|
224
264
|
{logo.run && <span className="wordmark-run" aria-hidden="true" />}
|
|
225
265
|
</p>
|
|
226
|
-
) : mark ? (
|
|
266
|
+
) : mark && lockupWords(name, logo) === null ? (
|
|
267
|
+
// Artwork that already spells the name stands alone, named by its alt.
|
|
227
268
|
<img className={tintClass(mark)} src={mark.src} alt={logo?.alt ?? name} />
|
|
228
269
|
) : (
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
)}
|
|
234
|
-
{rating && (
|
|
235
|
-
<p className="footer-rating">
|
|
236
|
-
<span className="footer-stars" aria-hidden="true">
|
|
237
|
-
{STARS.map((star) => (
|
|
238
|
-
<Star key={star} size={16} fill="currentColor" />
|
|
239
|
-
))}
|
|
240
|
-
</span>
|
|
241
|
-
{rating}
|
|
270
|
+
// The header's lockup on the dark band: the mark with the wordmark
|
|
271
|
+
// beside it, or the words alone when there is no image.
|
|
272
|
+
<p className={mark ? "footer-wordmark footer-lockup" : "footer-wordmark"}>
|
|
273
|
+
<LockupParts name={name} logo={logo} surface="dark" />
|
|
242
274
|
</p>
|
|
243
275
|
)}
|
|
276
|
+
{rating &&
|
|
277
|
+
(ratingHref ? (
|
|
278
|
+
<p className="footer-rating">
|
|
279
|
+
<a
|
|
280
|
+
className="footer-rating-link"
|
|
281
|
+
href={ratingHref}
|
|
282
|
+
aria-label={ratingLabel}
|
|
283
|
+
{...newTabProps(ratingHref, true)}
|
|
284
|
+
>
|
|
285
|
+
{stars}
|
|
286
|
+
{rating}
|
|
287
|
+
</a>
|
|
288
|
+
</p>
|
|
289
|
+
) : (
|
|
290
|
+
<p className="footer-rating">
|
|
291
|
+
{stars}
|
|
292
|
+
{rating}
|
|
293
|
+
</p>
|
|
294
|
+
))}
|
|
244
295
|
{(address || phone || email) && (
|
|
245
296
|
<address className="nap">
|
|
246
297
|
{address &&
|
|
@@ -256,10 +307,27 @@ export function Footer({
|
|
|
256
307
|
<span className="nap-address">{addressLines}</span>
|
|
257
308
|
))}
|
|
258
309
|
{phone && <a href={`tel:${phone.e164}`}>{phone.display}</a>}
|
|
259
|
-
{email && <a href={`mailto:${email}`}>{email}</a>}
|
|
310
|
+
{email && <a href={`mailto:${email}`}>{breakableEmail(email)}</a>}
|
|
260
311
|
</address>
|
|
261
312
|
)}
|
|
262
313
|
</div>
|
|
314
|
+
{hoursShown && (
|
|
315
|
+
<div className="footer-column footer-hours">
|
|
316
|
+
{/* biome-ignore lint/a11y/useSemanticElements: a heading by role, as the link columns' are (see below) */}
|
|
317
|
+
<div className="footer-heading" role="heading" aria-level={headingLevel}>
|
|
318
|
+
{hoursHeading}
|
|
319
|
+
</div>
|
|
320
|
+
<dl>
|
|
321
|
+
{hoursShown.map((row, at) => (
|
|
322
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: two rows may share a label (a split day), so the place keeps the key unique; rows never reorder
|
|
323
|
+
<div key={`${at} ${row.label}`}>
|
|
324
|
+
<dt>{row.label}</dt>
|
|
325
|
+
<dd>{row.range}</dd>
|
|
326
|
+
</div>
|
|
327
|
+
))}
|
|
328
|
+
</dl>
|
|
329
|
+
</div>
|
|
330
|
+
)}
|
|
263
331
|
{shown.map((column) => (
|
|
264
332
|
<nav key={column.heading} className="footer-column" aria-label={column.heading}>
|
|
265
333
|
{/* A heading by role rather than by element: a site's own bare
|
|
@@ -271,8 +339,9 @@ export function Footer({
|
|
|
271
339
|
<div className="footer-heading" role="heading" aria-level={headingLevel}>
|
|
272
340
|
{column.heading}
|
|
273
341
|
</div>
|
|
274
|
-
{column.links.map((link) => (
|
|
275
|
-
|
|
342
|
+
{column.links.map((link, at) => (
|
|
343
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: two links may share a label and a page, so the place keeps the key unique; links never reorder
|
|
344
|
+
<ColumnLink key={at} link={link} />
|
|
276
345
|
))}
|
|
277
346
|
</nav>
|
|
278
347
|
))}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ChevronRight } from "lucide-react";
|
|
2
2
|
import { newTabProps } from "../lib/newTabProps";
|
|
3
|
+
import { telText } from "../lib/phoneText";
|
|
3
4
|
import { Button } from "../primitives/Button";
|
|
4
5
|
import { TickList } from "../primitives/TickList";
|
|
5
6
|
import type {
|
|
@@ -111,7 +112,7 @@ function LinkColumn({
|
|
|
111
112
|
aria-current={current(linkKey(index, parent, at))}
|
|
112
113
|
{...newTabProps(link.href, link.external)}
|
|
113
114
|
>
|
|
114
|
-
{link.label}
|
|
115
|
+
{telText(link.href, link.label)}
|
|
115
116
|
<Badge text={link.badge} />
|
|
116
117
|
</a>
|
|
117
118
|
</li>
|
|
@@ -135,17 +136,19 @@ function LinkColumn({
|
|
|
135
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
|
|
136
137
|
<li key={`${at} ${link.href}`}>
|
|
137
138
|
<a
|
|
138
|
-
className="nav-mega-link"
|
|
139
|
+
className={link.quiet ? "nav-mega-link is-quiet" : "nav-mega-link"}
|
|
139
140
|
href={link.href}
|
|
140
141
|
onClick={onNavigate}
|
|
141
142
|
aria-current={current(linkKey(index, at))}
|
|
142
143
|
{...newTabProps(link.href, link.external)}
|
|
143
144
|
>
|
|
144
145
|
<span className="nav-mega-label">
|
|
145
|
-
{link.label}
|
|
146
|
+
{telText(link.href, link.label)}
|
|
146
147
|
<Badge text={link.badge} />
|
|
147
148
|
</span>
|
|
148
|
-
{link.description &&
|
|
149
|
+
{link.description && (
|
|
150
|
+
<span className="nav-mega-desc">{telText(link.href, link.description)}</span>
|
|
151
|
+
)}
|
|
149
152
|
</a>
|
|
150
153
|
{link.children && link.children.length > 0 && (
|
|
151
154
|
<ul className="nav-mega-children">{link.children.map(child(at))}</ul>
|
|
@@ -211,8 +214,10 @@ function RowsSection({
|
|
|
211
214
|
<Icon size={21} strokeWidth={1.75} aria-hidden="true" />
|
|
212
215
|
</span>
|
|
213
216
|
<span className="nav-mega-row-text">
|
|
214
|
-
<span className="nav-mega-row-label">{row.label}</span>
|
|
215
|
-
{row.description &&
|
|
217
|
+
<span className="nav-mega-row-label">{telText(row.href, row.label)}</span>
|
|
218
|
+
{row.description && (
|
|
219
|
+
<span className="nav-mega-row-desc">{telText(row.href, row.description)}</span>
|
|
220
|
+
)}
|
|
216
221
|
</span>
|
|
217
222
|
<ChevronRight className="nav-mega-row-go" size={16} aria-hidden="true" />
|
|
218
223
|
</a>
|