@atelic-action/ui 8.0.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 +135 -14
- 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 +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 +35 -5
- package/src/chrome/ContactDock.tsx +45 -13
- package/src/chrome/Footer.tsx +97 -25
- package/src/chrome/NavMegaPanel.tsx +17 -6
- package/src/chrome/SiteHeader.tsx +35 -7
- package/src/chrome/SiteMenu.tsx +6 -3
- package/src/chrome/SiteShell.tsx +22 -2
- package/src/chrome/StickyCTABar.tsx +12 -8
- 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 +40 -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 +3 -1
- package/src/primitives/Eyebrow.tsx +6 -2
- 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/FullBleedVideo.tsx +13 -4
- package/src/sections/Hero.tsx +8 -1
- package/src/sections/LinkColumns.tsx +30 -14
- package/src/sections/Locations.tsx +1 -1
- package/src/sections/siteConfig.ts +35 -5
- package/src/styles/app.css +9 -0
- package/src/styles/base.css +26 -0
- package/src/styles/chrome.css +218 -28
- package/src/styles/defaults.css +5 -2
- package/src/styles/primitives.css +11 -4
- package/src/styles/sections.css +26 -3
- package/src/types.ts +8 -1
- package/src/vite/index.ts +4 -0
- package/src/vite/marketing-config.ts +81 -1
package/src/chrome/Footer.tsx
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { Mail, Star, UserRound } from "lucide-react";
|
|
2
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
|
-
|
|
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
|
|
@@ -213,8 +256,8 @@ export function Footer({
|
|
|
213
256
|
<footer ref={ref} className="footer">
|
|
214
257
|
<div className="wrap">
|
|
215
258
|
<div
|
|
216
|
-
className="footer-grid"
|
|
217
|
-
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}
|
|
218
261
|
>
|
|
219
262
|
<div className="footer-brand">
|
|
220
263
|
{logo?.tile ? (
|
|
@@ -223,24 +266,35 @@ export function Footer({
|
|
|
223
266
|
{wordmark}
|
|
224
267
|
{logo.run && <span className="wordmark-run" aria-hidden="true" />}
|
|
225
268
|
</p>
|
|
226
|
-
) : mark ? (
|
|
269
|
+
) : mark && lockupWords(name, logo) === null ? (
|
|
270
|
+
// Artwork that already spells the name stands alone, named by its alt.
|
|
227
271
|
<img className={tintClass(mark)} src={mark.src} alt={logo?.alt ?? name} />
|
|
228
272
|
) : (
|
|
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}
|
|
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" />
|
|
242
277
|
</p>
|
|
243
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
|
+
))}
|
|
244
298
|
{(address || phone || email) && (
|
|
245
299
|
<address className="nap">
|
|
246
300
|
{address &&
|
|
@@ -256,10 +310,27 @@ export function Footer({
|
|
|
256
310
|
<span className="nap-address">{addressLines}</span>
|
|
257
311
|
))}
|
|
258
312
|
{phone && <a href={`tel:${phone.e164}`}>{phone.display}</a>}
|
|
259
|
-
{email && <a href={`mailto:${email}`}>{email}</a>}
|
|
313
|
+
{email && <a href={`mailto:${email}`}>{breakableEmail(email)}</a>}
|
|
260
314
|
</address>
|
|
261
315
|
)}
|
|
262
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
|
+
)}
|
|
263
334
|
{shown.map((column) => (
|
|
264
335
|
<nav key={column.heading} className="footer-column" aria-label={column.heading}>
|
|
265
336
|
{/* A heading by role rather than by element: a site's own bare
|
|
@@ -271,8 +342,9 @@ export function Footer({
|
|
|
271
342
|
<div className="footer-heading" role="heading" aria-level={headingLevel}>
|
|
272
343
|
{column.heading}
|
|
273
344
|
</div>
|
|
274
|
-
{column.links.map((link) => (
|
|
275
|
-
|
|
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} />
|
|
276
348
|
))}
|
|
277
349
|
</nav>
|
|
278
350
|
))}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ChevronRight } from "lucide-react";
|
|
2
2
|
import { newTabProps } from "../lib/newTabProps";
|
|
3
|
+
import { holdPhoneNumbers, isTel } 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
|
+
{isTel(link.href) ? holdPhoneNumbers(link.label) : link.label}
|
|
115
116
|
<Badge text={link.badge} />
|
|
116
117
|
</a>
|
|
117
118
|
</li>
|
|
@@ -135,17 +136,21 @@ 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
|
+
{isTel(link.href) ? holdPhoneNumbers(link.label) : link.label}
|
|
146
147
|
<Badge text={link.badge} />
|
|
147
148
|
</span>
|
|
148
|
-
{link.description &&
|
|
149
|
+
{link.description && (
|
|
150
|
+
<span className="nav-mega-desc">
|
|
151
|
+
{isTel(link.href) ? holdPhoneNumbers(link.description) : link.description}
|
|
152
|
+
</span>
|
|
153
|
+
)}
|
|
149
154
|
</a>
|
|
150
155
|
{link.children && link.children.length > 0 && (
|
|
151
156
|
<ul className="nav-mega-children">{link.children.map(child(at))}</ul>
|
|
@@ -211,8 +216,14 @@ function RowsSection({
|
|
|
211
216
|
<Icon size={21} strokeWidth={1.75} aria-hidden="true" />
|
|
212
217
|
</span>
|
|
213
218
|
<span className="nav-mega-row-text">
|
|
214
|
-
<span className="nav-mega-row-label">
|
|
215
|
-
|
|
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
|
+
)}
|
|
216
227
|
</span>
|
|
217
228
|
<ChevronRight className="nav-mega-row-go" size={16} aria-hidden="true" />
|
|
218
229
|
</a>
|
|
@@ -53,6 +53,11 @@ export interface SiteHeaderProps {
|
|
|
53
53
|
* first as a call button beside the burger on a phone. A third is dropped.
|
|
54
54
|
*/
|
|
55
55
|
phones?: HeaderPhone[];
|
|
56
|
+
/**
|
|
57
|
+
* Words shown beside the burger, e.g. "Menu", which also name it. Absent,
|
|
58
|
+
* the burger is its three lines alone, named "Open menu" or "Close menu".
|
|
59
|
+
*/
|
|
60
|
+
menuLabel?: string;
|
|
56
61
|
}
|
|
57
62
|
|
|
58
63
|
/** The keys that move focus along the bar and down into an open panel. */
|
|
@@ -102,6 +107,7 @@ export function SiteHeader({
|
|
|
102
107
|
hideCTA = false,
|
|
103
108
|
contact,
|
|
104
109
|
phones,
|
|
110
|
+
menuLabel,
|
|
105
111
|
}: SiteHeaderProps) {
|
|
106
112
|
const [scrolled, setScrolled] = useState(false);
|
|
107
113
|
const [menuOpen, setMenuOpen] = useState(false);
|
|
@@ -232,7 +238,8 @@ export function SiteHeader({
|
|
|
232
238
|
>
|
|
233
239
|
{links.map((link, index) =>
|
|
234
240
|
isGroup(link) ? (
|
|
235
|
-
|
|
241
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: a one page site points several entries at one page or anchor, so the place keeps the key unique; the bar never reorders
|
|
242
|
+
<div className="nav-item" key={index}>
|
|
236
243
|
<button
|
|
237
244
|
type="button"
|
|
238
245
|
id={`${baseId}g${index}`}
|
|
@@ -282,7 +289,8 @@ export function SiteHeader({
|
|
|
282
289
|
</div>
|
|
283
290
|
) : (
|
|
284
291
|
<a
|
|
285
|
-
|
|
292
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: as above, entries may share an href
|
|
293
|
+
key={index}
|
|
286
294
|
href={link.href}
|
|
287
295
|
aria-current={currentPath === link.href ? "page" : undefined}
|
|
288
296
|
onPointerEnter={(event) => {
|
|
@@ -324,6 +332,11 @@ export function SiteHeader({
|
|
|
324
332
|
{...newTabProps(barCTA.href, barCTA.external)}
|
|
325
333
|
>
|
|
326
334
|
{barCTA.label}
|
|
335
|
+
{barCTA.arrow && (
|
|
336
|
+
<span className="arrow" aria-hidden="true">
|
|
337
|
+
→
|
|
338
|
+
</span>
|
|
339
|
+
)}
|
|
327
340
|
</a>
|
|
328
341
|
</span>
|
|
329
342
|
)}
|
|
@@ -339,15 +352,30 @@ export function SiteHeader({
|
|
|
339
352
|
{hasMenu && (
|
|
340
353
|
<button
|
|
341
354
|
type="button"
|
|
342
|
-
className="nav-burger"
|
|
343
|
-
|
|
355
|
+
className={menuLabel ? "nav-burger has-label" : "nav-burger"}
|
|
356
|
+
// Words beside the burger name it, so the name holds what a reader
|
|
357
|
+
// sees; the open state is aria-expanded's to say.
|
|
358
|
+
aria-label={menuLabel ? undefined : menuOpen ? "Close menu" : "Open menu"}
|
|
344
359
|
aria-expanded={menuOpen}
|
|
345
360
|
aria-controls={menuId}
|
|
346
361
|
onClick={() => setMenuOpen((open) => !open)}
|
|
347
362
|
>
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
363
|
+
{menuLabel ? (
|
|
364
|
+
<>
|
|
365
|
+
<span className="nav-burger-label">{menuLabel}</span>
|
|
366
|
+
<span className="nav-burger-lines" aria-hidden="true">
|
|
367
|
+
<span />
|
|
368
|
+
<span />
|
|
369
|
+
<span />
|
|
370
|
+
</span>
|
|
371
|
+
</>
|
|
372
|
+
) : (
|
|
373
|
+
<>
|
|
374
|
+
<span />
|
|
375
|
+
<span />
|
|
376
|
+
<span />
|
|
377
|
+
</>
|
|
378
|
+
)}
|
|
351
379
|
</button>
|
|
352
380
|
)}
|
|
353
381
|
</div>
|
package/src/chrome/SiteMenu.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ChevronDown } from "lucide-react";
|
|
2
2
|
import { useEffect, useId, useRef, useState } from "react";
|
|
3
3
|
import { newTabProps } from "../lib/newTabProps";
|
|
4
|
+
import { holdPhoneNumbers, isTel } from "../lib/phoneText";
|
|
4
5
|
import type {
|
|
5
6
|
CallToAction,
|
|
6
7
|
HeaderPhone,
|
|
@@ -119,7 +120,8 @@ export function SiteMenu({
|
|
|
119
120
|
</button>
|
|
120
121
|
{links.map((link, i) =>
|
|
121
122
|
isGroup(link) ? (
|
|
122
|
-
|
|
123
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: a one page site points several entries at one page or anchor, so the place keeps the key unique; the menu never reorders
|
|
124
|
+
<div className="mm-group" key={i}>
|
|
123
125
|
<button
|
|
124
126
|
type="button"
|
|
125
127
|
className="mm-link mm-group-btn"
|
|
@@ -153,7 +155,8 @@ export function SiteMenu({
|
|
|
153
155
|
</div>
|
|
154
156
|
) : (
|
|
155
157
|
<a
|
|
156
|
-
|
|
158
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: as above, entries may share an href
|
|
159
|
+
key={i}
|
|
157
160
|
className="mm-link"
|
|
158
161
|
href={link.href}
|
|
159
162
|
onClick={close}
|
|
@@ -214,7 +217,7 @@ function MenuSection({
|
|
|
214
217
|
aria-current={currentPath === item.href ? "page" : undefined}
|
|
215
218
|
{...newTabProps(item.href, item.external)}
|
|
216
219
|
>
|
|
217
|
-
{item.label}
|
|
220
|
+
{isTel(item.href) ? holdPhoneNumbers(item.label) : item.label}
|
|
218
221
|
<Badge text={item.badge} />
|
|
219
222
|
</a>
|
|
220
223
|
);
|
package/src/chrome/SiteShell.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ReactNode, useCallback, useRef } from "react";
|
|
2
2
|
import { Watermark } from "../components/Watermark";
|
|
3
3
|
import type { PageStop } from "../hooks/useScrollSpy";
|
|
4
|
+
import { formatHoursRange } from "../lib/hours";
|
|
4
5
|
import { BasePathProvider } from "../routing/BasePathProvider";
|
|
5
6
|
import { joinBase, normalizeBasePath, stripBase } from "../routing/basePath";
|
|
6
7
|
import type { Density, NavItem, SiteConfig } from "../sections/siteConfig";
|
|
@@ -140,6 +141,8 @@ export function SiteShell({
|
|
|
140
141
|
else root.style.removeProperty("--sticky-cta-space");
|
|
141
142
|
}, []);
|
|
142
143
|
const cta = { ...site.cta, href: withBase(site.cta.href) };
|
|
144
|
+
// The phone's sticky bar may carry its own words (`cta.stickyLabel`).
|
|
145
|
+
const stickyLink = { ...cta, label: site.cta.stickyLabel ?? cta.label };
|
|
143
146
|
// Every link and picture a panel section holds, based.
|
|
144
147
|
const section = (part: NavPanelSection): NavPanelSection => {
|
|
145
148
|
if (isLinkColumn(part)) {
|
|
@@ -202,6 +205,19 @@ export function SiteShell({
|
|
|
202
205
|
},
|
|
203
206
|
{ heading: "Legal", links: based(site.legalLinks) ?? [] },
|
|
204
207
|
];
|
|
208
|
+
// The footer's hours, formatted as the footer prints them, unless the site
|
|
209
|
+
// keeps them out; the config's hours still feed its structured data.
|
|
210
|
+
const footerHours =
|
|
211
|
+
site.footer?.showHours === false
|
|
212
|
+
? undefined
|
|
213
|
+
: site.hours?.map((row) => ({
|
|
214
|
+
label: row.labelShort,
|
|
215
|
+
range: formatHoursRange(row, { short: true, clock: site.clock }),
|
|
216
|
+
}));
|
|
217
|
+
// The rating links to the Google profile: the site's own link for it, else
|
|
218
|
+
// the profile the address already links to.
|
|
219
|
+
const rating = site.footer?.rating;
|
|
220
|
+
const ratingHref = rating ? (site.footer?.ratingHref ?? site.mapLinkURL) : undefined;
|
|
205
221
|
// The header takes one variant. A hero page wins over a dark one: the bar
|
|
206
222
|
// sits transparent over the hero either way, and only its scrolled state
|
|
207
223
|
// differed.
|
|
@@ -225,6 +241,7 @@ export function SiteShell({
|
|
|
225
241
|
hideCTA={hideNavCTA}
|
|
226
242
|
contact={{ phone: site.phone, email: site.email, address: site.address }}
|
|
227
243
|
phones={site.header?.phones}
|
|
244
|
+
menuLabel={site.menuLabel}
|
|
228
245
|
/>
|
|
229
246
|
<main id="main" className={heroNav ? undefined : "clears-nav"}>
|
|
230
247
|
{children}
|
|
@@ -233,7 +250,7 @@ export function SiteShell({
|
|
|
233
250
|
the bar is there from the top; the hero home page keeps the slide in. */}
|
|
234
251
|
{stickyCTA && (
|
|
235
252
|
<StickyCTABar
|
|
236
|
-
primaryCTA={
|
|
253
|
+
primaryCTA={stickyLink}
|
|
237
254
|
phone={site.phone}
|
|
238
255
|
fromTop={!heroNav}
|
|
239
256
|
onSpaceChange={setBarSpace}
|
|
@@ -242,11 +259,14 @@ export function SiteShell({
|
|
|
242
259
|
{footer ? (
|
|
243
260
|
<Footer
|
|
244
261
|
brand={brand}
|
|
245
|
-
rating={
|
|
262
|
+
rating={rating}
|
|
263
|
+
ratingHref={ratingHref}
|
|
264
|
+
ratingLabel={site.footer?.ratingLabel}
|
|
246
265
|
address={site.footer?.showAddress === false ? undefined : site.address}
|
|
247
266
|
addressHref={site.mapLinkURL}
|
|
248
267
|
phone={site.phone}
|
|
249
268
|
email={site.email}
|
|
269
|
+
hours={footerHours}
|
|
250
270
|
columns={footerColumns}
|
|
251
271
|
attribution={site.attribution}
|
|
252
272
|
note={site.footer?.note}
|
|
@@ -66,15 +66,19 @@ export function StickyCTABar({
|
|
|
66
66
|
const bar = barRef.current;
|
|
67
67
|
if (!bar || !listening) return;
|
|
68
68
|
let last = -1;
|
|
69
|
-
// The listener last told a height
|
|
70
|
-
//
|
|
71
|
-
//
|
|
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
72
|
let heard: ((pixels: number) => void) | undefined;
|
|
73
73
|
const report = () => {
|
|
74
74
|
const next = show ? bar.offsetHeight : 0;
|
|
75
|
-
|
|
75
|
+
const listener = spaceRef.current;
|
|
76
|
+
if (next === last && listener === heard) return;
|
|
77
|
+
// A caller swapped listeners since the last report: the old one
|
|
78
|
+
// gives its space back before the new one is told the height.
|
|
79
|
+
if (heard && heard !== listener) heard(0);
|
|
76
80
|
last = next;
|
|
77
|
-
heard =
|
|
81
|
+
heard = listener;
|
|
78
82
|
heard?.(next);
|
|
79
83
|
};
|
|
80
84
|
report();
|
|
@@ -84,9 +88,9 @@ export function StickyCTABar({
|
|
|
84
88
|
return () => {
|
|
85
89
|
sizes?.disconnect();
|
|
86
90
|
window.removeEventListener("resize", report);
|
|
87
|
-
// A final 0 on unmount, on hiding, and when the listener goes,
|
|
88
|
-
// foot padding outlives the bar.
|
|
89
|
-
|
|
91
|
+
// A final 0 on unmount, on hiding, and when the listener goes, to the
|
|
92
|
+
// listener that holds the space, so no foot padding outlives the bar.
|
|
93
|
+
heard?.(0);
|
|
90
94
|
};
|
|
91
95
|
}, [show, listening]);
|
|
92
96
|
|
|
@@ -54,8 +54,9 @@ export function NotFound({
|
|
|
54
54
|
<div className="wrap center">
|
|
55
55
|
<span className="eyebrow center">{linksLabel}</span>
|
|
56
56
|
<nav aria-label={linksLabel} className="cta-row center">
|
|
57
|
-
{links.map((link) => (
|
|
58
|
-
|
|
57
|
+
{links.map((link, at) => (
|
|
58
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: two links may share a page, so the place keeps the key unique; links never reorder
|
|
59
|
+
<a key={at} className="btn btn-ghost" href={link.href}>
|
|
59
60
|
{link.label}
|
|
60
61
|
</a>
|
|
61
62
|
))}
|
package/src/gate/middleware.ts
CHANGED
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
* open file of its own passes `open`; one whose matcher already leaves its
|
|
30
30
|
* open paths out may still pass its own `needsSession`, which wins over both.
|
|
31
31
|
*/
|
|
32
|
+
import { reportServerError } from "../monitoring/server.js";
|
|
32
33
|
import { isAllowed } from "./config.js";
|
|
33
34
|
import { verifyToken } from "./tokens.js";
|
|
34
35
|
import { createNeedsSession, type WallOpenings } from "./wall.js";
|
|
@@ -53,7 +54,7 @@ function readCookie(header: string, name: string): string | undefined {
|
|
|
53
54
|
export function createMiddleware(options: MiddlewareOptions = {}) {
|
|
54
55
|
const needsSession = options.needsSession ?? createNeedsSession(options.open);
|
|
55
56
|
|
|
56
|
-
|
|
57
|
+
async function decide(request: Request): Promise<Response | undefined> {
|
|
57
58
|
const secret = process.env.GATE_SESSION_SECRET;
|
|
58
59
|
if (!secret) return; // gate off, let everything through
|
|
59
60
|
|
|
@@ -69,6 +70,19 @@ export function createMiddleware(options: MiddlewareOptions = {}) {
|
|
|
69
70
|
const login = new URL("/login", url.origin);
|
|
70
71
|
login.searchParams.set("next", url.pathname + url.search);
|
|
71
72
|
return Response.redirect(login.toString(), 302);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// A throw is reported to Sentry (when a DSN is set) and thrown again, so
|
|
76
|
+
// the request fails exactly as it did; a pass and a block are untouched.
|
|
77
|
+
// The expected misses (a malformed cookie, a token that fails to verify)
|
|
78
|
+
// are answers, not errors, and stay quiet.
|
|
79
|
+
return async function middleware(request: Request): Promise<Response | undefined> {
|
|
80
|
+
try {
|
|
81
|
+
return await decide(request);
|
|
82
|
+
} catch (error) {
|
|
83
|
+
await reportServerError(error, { request, tags: { source: "middleware" } });
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
72
86
|
};
|
|
73
87
|
}
|
|
74
88
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Fragment, type ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* An email address with its break opportunities marked: after the @ and
|
|
5
|
+
* before each dot of the domain, so a narrow column wraps it there and
|
|
6
|
+
* never inside a word ("hello@" / "kestrelhollow" / ".example.com"). The
|
|
7
|
+
* words read and copy exactly as the address.
|
|
8
|
+
*/
|
|
9
|
+
export function breakableEmail(email: string): ReactNode {
|
|
10
|
+
const at = email.indexOf("@");
|
|
11
|
+
if (at === -1) return email;
|
|
12
|
+
const [first, ...rest] = email.slice(at + 1).split(".");
|
|
13
|
+
return (
|
|
14
|
+
<>
|
|
15
|
+
{email.slice(0, at + 1)}
|
|
16
|
+
<wbr />
|
|
17
|
+
{first}
|
|
18
|
+
{rest.map((part, index) => (
|
|
19
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: the parts of one address never reorder
|
|
20
|
+
<Fragment key={index}>
|
|
21
|
+
<wbr />.{part}
|
|
22
|
+
</Fragment>
|
|
23
|
+
))}
|
|
24
|
+
</>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
/** A run that reads as a phone number: seven digits or more, with the usual separators. */
|
|
4
|
+
const PHONE = /(\+?\(?\d[\d\s().-]{5,}\d)/;
|
|
5
|
+
|
|
6
|
+
/** Whether a link calls: a `tel:` href. */
|
|
7
|
+
export function isTel(href: string | undefined): boolean {
|
|
8
|
+
return href?.startsWith("tel:") ?? false;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Wraps each phone number in a run of words in `.tel-number`, which never
|
|
13
|
+
* breaks, so a call link holding more than the number (a dock row's label
|
|
14
|
+
* and line, a menu row) wraps its words and holds its number whole.
|
|
15
|
+
* Anything that is not a string passes through as it is.
|
|
16
|
+
*
|
|
17
|
+
* The run comes back inside one plain inline span, so a flex parent (a
|
|
18
|
+
* button, a row) sees the words as the one item a bare string was: split
|
|
19
|
+
* into separate items, the space before the number was dropped at an
|
|
20
|
+
* item's edge and the parent's gap stood in its place, wider than a space.
|
|
21
|
+
*/
|
|
22
|
+
export function holdPhoneNumbers(content: ReactNode): ReactNode {
|
|
23
|
+
if (typeof content !== "string") return content;
|
|
24
|
+
const parts = content.split(PHONE);
|
|
25
|
+
if (parts.length === 1) return content;
|
|
26
|
+
return (
|
|
27
|
+
<span>
|
|
28
|
+
{parts.map((part, at) =>
|
|
29
|
+
at % 2 === 1 && (part.match(/\d/g)?.length ?? 0) >= 7 ? (
|
|
30
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: the runs of one string never reorder
|
|
31
|
+
<span key={at} className="tel-number">
|
|
32
|
+
{part}
|
|
33
|
+
</span>
|
|
34
|
+
) : (
|
|
35
|
+
part
|
|
36
|
+
),
|
|
37
|
+
)}
|
|
38
|
+
</span>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { errorCatcherScript } from "./catcher";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The inline early catcher as an element, for the first place in a root
|
|
5
|
+
* route's `<head>`, ahead of `<HeadContent />`: it runs before any other
|
|
6
|
+
* script, so an error thrown before the app's own JavaScript is held until
|
|
7
|
+
* `startErrorReporting` hands it to Sentry. It is a few hundred bytes, well
|
|
8
|
+
* inside the first kilobyte a browser scans for the charset.
|
|
9
|
+
*/
|
|
10
|
+
export function ErrorCatcherScript() {
|
|
11
|
+
return (
|
|
12
|
+
// biome-ignore lint/security/noDangerouslySetInnerHtml: the package's own constant script, no outside input
|
|
13
|
+
<script dangerouslySetInnerHTML={{ __html: errorCatcherScript }} />
|
|
14
|
+
);
|
|
15
|
+
}
|