@atelic-action/ui 7.1.0 → 8.0.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 +313 -127
- package/package.json +14 -10
- package/src/app/ErrorFallback.tsx +6 -2
- package/src/app/context/AppContext.tsx +10 -1
- package/src/app/index.ts +0 -1
- package/src/app/layout/AppPage.tsx +36 -7
- package/src/app/layout/DesktopRail.tsx +9 -2
- package/src/app/layout/MobileMenu.tsx +5 -1
- package/src/app/layout/PageError.tsx +6 -3
- package/src/app/layout/PageSkeleton.tsx +33 -26
- package/src/app/layout/UserMenu.tsx +12 -6
- package/src/app/ui/alert.tsx +41 -11
- package/src/app/ui/badge.tsx +1 -1
- package/src/app/ui/button.tsx +2 -1
- package/src/app/ui/command.tsx +86 -21
- package/src/app/ui/country-dropdown.tsx +26 -47
- package/src/app/ui/form.tsx +46 -7
- package/src/app/ui/pagination.tsx +1 -1
- package/src/app/ui/progress.tsx +26 -12
- package/src/app/ui/search-input.tsx +16 -3
- package/src/app/ui/select.tsx +8 -3
- package/src/app/ui/slider.tsx +62 -15
- package/src/artifact/ArtifactShell.tsx +8 -3
- package/src/artifact/ErrorFallback.tsx +8 -1
- package/src/artifact/artifactConfig.ts +1 -1
- package/src/chrome/BrandLockup.tsx +71 -16
- package/src/chrome/ClosingBar.tsx +8 -5
- package/src/chrome/ContactDock.tsx +329 -0
- package/src/chrome/Footer.tsx +32 -9
- package/src/chrome/NavBadge.tsx +8 -0
- package/src/chrome/NavMegaPanel.tsx +388 -0
- package/src/chrome/SiteHeader.tsx +235 -18
- package/src/chrome/SiteMenu.tsx +197 -19
- package/src/chrome/SiteShell.tsx +130 -13
- package/src/chrome/StickyCTABar.tsx +56 -2
- package/src/chrome/brandMark.ts +56 -0
- package/src/chrome/icons.ts +58 -0
- package/src/chrome/index.ts +16 -0
- package/src/chrome/navSections.ts +55 -0
- package/src/components/ColumnChart.tsx +27 -2
- package/src/components/DataTable.tsx +104 -85
- package/src/components/Disclosure.tsx +3 -1
- package/src/components/Hint.tsx +3 -24
- package/src/components/NotFound.tsx +4 -1
- package/src/components/StarRating.tsx +45 -19
- package/src/components/ThresholdScale.tsx +36 -26
- package/src/email/atoms.tsx +13 -57
- package/src/email/frame.tsx +4 -6
- package/src/email/index.ts +4 -10
- package/src/email/scoreboard.tsx +107 -186
- package/src/email/text.ts +30 -0
- package/src/email/theme.tsx +76 -9
- package/src/hooks/useDismiss.ts +39 -0
- package/src/lib/useScrollsSideways.ts +26 -0
- package/src/primitives/Button.tsx +2 -0
- package/src/primitives/ProseBlocks.tsx +6 -1
- package/src/primitives/SectionHeading.tsx +3 -1
- package/src/primitives/StarRow.tsx +23 -8
- package/src/sections/BlogIndex.tsx +17 -3
- package/src/sections/BlogPost.tsx +10 -1
- package/src/sections/CTASection.tsx +2 -2
- package/src/sections/CalloutPanel.tsx +34 -0
- package/src/sections/ComparisonTable.tsx +23 -2
- package/src/sections/ContactForm.tsx +61 -17
- package/src/sections/FAQBrowser.tsx +11 -2
- package/src/sections/FeatureGrid.tsx +6 -2
- package/src/sections/FullBleedVideo.tsx +158 -0
- package/src/sections/Gallery.tsx +6 -4
- package/src/sections/Hero.tsx +63 -39
- package/src/sections/JumpRail.tsx +7 -0
- package/src/sections/LegalPage.tsx +10 -2
- package/src/sections/LinkColumns.tsx +64 -0
- package/src/sections/LocationSection.tsx +28 -5
- package/src/sections/Locations.tsx +17 -4
- package/src/sections/LogoMarquee.tsx +43 -11
- package/src/sections/MapEmbed.tsx +13 -9
- package/src/sections/PageHero.tsx +16 -2
- package/src/sections/ProcessSteps.tsx +27 -4
- package/src/sections/ProfileCards.tsx +12 -2
- package/src/sections/ProofStrip.tsx +44 -0
- package/src/sections/RevealSlider.tsx +28 -7
- package/src/sections/ReviewCarousel.tsx +17 -4
- package/src/sections/ReviewWall.tsx +2 -2
- package/src/sections/SplitSection.tsx +2 -1
- package/src/sections/index.ts +15 -6
- package/src/sections/siteConfig.ts +66 -3
- package/src/styles/app.css +24 -2
- package/src/styles/artifact.css +20 -8
- package/src/styles/base.css +42 -13
- package/src/styles/chrome.css +938 -48
- package/src/styles/components.css +104 -65
- package/src/styles/defaults.css +137 -0
- package/src/styles/gate.css +21 -10
- package/src/styles/primitives.css +97 -35
- package/src/styles/sections.css +477 -437
- package/src/styles/star-rating.css +1 -4
- package/src/tokens/palettes.ts +24 -4
- package/src/types.ts +212 -2
- package/src/app/CardErrorBoundary.tsx +0 -39
- package/src/sections/CTABanner.tsx +0 -93
- package/src/sections/DeviceShowcase.tsx +0 -39
- package/src/sections/MediaBand.tsx +0 -20
- package/src/sections/MenuList.tsx +0 -44
- package/src/sections/PressQuotes.tsx +0 -51
- package/src/sections/SocialStrip.tsx +0 -83
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
1
|
+
import type { ReactNode, Ref } from "react";
|
|
2
2
|
import { Copyright } from "./Copyright";
|
|
3
3
|
import { Credit } from "./Credit";
|
|
4
4
|
|
|
@@ -15,16 +15,19 @@ export interface ClosingBarProps {
|
|
|
15
15
|
* it; anything else renders as given.
|
|
16
16
|
*/
|
|
17
17
|
right?: ReactNode;
|
|
18
|
+
/** The bar's element, for a caller that measures it. */
|
|
19
|
+
ref?: Ref<HTMLDivElement>;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
/**
|
|
21
23
|
* The line that closes every page: two sides, each taking anything. By
|
|
22
24
|
* default the left is the copyright with the business's name and the right is
|
|
23
25
|
* the practice's credit. Footer renders it at its foot, and a page with no
|
|
24
|
-
* footer
|
|
25
|
-
*
|
|
26
|
+
* footer renders it on its own (ArtifactShell passes the sender's name, so a
|
|
27
|
+
* sent document closes the way a site does); with nothing on the left, the
|
|
28
|
+
* right side sits centered.
|
|
26
29
|
*/
|
|
27
|
-
export function ClosingBar({ name, left, right }: ClosingBarProps) {
|
|
30
|
+
export function ClosingBar({ name, left, right, ref }: ClosingBarProps) {
|
|
28
31
|
const leftSide = left === undefined ? name ? <Copyright name={name} /> : null : left;
|
|
29
32
|
const rightSide = right === undefined ? <Credit /> : right;
|
|
30
33
|
const hasLeft = leftSide !== null && leftSide !== false;
|
|
@@ -32,7 +35,7 @@ export function ClosingBar({ name, left, right }: ClosingBarProps) {
|
|
|
32
35
|
if (!hasLeft && !hasRight) return null;
|
|
33
36
|
|
|
34
37
|
return (
|
|
35
|
-
<div className={hasLeft ? "closing-bar" : "closing-bar is-solo"}>
|
|
38
|
+
<div ref={ref} className={hasLeft ? "closing-bar" : "closing-bar is-solo"}>
|
|
36
39
|
<div className="wrap closing-bar-line">
|
|
37
40
|
{hasLeft && <div className="closing-bar-left">{leftSide}</div>}
|
|
38
41
|
{hasRight && <div className="closing-bar-right">{rightSide}</div>}
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import { ChevronRight, MessageCircle, X } from "lucide-react";
|
|
2
|
+
import { type RefObject, useEffect, useId, useRef, useState } from "react";
|
|
3
|
+
import { useDismiss } from "../hooks/useDismiss";
|
|
4
|
+
import { newTabProps } from "../lib/newTabProps";
|
|
5
|
+
import type { ContactDockConfig } from "../types";
|
|
6
|
+
import { dockIcons } from "./icons";
|
|
7
|
+
|
|
8
|
+
export interface ContactDockProps extends ContactDockConfig {
|
|
9
|
+
/**
|
|
10
|
+
* The element the dock never covers: as it scrolls into view the dock
|
|
11
|
+
* rides up to sit just above its top edge. A ref to it, or a selector;
|
|
12
|
+
* defaults to the page's `footer`, and `null` avoids nothing.
|
|
13
|
+
*/
|
|
14
|
+
avoid?: string | RefObject<Element | null> | null;
|
|
15
|
+
/**
|
|
16
|
+
* A selector for the bar the dock lifts over while that bar shows. The
|
|
17
|
+
* bar says it is showing with `data-showing="true"`, or, for a bar that
|
|
18
|
+
* sets no `data-showing`, with the `show` class the sticky bar wore before
|
|
19
|
+
* 8.0.0. `StickyCTABar` wears `data-dock-lift` and keeps `data-showing`
|
|
20
|
+
* current; the default finds it, or failing that a site's own
|
|
21
|
+
* `.sticky-cta`. `null` lifts over nothing.
|
|
22
|
+
*/
|
|
23
|
+
lift?: string | null;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the dock tracks the page: it lifts over the phone's sticky bar
|
|
26
|
+
* once that bar shows, and rises above the footer. Off holds it at its
|
|
27
|
+
* corner inset (a preview frame). Defaults on.
|
|
28
|
+
*/
|
|
29
|
+
track?: boolean;
|
|
30
|
+
/** The launcher's words while the panel is open. Defaults to "Close". */
|
|
31
|
+
closeLabel?: string;
|
|
32
|
+
/**
|
|
33
|
+
* The accessible name of the close button in the panel's head, kept apart
|
|
34
|
+
* from the launcher's so the two controls never share a name. Defaults to
|
|
35
|
+
* "Close panel".
|
|
36
|
+
*/
|
|
37
|
+
panelCloseLabel?: string;
|
|
38
|
+
/** Start with the panel open (a preview of the open state). */
|
|
39
|
+
defaultOpen?: boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** The default lift: the package's own bar, or a site's bar of the old class. */
|
|
43
|
+
const DEFAULT_LIFT = "[data-dock-lift], .sticky-cta";
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Whether the bar the dock lifts over is showing: its `data-showing` when it
|
|
47
|
+
* keeps one, else the `show` class, and never while the stylesheet hides it
|
|
48
|
+
* (a desktop). Exported for the tests; a site never calls it.
|
|
49
|
+
*/
|
|
50
|
+
export function barShowing(bar: HTMLElement | null): boolean {
|
|
51
|
+
if (!bar) return false;
|
|
52
|
+
const flag = bar.dataset.showing;
|
|
53
|
+
const shown = flag === undefined ? bar.classList.contains("show") : flag === "true";
|
|
54
|
+
return shown && getComputedStyle(bar).display !== "none";
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Where the phone layout starts, the sticky bar's own breakpoint. */
|
|
58
|
+
const PHONE_MAX = 899;
|
|
59
|
+
|
|
60
|
+
/** The launcher's height, matching `.cd-launch`. */
|
|
61
|
+
const LAUNCHER_HEIGHT = 52;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The corner the dock sits in: the same inset from the right and the bottom
|
|
65
|
+
* edge (16 on a phone, 24 above), lifted over the phone's sticky bar once
|
|
66
|
+
* 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. Exported
|
|
68
|
+
* for the tests; a site never calls it.
|
|
69
|
+
*/
|
|
70
|
+
export function dockPlacement({
|
|
71
|
+
viewportWidth,
|
|
72
|
+
viewportHeight,
|
|
73
|
+
barHeight,
|
|
74
|
+
avoidTop,
|
|
75
|
+
}: {
|
|
76
|
+
viewportWidth: number;
|
|
77
|
+
viewportHeight: number;
|
|
78
|
+
/** The sticky bar's height when it is showing, else 0. */
|
|
79
|
+
barHeight: number;
|
|
80
|
+
/** The avoided element's top edge in the viewport, or null when there is none. */
|
|
81
|
+
avoidTop: number | null;
|
|
82
|
+
}): { inset: number; bottom: number } {
|
|
83
|
+
const phone = viewportWidth <= PHONE_MAX;
|
|
84
|
+
const inset = phone ? 16 : 24;
|
|
85
|
+
const overBar = phone && barHeight > 0 ? barHeight + inset : inset;
|
|
86
|
+
const covered = avoidTop === null ? 0 : Math.max(0, viewportHeight - avoidTop);
|
|
87
|
+
const overFooter = covered > 0 ? covered + inset : 0;
|
|
88
|
+
// Never past the top of the screen: a footer taller than the viewport
|
|
89
|
+
// leaves the launcher at the top edge, still reachable.
|
|
90
|
+
const ceiling = Math.max(inset, viewportHeight - LAUNCHER_HEIGHT - inset);
|
|
91
|
+
return { inset, bottom: Math.round(Math.min(ceiling, Math.max(overBar, overFooter))) };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* A floating launcher in the page's corner that opens a small panel of the
|
|
96
|
+
* ways to reach the business: a chat, a call, a form, each an item passed as
|
|
97
|
+
* data. The open state lives in React state; every measurement runs in an
|
|
98
|
+
* effect, so it prerenders closed and at its default inset. The panel stays
|
|
99
|
+
* in the HTML while closed, `inert`. Escape and a click outside close it.
|
|
100
|
+
* On a phone the launcher is its icon alone and the panel is a sheet across
|
|
101
|
+
* the bottom of the screen.
|
|
102
|
+
*/
|
|
103
|
+
export function ContactDock({
|
|
104
|
+
label,
|
|
105
|
+
title,
|
|
106
|
+
subtitle,
|
|
107
|
+
items,
|
|
108
|
+
footnote,
|
|
109
|
+
avoid = "footer",
|
|
110
|
+
lift = DEFAULT_LIFT,
|
|
111
|
+
track = true,
|
|
112
|
+
closeLabel = "Close",
|
|
113
|
+
panelCloseLabel = "Close panel",
|
|
114
|
+
defaultOpen = false,
|
|
115
|
+
}: ContactDockProps) {
|
|
116
|
+
const [open, setOpen] = useState(defaultOpen);
|
|
117
|
+
// Unmeasured, the dock sits at the corner chrome.css gives it for the
|
|
118
|
+
// viewport; tracking sets its place inline once it has measured.
|
|
119
|
+
const [place, setPlace] = useState<{ inset: number; bottom: number } | null>(null);
|
|
120
|
+
const rootRef = useRef<HTMLDivElement>(null);
|
|
121
|
+
const launchRef = useRef<HTMLButtonElement>(null);
|
|
122
|
+
const panelRef = useRef<HTMLElement>(null);
|
|
123
|
+
const opened = useRef(defaultOpen);
|
|
124
|
+
const panelId = useId();
|
|
125
|
+
const headingId = `${panelId}h`;
|
|
126
|
+
|
|
127
|
+
useEffect(() => {
|
|
128
|
+
if (!track) {
|
|
129
|
+
setPlace(null);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
let frame = 0;
|
|
133
|
+
let bound = 0;
|
|
134
|
+
// The bar and the avoided element are found once and again only when
|
|
135
|
+
// the page's elements change, never on a scroll frame.
|
|
136
|
+
let bar: HTMLElement | null = null;
|
|
137
|
+
let footer: Element | null = null;
|
|
138
|
+
const measure = () => {
|
|
139
|
+
const showing = barShowing(bar);
|
|
140
|
+
const next = dockPlacement({
|
|
141
|
+
viewportWidth: window.innerWidth,
|
|
142
|
+
viewportHeight: window.innerHeight,
|
|
143
|
+
barHeight: showing && bar ? bar.getBoundingClientRect().height : 0,
|
|
144
|
+
avoidTop: footer ? footer.getBoundingClientRect().top : null,
|
|
145
|
+
});
|
|
146
|
+
setPlace((current) =>
|
|
147
|
+
current && current.inset === next.inset && current.bottom === next.bottom ? current : next,
|
|
148
|
+
);
|
|
149
|
+
};
|
|
150
|
+
// Read after the frame, so the sticky bar's own scroll handler has rendered.
|
|
151
|
+
const schedule = () => {
|
|
152
|
+
cancelAnimationFrame(frame);
|
|
153
|
+
frame = requestAnimationFrame(measure);
|
|
154
|
+
};
|
|
155
|
+
const sizes = typeof ResizeObserver === "undefined" ? undefined : new ResizeObserver(schedule);
|
|
156
|
+
// The bar slides in on an attribute change no scroll may follow (a bar
|
|
157
|
+
// shown from the top), so its own element is watched as well.
|
|
158
|
+
const shows =
|
|
159
|
+
typeof MutationObserver === "undefined" ? undefined : new MutationObserver(schedule);
|
|
160
|
+
const findBar = () => (lift ? document.querySelector<HTMLElement>(lift) : null);
|
|
161
|
+
const findFooter = () =>
|
|
162
|
+
avoid === null
|
|
163
|
+
? null
|
|
164
|
+
: typeof avoid === "string"
|
|
165
|
+
? document.querySelector(avoid)
|
|
166
|
+
: avoid.current;
|
|
167
|
+
const bind = () => {
|
|
168
|
+
bar = findBar();
|
|
169
|
+
footer = findFooter();
|
|
170
|
+
sizes?.disconnect();
|
|
171
|
+
shows?.disconnect();
|
|
172
|
+
// The page's own height moves the footer (a late image, an opened
|
|
173
|
+
// fold), and the bar and the footer can change size themselves.
|
|
174
|
+
sizes?.observe(document.body);
|
|
175
|
+
if (bar) {
|
|
176
|
+
sizes?.observe(bar);
|
|
177
|
+
shows?.observe(bar, { attributes: true, attributeFilter: ["data-showing", "class"] });
|
|
178
|
+
}
|
|
179
|
+
if (footer) sizes?.observe(footer);
|
|
180
|
+
measure();
|
|
181
|
+
};
|
|
182
|
+
// A route change swaps the footer, and a bar can mount after the dock:
|
|
183
|
+
// either is an element added or removed. The page's other changes (a
|
|
184
|
+
// carousel stepping, a form's message) add elements too, so a frame's
|
|
185
|
+
// worth of them is gathered into one look, and that look only asks the
|
|
186
|
+
// two selectors again: the dock rebinds, observing and measuring anew,
|
|
187
|
+
// only when the bar or the footer it finds is not the one it holds.
|
|
188
|
+
const check = () => {
|
|
189
|
+
if (findBar() !== bar || findFooter() !== footer) bind();
|
|
190
|
+
};
|
|
191
|
+
// The dock's own changes (its icon swapping as it opens) never move the bar
|
|
192
|
+
// or the footer, so they are not looked at.
|
|
193
|
+
const rebind = (records: MutationRecord[]) => {
|
|
194
|
+
const own = rootRef.current;
|
|
195
|
+
if (own && records.every((record) => own.contains(record.target))) return;
|
|
196
|
+
cancelAnimationFrame(bound);
|
|
197
|
+
bound = requestAnimationFrame(check);
|
|
198
|
+
};
|
|
199
|
+
const added =
|
|
200
|
+
typeof MutationObserver === "undefined" ? undefined : new MutationObserver(rebind);
|
|
201
|
+
added?.observe(document.body, { childList: true, subtree: true });
|
|
202
|
+
window.addEventListener("scroll", schedule, { passive: true });
|
|
203
|
+
window.addEventListener("resize", schedule);
|
|
204
|
+
bind();
|
|
205
|
+
return () => {
|
|
206
|
+
cancelAnimationFrame(frame);
|
|
207
|
+
cancelAnimationFrame(bound);
|
|
208
|
+
window.removeEventListener("scroll", schedule);
|
|
209
|
+
window.removeEventListener("resize", schedule);
|
|
210
|
+
sizes?.disconnect();
|
|
211
|
+
shows?.disconnect();
|
|
212
|
+
added?.disconnect();
|
|
213
|
+
};
|
|
214
|
+
}, [avoid, lift, track]);
|
|
215
|
+
|
|
216
|
+
useDismiss(open, rootRef, (reason) => {
|
|
217
|
+
setOpen(false);
|
|
218
|
+
if (reason === "escape") launchRef.current?.focus();
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
// The panel sits before the launcher in the DOM (it opens upward), so Tab
|
|
222
|
+
// from the launcher would skip it: opening by hand moves focus in.
|
|
223
|
+
useEffect(() => {
|
|
224
|
+
if (!open) return;
|
|
225
|
+
if (!opened.current) panelRef.current?.querySelector<HTMLElement>(".cd-close")?.focus();
|
|
226
|
+
opened.current = true;
|
|
227
|
+
return () => {
|
|
228
|
+
opened.current = false;
|
|
229
|
+
};
|
|
230
|
+
}, [open]);
|
|
231
|
+
|
|
232
|
+
const heading = title ?? label;
|
|
233
|
+
|
|
234
|
+
return (
|
|
235
|
+
<div
|
|
236
|
+
ref={rootRef}
|
|
237
|
+
className={["contact-dock", open && "is-open"].filter(Boolean).join(" ")}
|
|
238
|
+
// While open the dock sits in the corner: the phone's panel is a sheet that
|
|
239
|
+
// reserves room for the launcher there, and a desktop panel opens upward
|
|
240
|
+
// and would run off the top if the dock were riding above the footer.
|
|
241
|
+
style={place ? { right: place.inset, bottom: open ? place.inset : place.bottom } : undefined}
|
|
242
|
+
>
|
|
243
|
+
<section
|
|
244
|
+
ref={panelRef}
|
|
245
|
+
id={panelId}
|
|
246
|
+
className="cd-panel"
|
|
247
|
+
aria-labelledby={headingId}
|
|
248
|
+
inert={!open}
|
|
249
|
+
hidden={!open}
|
|
250
|
+
>
|
|
251
|
+
<div className="cd-head">
|
|
252
|
+
<div className="cd-head-text">
|
|
253
|
+
<h2 className="cd-title" id={headingId}>
|
|
254
|
+
{heading}
|
|
255
|
+
</h2>
|
|
256
|
+
{subtitle && <p className="cd-sub">{subtitle}</p>}
|
|
257
|
+
</div>
|
|
258
|
+
<button
|
|
259
|
+
type="button"
|
|
260
|
+
className="cd-close"
|
|
261
|
+
aria-label={panelCloseLabel}
|
|
262
|
+
onClick={() => {
|
|
263
|
+
setOpen(false);
|
|
264
|
+
launchRef.current?.focus();
|
|
265
|
+
}}
|
|
266
|
+
>
|
|
267
|
+
<X size={20} aria-hidden="true" />
|
|
268
|
+
</button>
|
|
269
|
+
</div>
|
|
270
|
+
<ul className="cd-items">
|
|
271
|
+
{items.map((item) => {
|
|
272
|
+
const Icon = dockIcons[item.icon ?? "chat"];
|
|
273
|
+
const inner = (
|
|
274
|
+
<>
|
|
275
|
+
<span className="cd-item-icon">
|
|
276
|
+
<Icon size={20} aria-hidden="true" />
|
|
277
|
+
</span>
|
|
278
|
+
<span className="cd-item-text">
|
|
279
|
+
<span className="cd-item-label">{item.label}</span>
|
|
280
|
+
{item.description && <span className="cd-item-desc">{item.description}</span>}
|
|
281
|
+
</span>
|
|
282
|
+
<ChevronRight className="cd-item-go" size={18} aria-hidden="true" />
|
|
283
|
+
</>
|
|
284
|
+
);
|
|
285
|
+
const className = ["cd-item", item.lead && "is-lead"].filter(Boolean).join(" ");
|
|
286
|
+
return (
|
|
287
|
+
<li key={item.label}>
|
|
288
|
+
{item.href !== undefined ? (
|
|
289
|
+
<a
|
|
290
|
+
className={className}
|
|
291
|
+
href={item.href}
|
|
292
|
+
onClick={() => setOpen(false)}
|
|
293
|
+
{...newTabProps(item.href, item.external)}
|
|
294
|
+
>
|
|
295
|
+
{inner}
|
|
296
|
+
</a>
|
|
297
|
+
) : (
|
|
298
|
+
<button
|
|
299
|
+
type="button"
|
|
300
|
+
className={className}
|
|
301
|
+
onClick={() => {
|
|
302
|
+
setOpen(false);
|
|
303
|
+
item.onSelect?.();
|
|
304
|
+
}}
|
|
305
|
+
>
|
|
306
|
+
{inner}
|
|
307
|
+
</button>
|
|
308
|
+
)}
|
|
309
|
+
</li>
|
|
310
|
+
);
|
|
311
|
+
})}
|
|
312
|
+
</ul>
|
|
313
|
+
{footnote && <p className="cd-foot">{footnote}</p>}
|
|
314
|
+
</section>
|
|
315
|
+
<button
|
|
316
|
+
ref={launchRef}
|
|
317
|
+
type="button"
|
|
318
|
+
className="cd-launch"
|
|
319
|
+
aria-expanded={open}
|
|
320
|
+
aria-controls={panelId}
|
|
321
|
+
onClick={() => setOpen((current) => !current)}
|
|
322
|
+
>
|
|
323
|
+
{open ? <X size={22} aria-hidden="true" /> : <MessageCircle size={22} aria-hidden="true" />}
|
|
324
|
+
{/* Visually hidden on a phone, where the launcher is its icon, and still its name. */}
|
|
325
|
+
<span className="cd-launch-text">{open ? closeLabel : label}</span>
|
|
326
|
+
</button>
|
|
327
|
+
</div>
|
|
328
|
+
);
|
|
329
|
+
}
|
package/src/chrome/Footer.tsx
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Mail, Star, UserRound } from "lucide-react";
|
|
2
|
-
import type { ComponentProps, CSSProperties } from "react";
|
|
2
|
+
import type { ComponentProps, CSSProperties, Ref } from "react";
|
|
3
3
|
import { newTabProps } from "../lib/newTabProps";
|
|
4
4
|
import type { Brand, FooterColumn, FooterColumnLink, Phone, PostalAddress } from "../types";
|
|
5
|
+
import { LogoTile } from "./BrandLockup";
|
|
6
|
+
import { resolveMark, tintClass } from "./brandMark";
|
|
5
7
|
import { ClosingBar } from "./ClosingBar";
|
|
6
8
|
import { Copyright } from "./Copyright";
|
|
7
9
|
|
|
@@ -157,6 +159,16 @@ export interface FooterProps {
|
|
|
157
159
|
* prints either way.
|
|
158
160
|
*/
|
|
159
161
|
credit?: boolean;
|
|
162
|
+
/**
|
|
163
|
+
* The level of the link columns' headings. Defaults to 2: the footer is a
|
|
164
|
+
* landmark beside the page's main content, so its sections sit one level
|
|
165
|
+
* under the page's `h1` whatever the page's own outline ends on, and a
|
|
166
|
+
* page never skips a level into its footer. A site whose footer sits
|
|
167
|
+
* inside a deeper outline passes its own.
|
|
168
|
+
*/
|
|
169
|
+
headingLevel?: 2 | 3 | 4 | 5 | 6;
|
|
170
|
+
/** The footer element, for a caller that measures it (`SiteShell` hands it to the contact dock). */
|
|
171
|
+
ref?: Ref<HTMLElement>;
|
|
160
172
|
}
|
|
161
173
|
|
|
162
174
|
/**
|
|
@@ -175,9 +187,14 @@ export function Footer({
|
|
|
175
187
|
attribution,
|
|
176
188
|
note,
|
|
177
189
|
credit = true,
|
|
190
|
+
headingLevel = 2,
|
|
191
|
+
ref,
|
|
178
192
|
}: FooterProps) {
|
|
179
193
|
const { name, logo } = brand;
|
|
180
|
-
|
|
194
|
+
// The footer always names the business when it draws no image.
|
|
195
|
+
const wordmark = logo?.wordmark === false ? name : (logo?.wordmark ?? name);
|
|
196
|
+
// The band is a dark surface, resolved by the order the header uses.
|
|
197
|
+
const mark = resolveMark(logo, "dark");
|
|
181
198
|
const shown = (columns ?? []).filter((column) => column.links.length > 0);
|
|
182
199
|
const addressLines = address && (
|
|
183
200
|
<>
|
|
@@ -193,7 +210,7 @@ export function Footer({
|
|
|
193
210
|
|
|
194
211
|
return (
|
|
195
212
|
<>
|
|
196
|
-
<footer className="footer">
|
|
213
|
+
<footer ref={ref} className="footer">
|
|
197
214
|
<div className="wrap">
|
|
198
215
|
<div
|
|
199
216
|
className="footer-grid"
|
|
@@ -202,14 +219,12 @@ export function Footer({
|
|
|
202
219
|
<div className="footer-brand">
|
|
203
220
|
{logo?.tile ? (
|
|
204
221
|
<p className="footer-wordmark">
|
|
205
|
-
<
|
|
206
|
-
{logo.tile}
|
|
207
|
-
</span>
|
|
222
|
+
<LogoTile glyph={logo.tile} />
|
|
208
223
|
{wordmark}
|
|
209
224
|
{logo.run && <span className="wordmark-run" aria-hidden="true" />}
|
|
210
225
|
</p>
|
|
211
|
-
) :
|
|
212
|
-
<img src={
|
|
226
|
+
) : mark ? (
|
|
227
|
+
<img className={tintClass(mark)} src={mark.src} alt={logo?.alt ?? name} />
|
|
213
228
|
) : (
|
|
214
229
|
<p className="footer-wordmark">
|
|
215
230
|
{wordmark}
|
|
@@ -247,7 +262,15 @@ export function Footer({
|
|
|
247
262
|
</div>
|
|
248
263
|
{shown.map((column) => (
|
|
249
264
|
<nav key={column.heading} className="footer-column" aria-label={column.heading}>
|
|
250
|
-
|
|
265
|
+
{/* A heading by role rather than by element: a site's own bare
|
|
266
|
+
h2 rule (unlayered, so it beats any rule in the package's
|
|
267
|
+
layer whatever its weight) is written for a page's section
|
|
268
|
+
titles and would restyle these small labels. A div that says
|
|
269
|
+
it is a heading keeps the outline and matches no such rule. */}
|
|
270
|
+
{/* biome-ignore lint/a11y/useSemanticElements: an h2 element would take a site's bare h2 rules, see above */}
|
|
271
|
+
<div className="footer-heading" role="heading" aria-level={headingLevel}>
|
|
272
|
+
{column.heading}
|
|
273
|
+
</div>
|
|
251
274
|
{column.links.map((link) => (
|
|
252
275
|
<ColumnLink key={`${link.label} ${link.href}`} link={link} />
|
|
253
276
|
))}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A short word in a pill after a nav link's label ("Popular"), drawn the
|
|
3
|
+
* same on the desktop panel and in the phone's menu, each with its own
|
|
4
|
+
* class for the surface it sits on. Nothing without words.
|
|
5
|
+
*/
|
|
6
|
+
export function NavBadge({ text, className }: { text?: string; className: string }) {
|
|
7
|
+
return text ? <span className={className}>{text}</span> : null;
|
|
8
|
+
}
|