@atelic-action/ui 8.1.0 → 8.3.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 +117 -34
- package/dist/monitoring/server.d.ts +58 -1
- package/dist/monitoring/server.js +129 -1
- package/package.json +1 -1
- package/src/chrome/BrandLockup.tsx +12 -3
- package/src/chrome/ContactDock.tsx +16 -2
- package/src/chrome/Footer.tsx +50 -12
- package/src/chrome/NavMegaPanel.tsx +6 -12
- package/src/chrome/SiteHeader.tsx +39 -17
- package/src/chrome/SiteMenu.tsx +211 -76
- package/src/chrome/SiteShell.tsx +9 -2
- package/src/chrome/StickyCTABar.tsx +48 -20
- package/src/chrome/index.ts +3 -0
- package/src/components/DataTable.tsx +1 -1
- package/src/components/ReportCard.tsx +3 -3
- package/src/lib/hours.ts +9 -2
- package/src/lib/phoneText.tsx +9 -0
- package/src/monitoring/ErrorCatcherScript.tsx +17 -6
- package/src/monitoring/index.ts +1 -1
- package/src/monitoring/server.ts +158 -1
- package/src/primitives/Button.tsx +2 -2
- package/src/routing/index.ts +10 -32
- package/src/routing/miss.ts +14 -3
- package/src/routing/routerErrors.tsx +57 -0
- package/src/routing/staticNotFound.tsx +77 -0
- package/src/scripts/check-sentry.ts +22 -1
- package/src/sections/CalloutPanel.tsx +4 -1
- package/src/sections/ContactInfoCard.tsx +9 -2
- package/src/sections/FeatureGrid.tsx +31 -7
- package/src/sections/Hero.tsx +2 -2
- package/src/sections/HoursTable.tsx +5 -3
- package/src/sections/LocationSection.tsx +2 -2
- package/src/sections/LogoMarquee.tsx +1 -1
- package/src/sections/PricingBand.tsx +1 -1
- package/src/sections/ProcessSteps.tsx +1 -1
- package/src/sections/ReviewWall.tsx +2 -2
- package/src/sections/index.ts +1 -0
- package/src/sections/siteConfig.ts +57 -0
- package/src/styles/base.css +34 -17
- package/src/styles/chrome.css +358 -42
- package/src/styles/components.css +0 -22
- package/src/styles/defaults.css +90 -3
- package/src/styles/primitives.css +9 -3
- package/src/styles/sections.css +46 -26
- package/src/types.ts +38 -1
package/src/chrome/SiteMenu.tsx
CHANGED
|
@@ -1,18 +1,34 @@
|
|
|
1
|
-
import { ChevronDown } from "lucide-react";
|
|
1
|
+
import { ChevronDown, X } from "lucide-react";
|
|
2
2
|
import { useEffect, useId, useRef, useState } from "react";
|
|
3
3
|
import { newTabProps } from "../lib/newTabProps";
|
|
4
|
-
import {
|
|
4
|
+
import { telText } from "../lib/phoneText";
|
|
5
|
+
import { Button } from "../primitives/Button";
|
|
5
6
|
import type {
|
|
7
|
+
Brand,
|
|
6
8
|
CallToAction,
|
|
7
9
|
HeaderPhone,
|
|
8
10
|
MenuContact,
|
|
9
11
|
NavGroupChildLink,
|
|
10
12
|
NavLink,
|
|
11
13
|
NavPanelSection,
|
|
14
|
+
Phone,
|
|
15
|
+
SiteMenuSurface,
|
|
12
16
|
} from "../types";
|
|
17
|
+
import { BrandLockup } from "./BrandLockup";
|
|
13
18
|
import { NavBadge } from "./NavBadge";
|
|
14
19
|
import { isGroup, isLinkColumn, panelSections } from "./navSections";
|
|
15
20
|
|
|
21
|
+
/** A number as the menu lists it: the header's, or the contact block's one phone. */
|
|
22
|
+
type MenuPhone = Phone & { label?: string; menuLabel?: string };
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The words the menu sets with a number: its `menuLabel`, else its `label`,
|
|
26
|
+
* else "Call", which asserts nothing a business may not do (answer texts).
|
|
27
|
+
*/
|
|
28
|
+
export function menuPhoneLabel(phone: MenuPhone): string {
|
|
29
|
+
return phone.menuLabel ?? phone.label ?? "Call";
|
|
30
|
+
}
|
|
31
|
+
|
|
16
32
|
export interface SiteMenuProps {
|
|
17
33
|
/** Whether the menu is showing. The owner holds this state. */
|
|
18
34
|
open: boolean;
|
|
@@ -27,20 +43,42 @@ export interface SiteMenuProps {
|
|
|
27
43
|
* An entry with `columns` is a group, an accordion that opens one at a time.
|
|
28
44
|
*/
|
|
29
45
|
links: NavLink[];
|
|
30
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* The primary action, rendered as a standard button below the entries, in
|
|
48
|
+
* its `menuLabel` when it has one, else its `label`.
|
|
49
|
+
*/
|
|
31
50
|
primaryCTA?: CallToAction;
|
|
32
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* The phone, email, and address block at the foot of the dark sheet. The
|
|
53
|
+
* light sheet draws its one phone as a card when `phones` is empty, and
|
|
54
|
+
* leaves the email and the address out, as its design does.
|
|
55
|
+
*/
|
|
33
56
|
contact?: MenuContact;
|
|
34
57
|
/**
|
|
35
58
|
* The numbers the header shows, each a tel link at the foot with its
|
|
36
|
-
* label, in place of the contact
|
|
59
|
+
* `menuLabel`, else its `label`, else "Call", in place of the contact
|
|
60
|
+
* block's one phone.
|
|
37
61
|
*/
|
|
38
62
|
phones?: HeaderPhone[];
|
|
39
|
-
/**
|
|
63
|
+
/**
|
|
64
|
+
* The path being read, marking the matching link with aria-current and,
|
|
65
|
+
* for the eye, the 2px underline the bar marks its current entry with.
|
|
66
|
+
*/
|
|
40
67
|
currentPath?: string;
|
|
41
68
|
id?: string;
|
|
42
69
|
/** The dialog's accessible name. Defaults to "Menu". */
|
|
43
70
|
label?: string;
|
|
71
|
+
/**
|
|
72
|
+
* The sheet's look. `dark` (the default) is the full screen sheet on the
|
|
73
|
+
* dark surface. `light` sets the page's ground: the brand's lockup and a
|
|
74
|
+
* round close button across the top, the entries as rows under hairlines,
|
|
75
|
+
* and a foot on the alternate ground holding the call to action and a
|
|
76
|
+
* card per number; it shows no email and no address, which the dark
|
|
77
|
+
* sheet's contact block does. The behavior is the same on both.
|
|
78
|
+
*/
|
|
79
|
+
surface?: SiteMenuSurface;
|
|
80
|
+
/** The identity the light sheet's top row draws, linking home. */
|
|
81
|
+
brand?: Brand;
|
|
44
82
|
}
|
|
45
83
|
|
|
46
84
|
/**
|
|
@@ -48,13 +86,18 @@ export interface SiteMenuProps {
|
|
|
48
86
|
* `<dialog>`: the platform supplies Escape, focus containment, and focus
|
|
49
87
|
* return to the burger. The dialog renders closed on the server and opens
|
|
50
88
|
* only in an effect, so the menu stays safe to prerender. Page scroll holds
|
|
51
|
-
* still through chrome.css while the dialog is open
|
|
89
|
+
* still through chrome.css while the dialog is open, and the contact dock's
|
|
90
|
+
* launcher steps aside.
|
|
52
91
|
*
|
|
53
92
|
* A group is an accordion: its label is a control that opens the group's
|
|
54
93
|
* columns under it and closes whichever group was open. Every group starts
|
|
55
94
|
* closed each time the menu opens, the one holding the current page
|
|
56
95
|
* included, so the menu always opens on the short list of entries. A closed
|
|
57
96
|
* group's links stay in the HTML, `inert`.
|
|
97
|
+
*
|
|
98
|
+
* Two sheets share every behavior and differ in look alone (`surface`): the
|
|
99
|
+
* dark one, and the light one with the lockup across the top and the call to
|
|
100
|
+
* action and the numbers in a foot.
|
|
58
101
|
*/
|
|
59
102
|
export function SiteMenu({
|
|
60
103
|
open,
|
|
@@ -66,16 +109,24 @@ export function SiteMenu({
|
|
|
66
109
|
currentPath,
|
|
67
110
|
id,
|
|
68
111
|
label = "Menu",
|
|
112
|
+
surface = "dark",
|
|
113
|
+
brand,
|
|
69
114
|
}: SiteMenuProps) {
|
|
115
|
+
const light = surface === "light";
|
|
116
|
+
// The header's numbers, when there are any; an empty list is none, so the
|
|
117
|
+
// contact block's one phone stands in on either sheet.
|
|
118
|
+
const headerPhones = phones && phones.length > 0 ? phones : undefined;
|
|
70
119
|
const [openGroup, setOpenGroup] = useState<number | null>(null);
|
|
71
120
|
const groupId = useId();
|
|
72
121
|
const dialogRef = useRef<HTMLDialogElement>(null);
|
|
122
|
+
const closeRef = useRef<HTMLButtonElement>(null);
|
|
73
123
|
// Whether the owner already knows the menu is closed. Escape fires cancel
|
|
74
124
|
// and then close, and a followed link closes the dialog and notifies
|
|
75
125
|
// directly, so every path runs through reportClosed and reports once.
|
|
76
126
|
const closedRef = useRef(true);
|
|
77
127
|
// Only a plain entry wears a number, so the numbers count those alone and
|
|
78
|
-
// run 01, 02, 03 down the menu whatever groups sit between them.
|
|
128
|
+
// run 01, 02, 03 down the menu whatever groups sit between them. The light
|
|
129
|
+
// sheet sets none.
|
|
79
130
|
const numbers: number[] = [];
|
|
80
131
|
let counted = 0;
|
|
81
132
|
for (const link of links) numbers.push(isGroup(link) ? 0 : ++counted);
|
|
@@ -86,9 +137,14 @@ export function SiteMenu({
|
|
|
86
137
|
closedRef.current = !open;
|
|
87
138
|
// No group is open when the menu opens, whatever page it opens on.
|
|
88
139
|
if (open) setOpenGroup(null);
|
|
89
|
-
if (open && !dialog.open)
|
|
140
|
+
if (open && !dialog.open) {
|
|
141
|
+
dialog.showModal();
|
|
142
|
+
// The light sheet's first stop is the lockup's home link, so focus
|
|
143
|
+
// starts on its close button, where the dark sheet's already does.
|
|
144
|
+
if (light) closeRef.current?.focus();
|
|
145
|
+
}
|
|
90
146
|
if (!open && dialog.open) dialog.close();
|
|
91
|
-
}, [open]);
|
|
147
|
+
}, [open, light]);
|
|
92
148
|
|
|
93
149
|
const reportClosed = () => {
|
|
94
150
|
if (closedRef.current) return;
|
|
@@ -105,6 +161,135 @@ export function SiteMenu({
|
|
|
105
161
|
reportClosed();
|
|
106
162
|
};
|
|
107
163
|
|
|
164
|
+
// The menu's own words for the action, else the bar's.
|
|
165
|
+
const menuCTA = primaryCTA && { ...primaryCTA, label: primaryCTA.menuLabel ?? primaryCTA.label };
|
|
166
|
+
|
|
167
|
+
const closeButton = (
|
|
168
|
+
<button
|
|
169
|
+
ref={closeRef}
|
|
170
|
+
type="button"
|
|
171
|
+
className="mm-close"
|
|
172
|
+
aria-label="Close menu"
|
|
173
|
+
onClick={close}
|
|
174
|
+
>
|
|
175
|
+
{light ? (
|
|
176
|
+
<X size={20} aria-hidden="true" />
|
|
177
|
+
) : (
|
|
178
|
+
<>
|
|
179
|
+
<span />
|
|
180
|
+
<span />
|
|
181
|
+
</>
|
|
182
|
+
)}
|
|
183
|
+
</button>
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
const entries = links.map((link, i) =>
|
|
187
|
+
isGroup(link) ? (
|
|
188
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: a one page site points several entries at one page or anchor, so the place keeps the key unique; the menu never reorders
|
|
189
|
+
<div className="mm-group" key={i}>
|
|
190
|
+
<button
|
|
191
|
+
type="button"
|
|
192
|
+
className="mm-link mm-group-btn"
|
|
193
|
+
aria-expanded={openGroup === i}
|
|
194
|
+
aria-controls={`${groupId}${i}`}
|
|
195
|
+
onClick={() => setOpenGroup((current) => (current === i ? null : i))}
|
|
196
|
+
>
|
|
197
|
+
<span>{link.label}</span>
|
|
198
|
+
<ChevronDown className="mm-chevron" size={light ? 20 : 22} aria-hidden="true" />
|
|
199
|
+
</button>
|
|
200
|
+
<div
|
|
201
|
+
id={`${groupId}${i}`}
|
|
202
|
+
className={["mm-group-panel", openGroup === i && "is-open"].filter(Boolean).join(" ")}
|
|
203
|
+
inert={openGroup !== i}
|
|
204
|
+
>
|
|
205
|
+
{link.allLabel && (
|
|
206
|
+
<a
|
|
207
|
+
className="mm-group-all"
|
|
208
|
+
href={link.href}
|
|
209
|
+
onClick={close}
|
|
210
|
+
aria-current={currentPath === link.href ? "page" : undefined}
|
|
211
|
+
>
|
|
212
|
+
{link.allLabel}
|
|
213
|
+
</a>
|
|
214
|
+
)}
|
|
215
|
+
{panelSections(link).map((section, index) => (
|
|
216
|
+
<MenuSection
|
|
217
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: a group's sections never reorder while the menu is open
|
|
218
|
+
key={index}
|
|
219
|
+
section={section}
|
|
220
|
+
currentPath={currentPath}
|
|
221
|
+
onNavigate={close}
|
|
222
|
+
/>
|
|
223
|
+
))}
|
|
224
|
+
</div>
|
|
225
|
+
</div>
|
|
226
|
+
) : (
|
|
227
|
+
<a
|
|
228
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: as above, entries may share an href
|
|
229
|
+
key={i}
|
|
230
|
+
className="mm-link"
|
|
231
|
+
href={link.href}
|
|
232
|
+
onClick={close}
|
|
233
|
+
aria-current={currentPath === link.href ? "page" : undefined}
|
|
234
|
+
>
|
|
235
|
+
<span className="mm-label">{link.label}</span>
|
|
236
|
+
{!light && <span className="idx">{String(numbers[i]).padStart(2, "0")}</span>}
|
|
237
|
+
</a>
|
|
238
|
+
),
|
|
239
|
+
);
|
|
240
|
+
|
|
241
|
+
if (light) {
|
|
242
|
+
// A card per number the header shows, else the contact block's one phone.
|
|
243
|
+
const cards: MenuPhone[] = headerPhones ?? (contact?.phone ? [contact.phone] : []);
|
|
244
|
+
return (
|
|
245
|
+
<dialog
|
|
246
|
+
ref={dialogRef}
|
|
247
|
+
id={id}
|
|
248
|
+
className="mobile-menu is-light"
|
|
249
|
+
aria-label={label}
|
|
250
|
+
onCancel={reportClosed}
|
|
251
|
+
onClose={reportClosed}
|
|
252
|
+
>
|
|
253
|
+
<div className="mm-top">
|
|
254
|
+
{brand && <BrandLockup brand={brand} surface="light" onClick={close} />}
|
|
255
|
+
{closeButton}
|
|
256
|
+
</div>
|
|
257
|
+
<div className="mm-list">{entries}</div>
|
|
258
|
+
{(menuCTA || cards.length > 0) && (
|
|
259
|
+
<div className="mm-foot">
|
|
260
|
+
{menuCTA && (
|
|
261
|
+
<Button
|
|
262
|
+
size="lg"
|
|
263
|
+
className="mm-cta"
|
|
264
|
+
href={menuCTA.href}
|
|
265
|
+
newTab={menuCTA.external}
|
|
266
|
+
arrow={menuCTA.arrow}
|
|
267
|
+
onClick={close}
|
|
268
|
+
>
|
|
269
|
+
{menuCTA.label}
|
|
270
|
+
</Button>
|
|
271
|
+
)}
|
|
272
|
+
{cards.map((line) => {
|
|
273
|
+
const words = menuPhoneLabel(line);
|
|
274
|
+
return (
|
|
275
|
+
// The words and the number are one name, spaced as they read.
|
|
276
|
+
<a
|
|
277
|
+
key={line.e164}
|
|
278
|
+
className="mm-phone-card"
|
|
279
|
+
href={`tel:${line.e164}`}
|
|
280
|
+
aria-label={`${words} ${line.display}`}
|
|
281
|
+
>
|
|
282
|
+
<span className="mm-phone-label">{words}</span>
|
|
283
|
+
<span className="mm-phone-number tel-number">{line.display}</span>
|
|
284
|
+
</a>
|
|
285
|
+
);
|
|
286
|
+
})}
|
|
287
|
+
</div>
|
|
288
|
+
)}
|
|
289
|
+
</dialog>
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
|
|
108
293
|
return (
|
|
109
294
|
<dialog
|
|
110
295
|
ref={dialogRef}
|
|
@@ -114,70 +299,20 @@ export function SiteMenu({
|
|
|
114
299
|
onCancel={reportClosed}
|
|
115
300
|
onClose={reportClosed}
|
|
116
301
|
>
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
<button
|
|
126
|
-
type="button"
|
|
127
|
-
className="mm-link mm-group-btn"
|
|
128
|
-
aria-expanded={openGroup === i}
|
|
129
|
-
aria-controls={`${groupId}${i}`}
|
|
130
|
-
onClick={() => setOpenGroup((current) => (current === i ? null : i))}
|
|
131
|
-
>
|
|
132
|
-
<span>{link.label}</span>
|
|
133
|
-
<ChevronDown className="mm-chevron" size={22} aria-hidden="true" />
|
|
134
|
-
</button>
|
|
135
|
-
<div
|
|
136
|
-
id={`${groupId}${i}`}
|
|
137
|
-
className={["mm-group-panel", openGroup === i && "is-open"].filter(Boolean).join(" ")}
|
|
138
|
-
inert={openGroup !== i}
|
|
139
|
-
>
|
|
140
|
-
{link.allLabel && (
|
|
141
|
-
<a className="mm-group-all" href={link.href} onClick={close}>
|
|
142
|
-
{link.allLabel}
|
|
143
|
-
</a>
|
|
144
|
-
)}
|
|
145
|
-
{panelSections(link).map((section, index) => (
|
|
146
|
-
<MenuSection
|
|
147
|
-
// biome-ignore lint/suspicious/noArrayIndexKey: a group's sections never reorder while the menu is open
|
|
148
|
-
key={index}
|
|
149
|
-
section={section}
|
|
150
|
-
currentPath={currentPath}
|
|
151
|
-
onNavigate={close}
|
|
152
|
-
/>
|
|
153
|
-
))}
|
|
154
|
-
</div>
|
|
155
|
-
</div>
|
|
156
|
-
) : (
|
|
157
|
-
<a
|
|
158
|
-
// biome-ignore lint/suspicious/noArrayIndexKey: as above, entries may share an href
|
|
159
|
-
key={i}
|
|
160
|
-
className="mm-link"
|
|
161
|
-
href={link.href}
|
|
162
|
-
onClick={close}
|
|
163
|
-
aria-current={currentPath === link.href ? "page" : undefined}
|
|
164
|
-
>
|
|
165
|
-
<span>{link.label}</span>
|
|
166
|
-
<span className="idx">{String(numbers[i]).padStart(2, "0")}</span>
|
|
167
|
-
</a>
|
|
168
|
-
),
|
|
169
|
-
)}
|
|
170
|
-
{primaryCTA && (
|
|
171
|
-
<a
|
|
172
|
-
className="btn btn-primary btn-lg mm-cta"
|
|
173
|
-
href={primaryCTA.href}
|
|
302
|
+
{closeButton}
|
|
303
|
+
{entries}
|
|
304
|
+
{menuCTA && (
|
|
305
|
+
<Button
|
|
306
|
+
size="lg"
|
|
307
|
+
className="mm-cta"
|
|
308
|
+
href={menuCTA.href}
|
|
309
|
+
newTab={menuCTA.external}
|
|
174
310
|
onClick={close}
|
|
175
|
-
{...newTabProps(primaryCTA.href, primaryCTA.external)}
|
|
176
311
|
>
|
|
177
|
-
{
|
|
178
|
-
</
|
|
312
|
+
{menuCTA.label}
|
|
313
|
+
</Button>
|
|
179
314
|
)}
|
|
180
|
-
{(contact ||
|
|
315
|
+
{(contact || headerPhones) && <ContactBlock contact={contact ?? {}} phones={headerPhones} />}
|
|
181
316
|
</dialog>
|
|
182
317
|
);
|
|
183
318
|
}
|
|
@@ -205,19 +340,19 @@ function MenuSection({
|
|
|
205
340
|
// A child may share its parent's href, and two rows may share one, so a
|
|
206
341
|
// link is keyed by its place, never its href alone.
|
|
207
342
|
const link = (
|
|
208
|
-
item: { label: string; href: string; external?: boolean; badge?: string },
|
|
343
|
+
item: { label: string; href: string; external?: boolean; badge?: string; quiet?: boolean },
|
|
209
344
|
className: string,
|
|
210
345
|
key: string,
|
|
211
346
|
) => (
|
|
212
347
|
<a
|
|
213
348
|
key={key}
|
|
214
|
-
className={className}
|
|
349
|
+
className={item.quiet ? `${className} is-quiet` : className}
|
|
215
350
|
href={item.href}
|
|
216
351
|
onClick={onNavigate}
|
|
217
352
|
aria-current={currentPath === item.href ? "page" : undefined}
|
|
218
353
|
{...newTabProps(item.href, item.external)}
|
|
219
354
|
>
|
|
220
|
-
{
|
|
355
|
+
<span className="mm-label">{telText(item.href, item.label)}</span>
|
|
221
356
|
<Badge text={item.badge} />
|
|
222
357
|
</a>
|
|
223
358
|
);
|
|
@@ -283,7 +418,7 @@ function ContactBlock({
|
|
|
283
418
|
? phones.map((line) => (
|
|
284
419
|
<span key={line.e164}>
|
|
285
420
|
<a className="mm-contact-link" href={`tel:${line.e164}`}>
|
|
286
|
-
{line.
|
|
421
|
+
{menuPhoneLabel(line).toUpperCase()} {line.display}
|
|
287
422
|
</a>
|
|
288
423
|
<br />
|
|
289
424
|
</span>
|
|
@@ -291,7 +426,7 @@ function ContactBlock({
|
|
|
291
426
|
: phone && (
|
|
292
427
|
<>
|
|
293
428
|
<a className="mm-contact-link" href={`tel:${phone.e164}`}>
|
|
294
|
-
|
|
429
|
+
{menuPhoneLabel(phone).toUpperCase()} {phone.display}
|
|
295
430
|
</a>
|
|
296
431
|
<br />
|
|
297
432
|
</>
|
package/src/chrome/SiteShell.tsx
CHANGED
|
@@ -212,7 +212,11 @@ export function SiteShell({
|
|
|
212
212
|
? undefined
|
|
213
213
|
: site.hours?.map((row) => ({
|
|
214
214
|
label: row.labelShort,
|
|
215
|
-
range: formatHoursRange(row, {
|
|
215
|
+
range: formatHoursRange(row, {
|
|
216
|
+
short: site.footer?.hoursShort ?? true,
|
|
217
|
+
clock: site.clock,
|
|
218
|
+
meridiem: site.meridiem,
|
|
219
|
+
}),
|
|
216
220
|
}));
|
|
217
221
|
// The rating links to the Google profile: the site's own link for it, else
|
|
218
222
|
// the profile the address already links to.
|
|
@@ -242,6 +246,8 @@ export function SiteShell({
|
|
|
242
246
|
contact={{ phone: site.phone, email: site.email, address: site.address }}
|
|
243
247
|
phones={site.header?.phones}
|
|
244
248
|
menuLabel={site.menuLabel}
|
|
249
|
+
menuSurface={site.menu?.surface}
|
|
250
|
+
burger={site.menu?.burger}
|
|
245
251
|
/>
|
|
246
252
|
<main id="main" className={heroNav ? undefined : "clears-nav"}>
|
|
247
253
|
{children}
|
|
@@ -252,7 +258,7 @@ export function SiteShell({
|
|
|
252
258
|
<StickyCTABar
|
|
253
259
|
primaryCTA={stickyLink}
|
|
254
260
|
phone={site.phone}
|
|
255
|
-
fromTop={!heroNav}
|
|
261
|
+
fromTop={site.cta.stickyFromTop ?? !heroNav}
|
|
256
262
|
onSpaceChange={setBarSpace}
|
|
257
263
|
/>
|
|
258
264
|
)}
|
|
@@ -267,6 +273,7 @@ export function SiteShell({
|
|
|
267
273
|
phone={site.phone}
|
|
268
274
|
email={site.email}
|
|
269
275
|
hours={footerHours}
|
|
276
|
+
hoursPlacement={site.footer?.hoursPlacement}
|
|
270
277
|
columns={footerColumns}
|
|
271
278
|
attribution={site.attribution}
|
|
272
279
|
note={site.footer?.note}
|
|
@@ -25,7 +25,11 @@ export interface StickyCTABarProps {
|
|
|
25
25
|
* measured height while it shows, and 0 while it is hidden (scrolled
|
|
26
26
|
* above its threshold, or on a desktop, where the stylesheet hides it).
|
|
27
27
|
* `SiteShell` pads the page's closing bar by it, so the copyright and the
|
|
28
|
-
* credit are never under the bar.
|
|
28
|
+
* credit are never under the bar. A listener swapped in is told the
|
|
29
|
+
* current height at once and the one it replaced gets 0; no listener
|
|
30
|
+
* hears one value twice. A listener made anew each render that sets state
|
|
31
|
+
* should store a plain number (or be memoized): each new function hears
|
|
32
|
+
* the height once, and a state equal to it stops the renders.
|
|
29
33
|
*/
|
|
30
34
|
onSpaceChange?: (pixels: number) => void;
|
|
31
35
|
}
|
|
@@ -42,11 +46,20 @@ export function StickyCTABar({
|
|
|
42
46
|
const [show, setShow] = useState(fromTop);
|
|
43
47
|
const barRef = useRef<HTMLDivElement>(null);
|
|
44
48
|
// 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
|
-
//
|
|
49
|
+
// never restarts the measuring below. Whether there is one at all does: a
|
|
50
|
+
// listener supplied after mount starts the measuring then.
|
|
47
51
|
const spaceRef = useRef(onSpaceChange);
|
|
48
52
|
spaceRef.current = onSpaceChange;
|
|
49
53
|
const listening = onSpaceChange !== undefined;
|
|
54
|
+
// The height last measured (-1 before any, and after the bar goes), and
|
|
55
|
+
// what each listener was last told: no listener hears one value twice.
|
|
56
|
+
const heightRef = useRef(-1);
|
|
57
|
+
const toldRef = useRef(new WeakMap<(pixels: number) => void, number>());
|
|
58
|
+
const tell = (listener: ((pixels: number) => void) | undefined, pixels: number) => {
|
|
59
|
+
if (!listener || toldRef.current.get(listener) === pixels) return;
|
|
60
|
+
toldRef.current.set(listener, pixels);
|
|
61
|
+
listener(pixels);
|
|
62
|
+
};
|
|
50
63
|
|
|
51
64
|
useEffect(() => {
|
|
52
65
|
if (fromTop) {
|
|
@@ -62,24 +75,14 @@ export function StickyCTABar({
|
|
|
62
75
|
// The bar's real height while it shows, measured again whenever it changes
|
|
63
76
|
// size (a phone turned, a font loading, a label wrapping), never assumed.
|
|
64
77
|
// Hidden by the stylesheet its height reads 0, so a desktop reserves nothing.
|
|
78
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: tell reads only refs
|
|
65
79
|
useEffect(() => {
|
|
66
80
|
const bar = barRef.current;
|
|
67
81
|
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
82
|
const report = () => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
+
heightRef.current = show ? bar.offsetHeight : 0;
|
|
84
|
+
arrivalsRef.current = 0;
|
|
85
|
+
tell(spaceRef.current, heightRef.current);
|
|
83
86
|
};
|
|
84
87
|
report();
|
|
85
88
|
const sizes = typeof ResizeObserver === "undefined" ? undefined : new ResizeObserver(report);
|
|
@@ -88,12 +91,37 @@ export function StickyCTABar({
|
|
|
88
91
|
return () => {
|
|
89
92
|
sizes?.disconnect();
|
|
90
93
|
window.removeEventListener("resize", report);
|
|
91
|
-
// A final 0 on unmount, on hiding, and when the listener goes,
|
|
92
|
-
//
|
|
93
|
-
|
|
94
|
+
// A final 0 on unmount, on hiding, and when the listener goes, so no
|
|
95
|
+
// foot padding outlives the bar.
|
|
96
|
+
heightRef.current = -1;
|
|
97
|
+
tell(spaceRef.current, 0);
|
|
94
98
|
};
|
|
95
99
|
}, [show, listening]);
|
|
96
100
|
|
|
101
|
+
// A listener swapped in is told the current height, and the one it
|
|
102
|
+
// replaced gets 0, unless either already heard that value. A function made
|
|
103
|
+
// anew each render (an inline listener) hears the height once a function
|
|
104
|
+
// until the caller's state settles; a stable listener hears nothing here.
|
|
105
|
+
const previousRef = useRef(onSpaceChange);
|
|
106
|
+
// Arrivals told since the bar last measured. A listener that sets object
|
|
107
|
+
// state is a new function on every render its own call causes, which no
|
|
108
|
+
// test of identity tells from a real swap; past three arrivals in a row
|
|
109
|
+
// with nothing measured between, the rest wait for the next measure, so
|
|
110
|
+
// such a listener cannot loop. Three real swaps in a row are all told.
|
|
111
|
+
const arrivalsRef = useRef(0);
|
|
112
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: the listener is the trigger; tell reads only refs
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
const previous = previousRef.current;
|
|
115
|
+
previousRef.current = onSpaceChange;
|
|
116
|
+
if (previous === onSpaceChange) return;
|
|
117
|
+
if (onSpaceChange && arrivalsRef.current >= 3) return;
|
|
118
|
+
arrivalsRef.current += 1;
|
|
119
|
+
// The outgoing one gives its space back, the bar measured or not (a
|
|
120
|
+
// listener taken away leaves the measuring off by now).
|
|
121
|
+
tell(previous, 0);
|
|
122
|
+
if (heightRef.current >= 0) tell(onSpaceChange, heightRef.current);
|
|
123
|
+
}, [onSpaceChange]);
|
|
124
|
+
|
|
97
125
|
return (
|
|
98
126
|
// Inert while offscreen, so its links take no keyboard focus before it slides in.
|
|
99
127
|
// data-dock-lift and data-showing tell the contact dock to ride above it.
|
package/src/chrome/index.ts
CHANGED
|
@@ -9,9 +9,11 @@ export type {
|
|
|
9
9
|
ContactDockItem,
|
|
10
10
|
FooterColumn,
|
|
11
11
|
FooterColumnLink,
|
|
12
|
+
FooterHoursPlacement,
|
|
12
13
|
FooterIcon,
|
|
13
14
|
HeaderPhone,
|
|
14
15
|
HoursRow,
|
|
16
|
+
MenuBurgerStyle,
|
|
15
17
|
MenuContact,
|
|
16
18
|
NavCard,
|
|
17
19
|
NavCardsSection,
|
|
@@ -28,6 +30,7 @@ export type {
|
|
|
28
30
|
Phone,
|
|
29
31
|
PostalAddress,
|
|
30
32
|
SiteLink,
|
|
33
|
+
SiteMenuSurface,
|
|
31
34
|
SocialLink,
|
|
32
35
|
} from "../types";
|
|
33
36
|
export { BrandLockup, type BrandLockupProps } from "./BrandLockup";
|
|
@@ -234,7 +234,7 @@ export function DataTable({
|
|
|
234
234
|
const body = isEmpty(cell, c) ? (
|
|
235
235
|
<>
|
|
236
236
|
<span className="data-table-empty" aria-hidden="true" />
|
|
237
|
-
<span className="data-table-empty-label">
|
|
237
|
+
<span className="data-table-empty-label visually-hidden">
|
|
238
238
|
{columns[c]?.emptyLabel ?? "None"}
|
|
239
239
|
</span>
|
|
240
240
|
</>
|
|
@@ -119,7 +119,7 @@ export function ReportCard({
|
|
|
119
119
|
<span className="rc-grade">
|
|
120
120
|
{row.before && (
|
|
121
121
|
<span className="rc-before">
|
|
122
|
-
<span className="rc-sr">{`${labels.before}: ${gradeLabel[row.before]}. `}</span>
|
|
122
|
+
<span className="rc-sr visually-hidden">{`${labels.before}: ${gradeLabel[row.before]}. `}</span>
|
|
123
123
|
<span aria-hidden="true">
|
|
124
124
|
<GradeChip grade={row.before} />
|
|
125
125
|
</span>
|
|
@@ -127,14 +127,14 @@ export function ReportCard({
|
|
|
127
127
|
)}
|
|
128
128
|
{row.grade ? (
|
|
129
129
|
<>
|
|
130
|
-
<span className="rc-sr">{`${labels.grade} ${gradeLabel[row.grade]}: `}</span>
|
|
130
|
+
<span className="rc-sr visually-hidden">{`${labels.grade} ${gradeLabel[row.grade]}: `}</span>
|
|
131
131
|
<span aria-hidden="true">
|
|
132
132
|
<GradeChip grade={row.grade} />
|
|
133
133
|
</span>
|
|
134
134
|
</>
|
|
135
135
|
) : (
|
|
136
136
|
<>
|
|
137
|
-
<span className="rc-sr">{`${labels.notGraded}: `}</span>
|
|
137
|
+
<span className="rc-sr visually-hidden">{`${labels.notGraded}: `}</span>
|
|
138
138
|
<span className="rc-dash" aria-hidden="true" />
|
|
139
139
|
</>
|
|
140
140
|
)}
|
package/src/lib/hours.ts
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import type { Clock, OpeningHours } from "../sections/siteConfig";
|
|
1
|
+
import type { Clock, Meridiem, OpeningHours } from "../sections/siteConfig";
|
|
2
2
|
|
|
3
3
|
/** How a time prints: `short` drops a whole hour's minutes on the 12 hour clock. */
|
|
4
4
|
export interface ClockOptions {
|
|
5
5
|
short?: boolean;
|
|
6
6
|
/** "12h" (the default) or "24h"; see `SiteConfig.clock`. */
|
|
7
7
|
clock?: Clock;
|
|
8
|
+
/** "letter" (the default, "9a") or "word" ("9 am"); see `SiteConfig.meridiem`. */
|
|
9
|
+
meridiem?: Meridiem;
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* Formats a 24 hour "HH:MM" time as the display style used across the
|
|
12
14
|
* marketing components: "11:00" -> "11:00a", "19:00" -> "7:00p".
|
|
13
15
|
* With short: true, whole hours drop their minutes: "11a", "7p".
|
|
16
|
+
* With meridiem: "word", the mark is a word after a no break space:
|
|
17
|
+
* "11:00 am", "7 pm" short.
|
|
14
18
|
* With clock: "24h", the time prints as "HH:MM" with a leading zero
|
|
15
19
|
* ("09:00", "17:00") and short changes nothing.
|
|
16
20
|
*/
|
|
@@ -18,7 +22,10 @@ export function formatClock(time: string, opts: ClockOptions = {}): string {
|
|
|
18
22
|
const [hourStr, minuteStr = "00"] = time.split(":");
|
|
19
23
|
const hour24 = Number(hourStr);
|
|
20
24
|
if (opts.clock === "24h") return `${String(hour24 % 24).padStart(2, "0")}:${minuteStr}`;
|
|
21
|
-
const
|
|
25
|
+
const afternoon = hour24 % 24 >= 12;
|
|
26
|
+
// A word joins with a no break space, so "5:00 pm" never breaks before its mark.
|
|
27
|
+
const word = afternoon ? "\u00a0pm" : "\u00a0am";
|
|
28
|
+
const suffix = opts.meridiem === "word" ? word : afternoon ? "p" : "a";
|
|
22
29
|
const hour = hour24 % 12 || 12;
|
|
23
30
|
if (opts.short && minuteStr === "00") return `${hour}${suffix}`;
|
|
24
31
|
return `${hour}:${minuteStr}${suffix}`;
|
package/src/lib/phoneText.tsx
CHANGED
|
@@ -38,3 +38,12 @@ export function holdPhoneNumbers(content: ReactNode): ReactNode {
|
|
|
38
38
|
</span>
|
|
39
39
|
);
|
|
40
40
|
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The words of a link, with any phone number in them held whole when the
|
|
44
|
+
* link calls (`holdPhoneNumbers` on a `tel:` href), and as given otherwise.
|
|
45
|
+
* The one way a component sets a link's words that may hold a number.
|
|
46
|
+
*/
|
|
47
|
+
export function telText(href: string | undefined, content: ReactNode): ReactNode {
|
|
48
|
+
return isTel(href) ? holdPhoneNumbers(content) : content;
|
|
49
|
+
}
|