@atelic-action/ui 7.2.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 +312 -126
- 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 +5 -1
- 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 +5 -3
- 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 +935 -47
- 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
package/src/chrome/SiteShell.tsx
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ReactNode, useCallback, useRef } from "react";
|
|
2
2
|
import { Watermark } from "../components/Watermark";
|
|
3
3
|
import type { PageStop } from "../hooks/useScrollSpy";
|
|
4
4
|
import { BasePathProvider } from "../routing/BasePathProvider";
|
|
5
5
|
import { joinBase, normalizeBasePath, stripBase } from "../routing/basePath";
|
|
6
|
-
import type { NavItem, SiteConfig } from "../sections/siteConfig";
|
|
7
|
-
import type { FooterColumn } from "../types";
|
|
6
|
+
import type { Density, NavItem, SiteConfig } from "../sections/siteConfig";
|
|
7
|
+
import type { FooterColumn, NavLink, NavPanelSection } from "../types";
|
|
8
8
|
import { ClosingBar } from "./ClosingBar";
|
|
9
|
+
import { ContactDock } from "./ContactDock";
|
|
9
10
|
import { Copyright } from "./Copyright";
|
|
10
11
|
import { Footer } from "./Footer";
|
|
12
|
+
import { isKnownSection, isLinkColumn } from "./navSections";
|
|
11
13
|
import { SiteHeader, type SiteHeaderVariant } from "./SiteHeader";
|
|
12
14
|
import { SkipLink } from "./SkipLink";
|
|
13
15
|
import { StickyCTABar } from "./StickyCTABar";
|
|
@@ -57,6 +59,17 @@ export interface SiteShellProps {
|
|
|
57
59
|
* side empty unless the site gives a note. The copyright prints either way.
|
|
58
60
|
*/
|
|
59
61
|
credit?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* The section spacing, set on the `.atelic-ui` root as `data-density`.
|
|
64
|
+
* Defaults to `site.density`, then `default`; `comfortable` is the roomier
|
|
65
|
+
* spacing sites had before 8.0.0, close to it though not to the pixel.
|
|
66
|
+
*/
|
|
67
|
+
density?: Density;
|
|
68
|
+
/**
|
|
69
|
+
* Mounts the contact dock when the config supplies `contactDock`.
|
|
70
|
+
* Defaults on; a page that closes on its own ask turns it off.
|
|
71
|
+
*/
|
|
72
|
+
contactDock?: boolean;
|
|
60
73
|
children: ReactNode;
|
|
61
74
|
}
|
|
62
75
|
|
|
@@ -79,23 +92,102 @@ export function SiteShell({
|
|
|
79
92
|
navOnDark = false,
|
|
80
93
|
hideNavCTA = false,
|
|
81
94
|
credit = true,
|
|
95
|
+
density,
|
|
96
|
+
contactDock = true,
|
|
82
97
|
children,
|
|
83
98
|
}: SiteShellProps) {
|
|
84
99
|
const base = normalizeBasePath(basePath ?? site.basePath);
|
|
85
|
-
const withBase = (path: string) => joinBase(base, path);
|
|
86
100
|
// Every href and src handed to the chrome carries the base path (a no op at
|
|
87
|
-
// the root)
|
|
88
|
-
//
|
|
101
|
+
// the root), through these helpers alone: a path, a path that may be
|
|
102
|
+
// absent, and a list or a picture whose own path takes it. The current path
|
|
103
|
+
// is compared against those hrefs, so it is put in the same form whether
|
|
104
|
+
// or not the router reports it with the base.
|
|
105
|
+
const withBase = (path: string) => joinBase(base, path);
|
|
106
|
+
const maybeBase = <T extends string | undefined>(path: T): T =>
|
|
107
|
+
(path === undefined ? path : withBase(path)) as T;
|
|
108
|
+
const based = <T extends { href: string }>(items: T[] | undefined) =>
|
|
109
|
+
items?.map((item) => ({ ...item, href: withBase(item.href) }));
|
|
110
|
+
function image<T extends { src: string }>(picture: T): T;
|
|
111
|
+
function image<T extends { src: string }>(picture: T | undefined): T | undefined;
|
|
112
|
+
function image<T extends { src: string }>(picture: T | undefined) {
|
|
113
|
+
return picture && { ...picture, src: withBase(picture.src) };
|
|
114
|
+
}
|
|
89
115
|
const pathname = withBase(stripBase(base, currentPath));
|
|
90
116
|
const brand = {
|
|
91
117
|
name: site.name,
|
|
92
118
|
href: withBase("/"),
|
|
93
|
-
logo: {
|
|
119
|
+
logo: {
|
|
120
|
+
...site.logo,
|
|
121
|
+
src: maybeBase(site.logo.src),
|
|
122
|
+
onLight: maybeBase(site.logo.onLight),
|
|
123
|
+
onDark: maybeBase(site.logo.onDark),
|
|
124
|
+
},
|
|
94
125
|
};
|
|
95
|
-
|
|
126
|
+
// The contact dock rides above the shell's own footer, or the closing bar
|
|
127
|
+
// standing in for it, held by ref rather than found by a selector.
|
|
128
|
+
const footerRef = useRef<HTMLElement>(null);
|
|
129
|
+
const closingRef = useRef<HTMLDivElement>(null);
|
|
130
|
+
// The room the phone's sticky bar takes while it shows, which the closing
|
|
131
|
+
// bar pads its foot by. The bar reports it and the shell writes it straight
|
|
132
|
+
// onto its root as --sticky-cta-space, outside React's render, so a change
|
|
133
|
+
// in the bar's height never renders the whole shell again. The root's style
|
|
134
|
+
// is never a prop, so no render of the shell clears what this sets.
|
|
135
|
+
const rootRef = useRef<HTMLDivElement>(null);
|
|
136
|
+
const setBarSpace = useCallback((pixels: number) => {
|
|
137
|
+
const root = rootRef.current;
|
|
138
|
+
if (!root) return;
|
|
139
|
+
if (pixels > 0) root.style.setProperty("--sticky-cta-space", `${pixels}px`);
|
|
140
|
+
else root.style.removeProperty("--sticky-cta-space");
|
|
141
|
+
}, []);
|
|
96
142
|
const cta = { ...site.cta, href: withBase(site.cta.href) };
|
|
97
|
-
|
|
98
|
-
|
|
143
|
+
// Every link and picture a panel section holds, based.
|
|
144
|
+
const section = (part: NavPanelSection): NavPanelSection => {
|
|
145
|
+
if (isLinkColumn(part)) {
|
|
146
|
+
return {
|
|
147
|
+
...part,
|
|
148
|
+
href: maybeBase(part.href),
|
|
149
|
+
links: part.links.map((link) => ({
|
|
150
|
+
...link,
|
|
151
|
+
href: withBase(link.href),
|
|
152
|
+
children: based(link.children),
|
|
153
|
+
})),
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
if (part.kind === "picture") {
|
|
157
|
+
return {
|
|
158
|
+
...part,
|
|
159
|
+
href: withBase(part.href),
|
|
160
|
+
image: image(part.image),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
if (part.kind === "rows") return { ...part, rows: based(part.rows) ?? [] };
|
|
164
|
+
return {
|
|
165
|
+
...part,
|
|
166
|
+
cards: part.cards.map((card) => ({
|
|
167
|
+
...card,
|
|
168
|
+
href: withBase(card.href),
|
|
169
|
+
image: image(card.image),
|
|
170
|
+
})),
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
// A group carries its sections and its card into the header, every link based.
|
|
174
|
+
const headerLinks: NavLink[] = (nav ?? site.nav).map((item) => ({
|
|
175
|
+
label: item.label,
|
|
176
|
+
href: withBase(item.to),
|
|
177
|
+
allLabel: item.allLabel,
|
|
178
|
+
// A section of a kind this version does not know is dropped here, before
|
|
179
|
+
// the mapping below would read fields it does not have.
|
|
180
|
+
columns: item.columns?.filter(isKnownSection).map(section),
|
|
181
|
+
feature: item.feature && {
|
|
182
|
+
...item.feature,
|
|
183
|
+
cta: { ...item.feature.cta, href: withBase(item.feature.cta.href) },
|
|
184
|
+
image: image(item.feature.image),
|
|
185
|
+
},
|
|
186
|
+
}));
|
|
187
|
+
// The footer's Company column lists the entries themselves, never a group's links.
|
|
188
|
+
const links = headerLinks.map(({ label, href }) => ({ label, href }));
|
|
189
|
+
const setting = density ?? site.density;
|
|
190
|
+
const dock = contactDock ? site.contactDock : undefined;
|
|
99
191
|
// The default footer's four columns, drawn from what the config already
|
|
100
192
|
// holds; a site that wants other columns names them in `footer.columns`.
|
|
101
193
|
const footerColumns: FooterColumn[] = site.footer?.columns?.map((column) => ({
|
|
@@ -117,24 +209,36 @@ export function SiteShell({
|
|
|
117
209
|
|
|
118
210
|
return (
|
|
119
211
|
<BasePathProvider base={base}>
|
|
120
|
-
<div
|
|
212
|
+
<div
|
|
213
|
+
ref={rootRef}
|
|
214
|
+
className="atelic-ui"
|
|
215
|
+
data-density={setting && setting !== "default" ? setting : undefined}
|
|
216
|
+
>
|
|
121
217
|
<SkipLink />
|
|
122
218
|
<SiteHeader
|
|
123
219
|
brand={brand}
|
|
124
|
-
links={
|
|
220
|
+
links={headerLinks}
|
|
125
221
|
primaryCTA={cta}
|
|
126
222
|
variant={variant}
|
|
127
223
|
currentPath={pathname}
|
|
128
224
|
stops={pageNav}
|
|
129
225
|
hideCTA={hideNavCTA}
|
|
130
226
|
contact={{ phone: site.phone, email: site.email, address: site.address }}
|
|
227
|
+
phones={site.header?.phones}
|
|
131
228
|
/>
|
|
132
229
|
<main id="main" className={heroNav ? undefined : "clears-nav"}>
|
|
133
230
|
{children}
|
|
134
231
|
</main>
|
|
135
232
|
{/* An interior page's first screen has no booking button of its own, so
|
|
136
233
|
the bar is there from the top; the hero home page keeps the slide in. */}
|
|
137
|
-
{stickyCTA &&
|
|
234
|
+
{stickyCTA && (
|
|
235
|
+
<StickyCTABar
|
|
236
|
+
primaryCTA={cta}
|
|
237
|
+
phone={site.phone}
|
|
238
|
+
fromTop={!heroNav}
|
|
239
|
+
onSpaceChange={setBarSpace}
|
|
240
|
+
/>
|
|
241
|
+
)}
|
|
138
242
|
{footer ? (
|
|
139
243
|
<Footer
|
|
140
244
|
brand={brand}
|
|
@@ -147,13 +251,26 @@ export function SiteShell({
|
|
|
147
251
|
attribution={site.attribution}
|
|
148
252
|
note={site.footer?.note}
|
|
149
253
|
credit={credit}
|
|
254
|
+
ref={footerRef}
|
|
150
255
|
/>
|
|
151
256
|
) : (
|
|
152
257
|
<ClosingBar
|
|
258
|
+
ref={closingRef}
|
|
153
259
|
left={<Copyright name={brand.name} attribution={site.attribution} />}
|
|
154
260
|
right={site.footer?.note ?? (credit ? undefined : null)}
|
|
155
261
|
/>
|
|
156
262
|
)}
|
|
263
|
+
{dock && (
|
|
264
|
+
<ContactDock
|
|
265
|
+
{...dock}
|
|
266
|
+
// The shell's own footer, or the closing bar standing in for it, never
|
|
267
|
+
// a footer element some section on the page holds.
|
|
268
|
+
avoid={footer ? footerRef : closingRef}
|
|
269
|
+
items={dock.items.map((item) =>
|
|
270
|
+
item.href === undefined ? item : { ...item, href: withBase(item.href) },
|
|
271
|
+
)}
|
|
272
|
+
/>
|
|
273
|
+
)}
|
|
157
274
|
<Watermark />
|
|
158
275
|
</div>
|
|
159
276
|
</BasePathProvider>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Phone as PhoneIcon } from "lucide-react";
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
3
|
import { newTabProps } from "../lib/newTabProps";
|
|
4
4
|
import type { CallToAction, Phone } from "../types";
|
|
5
5
|
|
|
@@ -20,6 +20,14 @@ export interface StickyCTABarProps {
|
|
|
20
20
|
fromTop?: boolean;
|
|
21
21
|
/** The call shortcut's accessible name. Defaults to "Call us". */
|
|
22
22
|
callLabel?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Hears the room the bar takes at the foot of the screen, in pixels: its
|
|
25
|
+
* measured height while it shows, and 0 while it is hidden (scrolled
|
|
26
|
+
* above its threshold, or on a desktop, where the stylesheet hides it).
|
|
27
|
+
* `SiteShell` pads the page's closing bar by it, so the copyright and the
|
|
28
|
+
* credit are never under the bar.
|
|
29
|
+
*/
|
|
30
|
+
onSpaceChange?: (pixels: number) => void;
|
|
23
31
|
}
|
|
24
32
|
|
|
25
33
|
/** The phone only bottom bar: the primary CTA and a call shortcut, sliding in once scrolled, or there from the top. */
|
|
@@ -29,8 +37,16 @@ export function StickyCTABar({
|
|
|
29
37
|
threshold = 520,
|
|
30
38
|
fromTop = false,
|
|
31
39
|
callLabel = "Call us",
|
|
40
|
+
onSpaceChange,
|
|
32
41
|
}: StickyCTABarProps) {
|
|
33
42
|
const [show, setShow] = useState(fromTop);
|
|
43
|
+
const barRef = useRef<HTMLDivElement>(null);
|
|
44
|
+
// 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
|
+
// a listener supplied after mount starts the measuring then.
|
|
47
|
+
const spaceRef = useRef(onSpaceChange);
|
|
48
|
+
spaceRef.current = onSpaceChange;
|
|
49
|
+
const listening = onSpaceChange !== undefined;
|
|
34
50
|
|
|
35
51
|
useEffect(() => {
|
|
36
52
|
if (fromTop) {
|
|
@@ -43,9 +59,47 @@ export function StickyCTABar({
|
|
|
43
59
|
return () => window.removeEventListener("scroll", onScroll);
|
|
44
60
|
}, [threshold, fromTop]);
|
|
45
61
|
|
|
62
|
+
// The bar's real height while it shows, measured again whenever it changes
|
|
63
|
+
// size (a phone turned, a font loading, a label wrapping), never assumed.
|
|
64
|
+
// Hidden by the stylesheet its height reads 0, so a desktop reserves nothing.
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
const bar = barRef.current;
|
|
67
|
+
if (!bar || !listening) return;
|
|
68
|
+
let last = -1;
|
|
69
|
+
// The listener last told a height, so the cleanup can hand it back its
|
|
70
|
+
// space even when the cleanup runs because that listener was taken
|
|
71
|
+
// away (spaceRef is already empty by then).
|
|
72
|
+
let heard: ((pixels: number) => void) | undefined;
|
|
73
|
+
const report = () => {
|
|
74
|
+
const next = show ? bar.offsetHeight : 0;
|
|
75
|
+
if (next === last) return;
|
|
76
|
+
last = next;
|
|
77
|
+
heard = spaceRef.current;
|
|
78
|
+
heard?.(next);
|
|
79
|
+
};
|
|
80
|
+
report();
|
|
81
|
+
const sizes = typeof ResizeObserver === "undefined" ? undefined : new ResizeObserver(report);
|
|
82
|
+
sizes?.observe(bar);
|
|
83
|
+
window.addEventListener("resize", report);
|
|
84
|
+
return () => {
|
|
85
|
+
sizes?.disconnect();
|
|
86
|
+
window.removeEventListener("resize", report);
|
|
87
|
+
// A final 0 on unmount, on hiding, and when the listener goes, so no
|
|
88
|
+
// foot padding outlives the bar.
|
|
89
|
+
(spaceRef.current ?? heard)?.(0);
|
|
90
|
+
};
|
|
91
|
+
}, [show, listening]);
|
|
92
|
+
|
|
46
93
|
return (
|
|
47
94
|
// Inert while offscreen, so its links take no keyboard focus before it slides in.
|
|
48
|
-
|
|
95
|
+
// data-dock-lift and data-showing tell the contact dock to ride above it.
|
|
96
|
+
<div
|
|
97
|
+
ref={barRef}
|
|
98
|
+
className={show ? "sticky-cta show" : "sticky-cta"}
|
|
99
|
+
inert={!show}
|
|
100
|
+
data-dock-lift=""
|
|
101
|
+
data-showing={show ? "true" : "false"}
|
|
102
|
+
>
|
|
49
103
|
<a
|
|
50
104
|
className="btn btn-primary"
|
|
51
105
|
href={primaryCTA.href}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { BrandLogo } from "../types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The two grounds a mark is drawn on: `light` is the solid light bar, and
|
|
5
|
+
* `dark` is everything else the chrome puts a mark on (the dark bar, the
|
|
6
|
+
* transparent bar over a hero, and the footer band).
|
|
7
|
+
*/
|
|
8
|
+
export type MarkSurface = "light" | "dark";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A mark as one surface draws it: the image, and the silhouette it is
|
|
12
|
+
* flattened to when the image was cut for the other ground. `ink` flattens
|
|
13
|
+
* it dark for a light ground, `light` flattens it white for a dark ground,
|
|
14
|
+
* and `null` draws the artwork as given.
|
|
15
|
+
*/
|
|
16
|
+
export interface ResolvedMark {
|
|
17
|
+
src: string;
|
|
18
|
+
tint: "ink" | "light" | null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Which image a surface draws, and how, by one order the header and the
|
|
23
|
+
* footer share.
|
|
24
|
+
*
|
|
25
|
+
* - A cut made for the surface (`onLight` on light, `onDark` on dark) is drawn
|
|
26
|
+
* as given, never recolored.
|
|
27
|
+
* - Failing that, `src`, the single light mark sites have always passed: drawn
|
|
28
|
+
* as given on a dark ground and flattened to ink on a light one.
|
|
29
|
+
* - Failing that, the cut made for the other ground, flattened to the
|
|
30
|
+
* surface's silhouette, since drawn as given it would vanish (a light only
|
|
31
|
+
* mark on the light bar, an ink only mark on the footer).
|
|
32
|
+
*
|
|
33
|
+
* Null when the logo carries no image at all.
|
|
34
|
+
*/
|
|
35
|
+
export function resolveMark(
|
|
36
|
+
logo: BrandLogo | undefined,
|
|
37
|
+
surface: MarkSurface,
|
|
38
|
+
): ResolvedMark | null {
|
|
39
|
+
if (!logo) return null;
|
|
40
|
+
const own = surface === "light" ? logo.onLight : logo.onDark;
|
|
41
|
+
if (own) return { src: own, tint: null };
|
|
42
|
+
if (logo.src) return { src: logo.src, tint: surface === "light" ? "ink" : null };
|
|
43
|
+
const other = surface === "light" ? logo.onDark : logo.onLight;
|
|
44
|
+
if (other) return { src: other, tint: surface === "light" ? "ink" : "light" };
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Whether the logo draws a mark of any kind: a glyph tile or an image. */
|
|
49
|
+
export function hasMark(logo: BrandLogo | undefined): boolean {
|
|
50
|
+
return Boolean(logo?.tile || logo?.src || logo?.onLight || logo?.onDark);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** The class a resolved mark's silhouette wears, or none for artwork drawn as given. */
|
|
54
|
+
export function tintClass(mark: ResolvedMark): string | undefined {
|
|
55
|
+
return mark.tint === "ink" ? "is-tinted" : mark.tint === "light" ? "is-tinted-light" : undefined;
|
|
56
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Calculator,
|
|
3
|
+
CalendarDays,
|
|
4
|
+
CircleHelp,
|
|
5
|
+
CirclePlay,
|
|
6
|
+
ClipboardList,
|
|
7
|
+
CreditCard,
|
|
8
|
+
FileText,
|
|
9
|
+
House,
|
|
10
|
+
type LucideIcon,
|
|
11
|
+
Mail,
|
|
12
|
+
Map as MapIcon,
|
|
13
|
+
MapPin,
|
|
14
|
+
MessageCircle,
|
|
15
|
+
Phone,
|
|
16
|
+
Shield,
|
|
17
|
+
Star,
|
|
18
|
+
Truck,
|
|
19
|
+
Users,
|
|
20
|
+
Wrench,
|
|
21
|
+
} from "lucide-react";
|
|
22
|
+
import type { ContactDockIcon, NavIcon } from "../types";
|
|
23
|
+
|
|
24
|
+
/** The lucide icon each name in `NavIcon` draws, in a mega menu panel's icon rows. */
|
|
25
|
+
export const navIcons: Record<NavIcon, LucideIcon> = {
|
|
26
|
+
calculator: Calculator,
|
|
27
|
+
calendar: CalendarDays,
|
|
28
|
+
card: CreditCard,
|
|
29
|
+
chat: MessageCircle,
|
|
30
|
+
document: FileText,
|
|
31
|
+
help: CircleHelp,
|
|
32
|
+
home: House,
|
|
33
|
+
mail: Mail,
|
|
34
|
+
map: MapIcon,
|
|
35
|
+
phone: Phone,
|
|
36
|
+
pin: MapPin,
|
|
37
|
+
play: CirclePlay,
|
|
38
|
+
shield: Shield,
|
|
39
|
+
star: Star,
|
|
40
|
+
tool: Wrench,
|
|
41
|
+
truck: Truck,
|
|
42
|
+
users: Users,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The icon each name in `ContactDockIcon` draws, the same glyphs as the
|
|
47
|
+
* panel's where the names meet. The dock's `map` is the pin, since a dock
|
|
48
|
+
* item leads to a place, and its `form` is the clipboard.
|
|
49
|
+
*/
|
|
50
|
+
export const dockIcons: Record<ContactDockIcon, LucideIcon> = {
|
|
51
|
+
chat: navIcons.chat,
|
|
52
|
+
phone: navIcons.phone,
|
|
53
|
+
calendar: navIcons.calendar,
|
|
54
|
+
mail: navIcons.mail,
|
|
55
|
+
form: ClipboardList,
|
|
56
|
+
calculator: navIcons.calculator,
|
|
57
|
+
map: navIcons.pin,
|
|
58
|
+
};
|
package/src/chrome/index.ts
CHANGED
|
@@ -4,12 +4,27 @@ export type {
|
|
|
4
4
|
Brand,
|
|
5
5
|
BrandLogo,
|
|
6
6
|
CallToAction,
|
|
7
|
+
ContactDockConfig,
|
|
8
|
+
ContactDockIcon,
|
|
9
|
+
ContactDockItem,
|
|
7
10
|
FooterColumn,
|
|
8
11
|
FooterColumnLink,
|
|
9
12
|
FooterIcon,
|
|
13
|
+
HeaderPhone,
|
|
10
14
|
HoursRow,
|
|
11
15
|
MenuContact,
|
|
16
|
+
NavCard,
|
|
17
|
+
NavCardsSection,
|
|
18
|
+
NavFeature,
|
|
19
|
+
NavGroupChildLink,
|
|
20
|
+
NavGroupColumn,
|
|
21
|
+
NavGroupLink,
|
|
22
|
+
NavIcon,
|
|
23
|
+
NavIconRow,
|
|
24
|
+
NavIconRowsSection,
|
|
12
25
|
NavLink,
|
|
26
|
+
NavPanelSection,
|
|
27
|
+
NavPictureSection,
|
|
13
28
|
Phone,
|
|
14
29
|
PostalAddress,
|
|
15
30
|
SiteLink,
|
|
@@ -17,6 +32,7 @@ export type {
|
|
|
17
32
|
} from "../types";
|
|
18
33
|
export { BrandLockup, type BrandLockupProps } from "./BrandLockup";
|
|
19
34
|
export { ClosingBar, type ClosingBarProps } from "./ClosingBar";
|
|
35
|
+
export { ContactDock, type ContactDockProps } from "./ContactDock";
|
|
20
36
|
export { Copyright, type CopyrightProps } from "./Copyright";
|
|
21
37
|
export { Credit } from "./Credit";
|
|
22
38
|
export { Footer, type FooterProps } from "./Footer";
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { NavGroupColumn, NavLink, NavPanelSection } from "../types";
|
|
2
|
+
|
|
3
|
+
/** Whether a panel section is a link column, the kind a section is when it names none. */
|
|
4
|
+
export function isLinkColumn(section: NavPanelSection): section is NavGroupColumn {
|
|
5
|
+
return section.kind === undefined || section.kind === "links";
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const KNOWN_KINDS: ReadonlySet<string | undefined> = new Set([
|
|
9
|
+
undefined,
|
|
10
|
+
"links",
|
|
11
|
+
"picture",
|
|
12
|
+
"rows",
|
|
13
|
+
"cards",
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Whether the chrome knows how to draw a section. A config written against a
|
|
18
|
+
* later version (or a typo the types never saw, from JSON) can name a kind
|
|
19
|
+
* this one lacks; that section is left out rather than drawn as the wrong
|
|
20
|
+
* kind, which would read fields it does not have.
|
|
21
|
+
*/
|
|
22
|
+
export function isKnownSection(section: NavPanelSection): boolean {
|
|
23
|
+
return (
|
|
24
|
+
typeof section === "object" &&
|
|
25
|
+
section !== null &&
|
|
26
|
+
KNOWN_KINDS.has((section as { kind?: string }).kind)
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** A group's sections that the chrome can draw, in order. */
|
|
31
|
+
export function panelSections(link: NavLink): NavPanelSection[] {
|
|
32
|
+
return (link.columns ?? []).filter(isKnownSection);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Whether an entry is a group: it holds at least one section the chrome can draw. */
|
|
36
|
+
export function isGroup(link: NavLink): boolean {
|
|
37
|
+
return panelSections(link).length > 0;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Every href a group's panel holds, its column headings, links, and their children included. */
|
|
41
|
+
export function groupHrefs(group: NavLink): string[] {
|
|
42
|
+
const hrefs: string[] = [];
|
|
43
|
+
for (const section of panelSections(group)) {
|
|
44
|
+
if (isLinkColumn(section)) {
|
|
45
|
+
if (section.href) hrefs.push(section.href);
|
|
46
|
+
for (const link of section.links) {
|
|
47
|
+
hrefs.push(link.href);
|
|
48
|
+
for (const child of link.children ?? []) hrefs.push(child.href);
|
|
49
|
+
}
|
|
50
|
+
} else if (section.kind === "picture") hrefs.push(section.href);
|
|
51
|
+
else if (section.kind === "rows") for (const row of section.rows) hrefs.push(row.href);
|
|
52
|
+
else for (const card of section.cards) hrefs.push(card.href);
|
|
53
|
+
}
|
|
54
|
+
return hrefs;
|
|
55
|
+
}
|
|
@@ -26,6 +26,8 @@ export interface ColumnChartProps {
|
|
|
26
26
|
legend?: Array<{ label: string; tone: Tone }>;
|
|
27
27
|
/** The tallest a bar draws, in pixels. */
|
|
28
28
|
height?: number;
|
|
29
|
+
/** What the chart says, shown and spoken, when it has no bars; defaults to "No data to show". */
|
|
30
|
+
emptyLabel?: string;
|
|
29
31
|
className?: string;
|
|
30
32
|
}
|
|
31
33
|
|
|
@@ -34,18 +36,41 @@ export interface ColumnChartProps {
|
|
|
34
36
|
* their own label and total, so a reader compares a quarter with the one
|
|
35
37
|
* before it and with the same quarter a year earlier in one picture.
|
|
36
38
|
*/
|
|
37
|
-
export function ColumnChart({
|
|
39
|
+
export function ColumnChart({
|
|
40
|
+
groups,
|
|
41
|
+
legend,
|
|
42
|
+
height = 120,
|
|
43
|
+
emptyLabel = "No data to show",
|
|
44
|
+
className,
|
|
45
|
+
}: ColumnChartProps) {
|
|
38
46
|
const all = groups.flatMap((group) => group.bars);
|
|
39
47
|
const max = Math.max(...all.map((bar) => bar.value), 1);
|
|
40
48
|
const figure = (bar: ColumnChartBar) => bar.display ?? bar.value.toLocaleString("en-US");
|
|
49
|
+
// A bar marked apart from its group is told by its tone; the legend's
|
|
50
|
+
// words for that tone go into the picture's name, so the mark is never
|
|
51
|
+
// carried by color alone. A group's tone is named by the group's label.
|
|
52
|
+
const meaning = (tone: Tone) => legend?.find((entry) => entry.tone === tone)?.label;
|
|
53
|
+
const describe = (bar: ColumnChartBar, group: ColumnChartGroup) => {
|
|
54
|
+
const marked = bar.tone && bar.tone !== group.tone ? meaning(bar.tone) : undefined;
|
|
55
|
+
return `${bar.label} ${bar.value.toLocaleString("en-US")}${marked ? ` (${marked})` : ""}`;
|
|
56
|
+
};
|
|
41
57
|
const summary = groups
|
|
42
58
|
.map(
|
|
43
59
|
(group) =>
|
|
44
60
|
`${group.label ? `${group.label}${group.total ? `, ${group.total}` : ""}: ` : ""}${group.bars
|
|
45
|
-
.map((bar) =>
|
|
61
|
+
.map((bar) => describe(bar, group))
|
|
46
62
|
.join(", ")}`,
|
|
47
63
|
)
|
|
48
64
|
.join("; ");
|
|
65
|
+
if (all.length === 0) {
|
|
66
|
+
return (
|
|
67
|
+
<div className={["column-chart", "is-empty", className].filter(Boolean).join(" ")}>
|
|
68
|
+
<div className="column-chart-plot" role="img" aria-label={emptyLabel}>
|
|
69
|
+
<p className="column-chart-empty">{emptyLabel}</p>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
49
74
|
return (
|
|
50
75
|
<div className={["column-chart", className].filter(Boolean).join(" ")}>
|
|
51
76
|
<div className="column-chart-plot" role="img" aria-label={summary}>
|