@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/dist/vite/index.js
CHANGED
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
* plugin inside the artifact one for a site that writes its own.
|
|
5
5
|
*/
|
|
6
6
|
export { artifactConfig, artifactPages, } from "./artifact-config.js";
|
|
7
|
-
export { marketingBasePath, marketingConfig, NOT_FOUND_PAGE, } from "./marketing-config.js";
|
|
7
|
+
export { buildRelease, environmentPlugin, marketingBasePath, marketingConfig, NOT_FOUND_PAGE, sentryUpload, } from "./marketing-config.js";
|
|
8
8
|
export { DOC_DIR, isPrivateContent, privateChunks } from "./private-chunks.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type UserConfig } from "vite";
|
|
1
|
+
import { type Plugin, type UserConfig } from "vite";
|
|
2
2
|
/** One entry of the prerender list, as TanStack Start takes it. */
|
|
3
3
|
export interface MarketingPage {
|
|
4
4
|
path: string;
|
|
@@ -35,6 +35,33 @@ export interface MarketingConfigOptions {
|
|
|
35
35
|
/** The environment to read `VITE_BASE_PATH` from; a test passes its own. */
|
|
36
36
|
env?: Record<string, string | undefined>;
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* The commit a build is filed under in Sentry: Vercel's commit, else the CI's.
|
|
40
|
+
* The same value names the release the Sentry plugin creates and the release
|
|
41
|
+
* the browser reports under, so a stack trace meets its source maps.
|
|
42
|
+
*/
|
|
43
|
+
export declare function buildRelease(env?: Record<string, string | undefined>): string | undefined;
|
|
44
|
+
/** What the Sentry plugin is given, when it runs at all. */
|
|
45
|
+
export interface SentryUpload {
|
|
46
|
+
org: string;
|
|
47
|
+
project: string;
|
|
48
|
+
authToken: string;
|
|
49
|
+
release: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The source map upload, on only when `SENTRY_AUTH_TOKEN`, `SENTRY_ORG`, and
|
|
53
|
+
* `SENTRY_PROJECT` are all set and the build knows its commit. Off, the
|
|
54
|
+
* build is exactly what it was: no plugin, no source maps.
|
|
55
|
+
*/
|
|
56
|
+
export declare function sentryUpload(env?: Record<string, string | undefined>): SentryUpload | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* The environment the browser files its errors under, as
|
|
59
|
+
* `import.meta.env.VITE_ENVIRONMENT`: Vercel's (production, preview,
|
|
60
|
+
* development) when the build runs there, else the build's mode. A Vite
|
|
61
|
+
* production build's mode is production on every deploy, a preview's
|
|
62
|
+
* included, so the mode alone filed every error as production.
|
|
63
|
+
*/
|
|
64
|
+
export declare function environmentPlugin(env?: Record<string, string | undefined>): Plugin;
|
|
38
65
|
/** The 404 page, prerendered and copied to 404.html by the build, never in the sitemap. */
|
|
39
66
|
export declare const NOT_FOUND_PAGE: MarketingPage;
|
|
40
67
|
/**
|
|
@@ -17,6 +17,58 @@ import { tanstackStart } from "@tanstack/react-start/plugin/vite";
|
|
|
17
17
|
import react from "@vitejs/plugin-react";
|
|
18
18
|
import { mergeConfig } from "vite";
|
|
19
19
|
import { normalizeBasePath } from "../routing/basePath.js";
|
|
20
|
+
/**
|
|
21
|
+
* The commit a build is filed under in Sentry: Vercel's commit, else the CI's.
|
|
22
|
+
* The same value names the release the Sentry plugin creates and the release
|
|
23
|
+
* the browser reports under, so a stack trace meets its source maps.
|
|
24
|
+
*/
|
|
25
|
+
export function buildRelease(env = process.env) {
|
|
26
|
+
return env.VERCEL_GIT_COMMIT_SHA || env.GITHUB_SHA || undefined;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The source map upload, on only when `SENTRY_AUTH_TOKEN`, `SENTRY_ORG`, and
|
|
30
|
+
* `SENTRY_PROJECT` are all set and the build knows its commit. Off, the
|
|
31
|
+
* build is exactly what it was: no plugin, no source maps.
|
|
32
|
+
*/
|
|
33
|
+
export function sentryUpload(env = process.env) {
|
|
34
|
+
const { SENTRY_AUTH_TOKEN: authToken, SENTRY_ORG: org, SENTRY_PROJECT: project } = env;
|
|
35
|
+
const release = buildRelease(env);
|
|
36
|
+
if (!authToken || !org || !project || !release)
|
|
37
|
+
return undefined;
|
|
38
|
+
return { org, project, authToken, release };
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The Sentry Vite plugin, loaded only when it runs: it creates the release
|
|
42
|
+
* named by the commit, uploads the build's hidden source maps, and deletes
|
|
43
|
+
* every map file from the output afterwards, so none is ever served.
|
|
44
|
+
*/
|
|
45
|
+
function sentryPlugin(upload) {
|
|
46
|
+
return import("@sentry/vite-plugin").then(({ sentryVitePlugin }) => sentryVitePlugin({
|
|
47
|
+
org: upload.org,
|
|
48
|
+
project: upload.project,
|
|
49
|
+
authToken: upload.authToken,
|
|
50
|
+
release: { name: upload.release, inject: false },
|
|
51
|
+
sourcemaps: { filesToDeleteAfterUpload: ["./dist/**/*.map"] },
|
|
52
|
+
telemetry: false,
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The environment the browser files its errors under, as
|
|
57
|
+
* `import.meta.env.VITE_ENVIRONMENT`: Vercel's (production, preview,
|
|
58
|
+
* development) when the build runs there, else the build's mode. A Vite
|
|
59
|
+
* production build's mode is production on every deploy, a preview's
|
|
60
|
+
* included, so the mode alone filed every error as production.
|
|
61
|
+
*/
|
|
62
|
+
export function environmentPlugin(env = process.env) {
|
|
63
|
+
return {
|
|
64
|
+
name: "atelic-build-environment",
|
|
65
|
+
config: (_config, { mode }) => ({
|
|
66
|
+
define: {
|
|
67
|
+
"import.meta.env.VITE_ENVIRONMENT": JSON.stringify(env.VERCEL_ENV || mode),
|
|
68
|
+
},
|
|
69
|
+
}),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
20
72
|
/** The 404 page, prerendered and copied to 404.html by the build, never in the sitemap. */
|
|
21
73
|
export const NOT_FOUND_PAGE = {
|
|
22
74
|
path: "/404",
|
|
@@ -39,6 +91,8 @@ export function marketingBasePath(site, env = process.env) {
|
|
|
39
91
|
}
|
|
40
92
|
export function marketingConfig({ site, pages = [], sitemapHost, extend, env = process.env, }) {
|
|
41
93
|
const basePath = marketingBasePath(site, env);
|
|
94
|
+
const release = buildRelease(env);
|
|
95
|
+
const upload = sentryUpload(env);
|
|
42
96
|
const listed = pages.filter((page) => page.path !== NOT_FOUND_PAGE.path);
|
|
43
97
|
const config = {
|
|
44
98
|
// The base becomes Vite's `base`, so every built asset URL and every
|
|
@@ -65,7 +119,15 @@ export function marketingConfig({ site, pages = [], sitemapHost, extend, env = p
|
|
|
65
119
|
},
|
|
66
120
|
}),
|
|
67
121
|
react(),
|
|
122
|
+
environmentPlugin(env),
|
|
123
|
+
...(upload ? [sentryPlugin(upload)] : []),
|
|
68
124
|
],
|
|
125
|
+
// The commit, for the browser to report under (`startErrorReporting`'s
|
|
126
|
+
// `release`), read as `import.meta.env.VITE_RELEASE`.
|
|
127
|
+
...(release ? { define: { "import.meta.env.VITE_RELEASE": JSON.stringify(release) } } : {}),
|
|
128
|
+
// Maps only for Sentry, and hidden: the bundles carry no comment
|
|
129
|
+
// pointing at one, and the plugin deletes them once uploaded.
|
|
130
|
+
...(upload ? { build: { sourcemap: "hidden" } } : {}),
|
|
69
131
|
resolve: {
|
|
70
132
|
alias: {
|
|
71
133
|
// The site's src, from the directory Vite is run in: this file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atelic-action/ui",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.1.0",
|
|
4
4
|
"description": "Shared UI for the Atelic templates: site chrome, base styles, the component library, the access gate, and the app shell they install",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"atelic-check-base-path": "./bin/atelic-check-base-path.ts",
|
|
22
22
|
"atelic-check-images": "./bin/atelic-check-images.ts",
|
|
23
23
|
"atelic-check-links": "./bin/atelic-check-links.ts",
|
|
24
|
+
"atelic-check-sentry": "./bin/atelic-check-sentry.ts",
|
|
24
25
|
"atelic-check-wall": "./bin/atelic-check-wall.ts",
|
|
25
26
|
"atelic-clean-sitemap": "./bin/atelic-clean-sitemap.ts",
|
|
26
27
|
"atelic-contact-canary": "./bin/atelic-contact-canary.ts",
|
|
@@ -46,6 +47,11 @@
|
|
|
46
47
|
"./email": "./src/email/index.ts",
|
|
47
48
|
"./email/render": "./src/email/render.tsx",
|
|
48
49
|
"./hooks": "./src/hooks/index.ts",
|
|
50
|
+
"./monitoring": "./src/monitoring/index.ts",
|
|
51
|
+
"./monitoring/server": {
|
|
52
|
+
"types": "./dist/monitoring/server.d.ts",
|
|
53
|
+
"default": "./dist/monitoring/server.js"
|
|
54
|
+
},
|
|
49
55
|
"./primitives": "./src/primitives/index.ts",
|
|
50
56
|
"./routing": "./src/routing/index.ts",
|
|
51
57
|
"./routing/base-path": {
|
|
@@ -91,7 +97,7 @@
|
|
|
91
97
|
},
|
|
92
98
|
"scripts": {
|
|
93
99
|
"build": "rm -rf dist && tsc -p tsconfig.server.json",
|
|
94
|
-
"build:smoke": "node --input-type=module -e \"for (const entry of ['gate', 'gate/middleware', 'gate/request-link', 'gate/verify', 'vite', 'vite/private-chunks', 'artifact/readers', 'routing/base-path']) await import('@atelic-action/ui/' + entry)\"",
|
|
100
|
+
"build:smoke": "node --input-type=module -e \"for (const entry of ['gate', 'gate/middleware', 'gate/request-link', 'gate/verify', 'vite', 'vite/private-chunks', 'artifact/readers', 'routing/base-path', 'monitoring/server']) await import('@atelic-action/ui/' + entry)\"",
|
|
95
101
|
"prepack": "bun run build",
|
|
96
102
|
"lint": "biome check .",
|
|
97
103
|
"lint:fix": "biome check . --write",
|
|
@@ -103,6 +109,8 @@
|
|
|
103
109
|
},
|
|
104
110
|
"dependencies": {
|
|
105
111
|
"@radix-ui/react-tabs": "^1.2.1",
|
|
112
|
+
"@sentry/browser": "^11.16.0",
|
|
113
|
+
"@sentry/vite-plugin": "^11.16.0",
|
|
106
114
|
"jose": "^6.2.12"
|
|
107
115
|
},
|
|
108
116
|
"peerDependencies": {
|
|
@@ -131,19 +131,21 @@ export function DesktopRail({ pathname, collapsed, onToggle, user, onLogout }: D
|
|
|
131
131
|
<nav className="flex-1 space-y-1 px-4 py-6" aria-label="Primary navigation">
|
|
132
132
|
{navItems
|
|
133
133
|
.filter((item) => !item.mobileOnly)
|
|
134
|
-
.map((item) => {
|
|
134
|
+
.map((item, at) => {
|
|
135
135
|
const active = isActiveSection(pathname, item);
|
|
136
136
|
const showChildren = active && !collapsed && item.children?.length;
|
|
137
137
|
return (
|
|
138
|
-
|
|
138
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: two entries may share a link, so the place keeps the key unique; the nav never reorders
|
|
139
|
+
<div key={at}>
|
|
139
140
|
<RailLink item={item} active={active} collapsed={collapsed} />
|
|
140
141
|
{showChildren ? (
|
|
141
142
|
<ul className="mt-1 space-y-0.5 pb-1" aria-label={`${item.label} pages`}>
|
|
142
|
-
{item.children?.map((child) => {
|
|
143
|
+
{item.children?.map((child, childAt) => {
|
|
143
144
|
const childActive = isActivePath(pathname, child.href);
|
|
144
145
|
const ChildIcon = child.icon;
|
|
145
146
|
return (
|
|
146
|
-
|
|
147
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: two entries may share a link, so the place keeps the key unique; the nav never reorders
|
|
148
|
+
<li key={childAt}>
|
|
147
149
|
<Link
|
|
148
150
|
to={child.href}
|
|
149
151
|
className={cn(
|
|
@@ -72,14 +72,15 @@ export function MobileMenu({ pathname, user, onLogout }: MobileMenuProps) {
|
|
|
72
72
|
|
|
73
73
|
<nav className="flex-1 overflow-y-auto px-2 py-3" aria-label="Menu">
|
|
74
74
|
<ul className="space-y-0.5">
|
|
75
|
-
{navItems.map((item) => {
|
|
75
|
+
{navItems.map((item, at) => {
|
|
76
76
|
const Icon = item.icon;
|
|
77
77
|
const active = isActiveSection(pathname, item);
|
|
78
78
|
// A section with sub pages lights its row only on its own landing
|
|
79
79
|
// page; deeper in, the sub page row carries the highlight.
|
|
80
80
|
const exact = pathname === item.href;
|
|
81
81
|
return (
|
|
82
|
-
|
|
82
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: two entries may share a link, so the place keeps the key unique; the nav never reorders
|
|
83
|
+
<li key={at}>
|
|
83
84
|
<Link
|
|
84
85
|
onClick={() => setOpen(false)}
|
|
85
86
|
to={item.href}
|
|
@@ -98,11 +99,12 @@ export function MobileMenu({ pathname, user, onLogout }: MobileMenuProps) {
|
|
|
98
99
|
</Link>
|
|
99
100
|
{item.children ? (
|
|
100
101
|
<ul className="mb-1 mt-0.5 space-y-0.5" aria-label={`${item.label} pages`}>
|
|
101
|
-
{item.children.map((child) => {
|
|
102
|
+
{item.children.map((child, childAt) => {
|
|
102
103
|
const ChildIcon = child.icon;
|
|
103
104
|
const childActive = isActivePath(pathname, child.href);
|
|
104
105
|
return (
|
|
105
|
-
|
|
106
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: two entries may share a link, so the place keeps the key unique; the nav never reorders
|
|
107
|
+
<li key={childAt}>
|
|
106
108
|
<Link
|
|
107
109
|
onClick={() => setOpen(false)}
|
|
108
110
|
to={child.href}
|
|
@@ -148,7 +150,10 @@ export function MobileMenu({ pathname, user, onLogout }: MobileMenuProps) {
|
|
|
148
150
|
<button
|
|
149
151
|
type="button"
|
|
150
152
|
onClick={onLogout}
|
|
151
|
-
className={cn(
|
|
153
|
+
className={cn(
|
|
154
|
+
ROW,
|
|
155
|
+
"w-full text-destructive-ink active:text-destructive-hover dark:active:text-destructive-ink",
|
|
156
|
+
)}
|
|
152
157
|
>
|
|
153
158
|
<LogOut className="h-5 w-5 flex-shrink-0" />
|
|
154
159
|
<span>Log out</span>
|
|
@@ -18,12 +18,13 @@ export function MobileTabBar({ pathname }: { pathname: string }) {
|
|
|
18
18
|
<div className="flex h-16 items-center justify-around">
|
|
19
19
|
{navItems
|
|
20
20
|
.filter((item) => !item.desktopOnly)
|
|
21
|
-
.map((item) => {
|
|
21
|
+
.map((item, at) => {
|
|
22
22
|
const Icon = item.icon;
|
|
23
23
|
const active = isActiveSection(pathname, item);
|
|
24
24
|
return (
|
|
25
25
|
<Link
|
|
26
|
-
key
|
|
26
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: two entries may share a link, so the place keeps the key unique; the nav never reorders
|
|
27
|
+
key={at}
|
|
27
28
|
to={item.href}
|
|
28
29
|
className={cn(
|
|
29
30
|
"flex h-full flex-1 flex-col items-center justify-center py-2 transition-colors duration-150 active:bg-accent",
|
|
@@ -22,9 +22,9 @@ export function PageError({ message, title = "Error", className }: PageErrorProp
|
|
|
22
22
|
return (
|
|
23
23
|
<Card role="alert" className={cn("border-destructive/50", className)}>
|
|
24
24
|
<CardContent className="flex items-center gap-3 py-6">
|
|
25
|
-
<AlertCircle className="h-5 w-5 flex-shrink-0 text-destructive" aria-hidden="true" />
|
|
25
|
+
<AlertCircle className="h-5 w-5 flex-shrink-0 text-destructive-ink" aria-hidden="true" />
|
|
26
26
|
<div>
|
|
27
|
-
<p className="font-medium text-destructive">{title}</p>
|
|
27
|
+
<p className="font-medium text-destructive-ink">{title}</p>
|
|
28
28
|
<p className="text-sm text-muted-foreground">{message}</p>
|
|
29
29
|
</div>
|
|
30
30
|
</CardContent>
|
|
@@ -14,10 +14,15 @@ export function SectionCards({ section }: { section: string }) {
|
|
|
14
14
|
|
|
15
15
|
return (
|
|
16
16
|
<nav className="ap-sections" aria-label={`${item.label} pages`}>
|
|
17
|
-
{item.children.map((child) => {
|
|
17
|
+
{item.children.map((child, at) => {
|
|
18
18
|
const Icon = child.icon;
|
|
19
19
|
return (
|
|
20
|
-
<Link
|
|
20
|
+
<Link
|
|
21
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: two entries may share a link, so the place keeps the key unique; the nav never reorders
|
|
22
|
+
key={at}
|
|
23
|
+
to={child.href}
|
|
24
|
+
className="ap-section-card"
|
|
25
|
+
>
|
|
21
26
|
<span className="ic">
|
|
22
27
|
<Icon size={20} />
|
|
23
28
|
</span>
|
|
@@ -100,7 +100,7 @@ export function UserMenu({ user, onLogout, collapsed = false }: UserMenuProps) {
|
|
|
100
100
|
</Link>
|
|
101
101
|
</DropdownMenuItem>
|
|
102
102
|
<DropdownMenuSeparator />
|
|
103
|
-
<DropdownMenuItem onClick={onLogout} className="cursor-pointer text-destructive">
|
|
103
|
+
<DropdownMenuItem onClick={onLogout} className="cursor-pointer text-destructive-ink">
|
|
104
104
|
<LogOut className="mr-2 h-4 w-4" />
|
|
105
105
|
<span>Log out</span>
|
|
106
106
|
</DropdownMenuItem>
|
package/src/app/ui/alert.tsx
CHANGED
|
@@ -10,7 +10,7 @@ const alertVariants = cva(
|
|
|
10
10
|
variant: {
|
|
11
11
|
default: "bg-background text-foreground",
|
|
12
12
|
destructive:
|
|
13
|
-
"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",
|
|
13
|
+
"border-destructive/50 text-destructive-ink dark:border-destructive [&>svg]:text-destructive-ink",
|
|
14
14
|
},
|
|
15
15
|
},
|
|
16
16
|
defaultVariants: {
|
package/src/app/ui/form.tsx
CHANGED
|
@@ -125,7 +125,7 @@ const FormLabel = React.forwardRef<
|
|
|
125
125
|
return (
|
|
126
126
|
<Label
|
|
127
127
|
ref={ref}
|
|
128
|
-
className={cn(error && "text-destructive", className)}
|
|
128
|
+
className={cn(error && "text-destructive-ink", className)}
|
|
129
129
|
htmlFor={formItemId}
|
|
130
130
|
{...props}
|
|
131
131
|
/>
|
|
@@ -190,7 +190,7 @@ const FormMessage = React.forwardRef<
|
|
|
190
190
|
<p
|
|
191
191
|
ref={ref}
|
|
192
192
|
id={formMessageId}
|
|
193
|
-
className={cn("text-sm font-medium text-destructive", className)}
|
|
193
|
+
className={cn("text-sm font-medium text-destructive-ink", className)}
|
|
194
194
|
{...props}
|
|
195
195
|
>
|
|
196
196
|
{body}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component, type ReactNode } from "react";
|
|
2
|
-
|
|
2
|
+
import { reportError } from "../monitoring/catcher";
|
|
3
3
|
import { ErrorFallback } from "./ErrorFallback";
|
|
4
4
|
|
|
5
5
|
interface AppErrorBoundaryState {
|
|
@@ -8,12 +8,13 @@ interface AppErrorBoundaryState {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* Plain React error boundary rendering the dependency
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
11
|
+
* Plain React error boundary rendering the dependency free ErrorFallback, so
|
|
12
|
+
* no Sentry code sits in the critical bundle. A render crash it catches
|
|
13
|
+
* never reaches the window's error handlers (React keeps it), so it hands
|
|
14
|
+
* the error to the package's error reporting itself (`reportError`): to the
|
|
15
|
+
* Sentry SDK once `startErrorReporting` has loaded it, and to the early
|
|
16
|
+
* catcher's buffer before that, which the SDK replays when it arrives. With
|
|
17
|
+
* no DSN configured the buffer simply holds it and nothing is sent.
|
|
17
18
|
*/
|
|
18
19
|
export class AppErrorBoundary extends Component<{ children: ReactNode }, AppErrorBoundaryState> {
|
|
19
20
|
state: AppErrorBoundaryState = { error: null, hasError: false };
|
|
@@ -22,6 +23,10 @@ export class AppErrorBoundary extends Component<{ children: ReactNode }, AppErro
|
|
|
22
23
|
return { error, hasError: true };
|
|
23
24
|
}
|
|
24
25
|
|
|
26
|
+
componentDidCatch(error: unknown) {
|
|
27
|
+
reportError(error, "boundary");
|
|
28
|
+
}
|
|
29
|
+
|
|
25
30
|
render() {
|
|
26
31
|
if (this.state.hasError) {
|
|
27
32
|
return (
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Brand, BrandLogo } from "../types";
|
|
2
|
-
import { hasMark, type ResolvedMark, resolveMark, tintClass } from "./brandMark";
|
|
2
|
+
import { hasMark, type MarkSurface, type ResolvedMark, resolveMark, tintClass } from "./brandMark";
|
|
3
3
|
|
|
4
4
|
export interface BrandLockupProps {
|
|
5
5
|
brand: Brand;
|
|
@@ -31,9 +31,15 @@ function MarkImage({ mark, surface }: { mark: ResolvedMark; surface?: "light" |
|
|
|
31
31
|
* The header's mark: a glyph tile, or the image each surface resolves to
|
|
32
32
|
* (`resolveMark`), one per surface, each shown on its own bar by chrome.css.
|
|
33
33
|
* When both surfaces draw the same image the same way, it is drawn once.
|
|
34
|
+
* Given a `surface`, it draws that surface's image alone, for a place that
|
|
35
|
+
* only ever wears one ground (the footer's dark band).
|
|
34
36
|
*/
|
|
35
|
-
function Mark({ logo }: { logo?: BrandLogo }) {
|
|
37
|
+
function Mark({ logo, surface }: { logo?: BrandLogo; surface?: MarkSurface }) {
|
|
36
38
|
if (logo?.tile) return <LogoTile glyph={logo.tile} />;
|
|
39
|
+
if (surface) {
|
|
40
|
+
const mark = resolveMark(logo, surface);
|
|
41
|
+
return mark ? <MarkImage mark={mark} /> : null;
|
|
42
|
+
}
|
|
37
43
|
const light = resolveMark(logo, "light");
|
|
38
44
|
const dark = resolveMark(logo, "dark");
|
|
39
45
|
if (!light || !dark) return null;
|
|
@@ -57,6 +63,32 @@ export function lockupWords(name: string, logo: BrandLogo | undefined): string |
|
|
|
57
63
|
return logo?.wordmark ?? name;
|
|
58
64
|
}
|
|
59
65
|
|
|
66
|
+
/**
|
|
67
|
+
* The lockup's parts, in the order the header draws them: the mark, the
|
|
68
|
+
* live words beside it (`lockupWords`), and the trailing run. The header
|
|
69
|
+
* wraps them in its home link; the footer sets them on its dark band, passing
|
|
70
|
+
* `surface` so only that ground's image is drawn. The mark's image carries
|
|
71
|
+
* empty alt text, since the words beside it name the lockup.
|
|
72
|
+
*/
|
|
73
|
+
export function LockupParts({
|
|
74
|
+
name,
|
|
75
|
+
logo,
|
|
76
|
+
surface,
|
|
77
|
+
}: {
|
|
78
|
+
name: string;
|
|
79
|
+
logo?: BrandLogo;
|
|
80
|
+
surface?: MarkSurface;
|
|
81
|
+
}) {
|
|
82
|
+
const wordmark = lockupWords(name, logo);
|
|
83
|
+
return (
|
|
84
|
+
<>
|
|
85
|
+
<Mark logo={logo} surface={surface} />
|
|
86
|
+
{wordmark !== null && <span className="wordmark">{wordmark}</span>}
|
|
87
|
+
{logo?.run && <span className="wordmark-run" aria-hidden="true" />}
|
|
88
|
+
</>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
60
92
|
/**
|
|
61
93
|
* The header's identity as one link: the mark (a glyph tile or an image),
|
|
62
94
|
* the wordmark, and the trailing run. The image carries empty alt text
|
|
@@ -81,9 +113,7 @@ export function BrandLockup({ brand, ariaLabel }: BrandLockupProps) {
|
|
|
81
113
|
const label = ariaLabel ?? (recipient ? `${words} × ${recipient.alt} home` : `${words} home`);
|
|
82
114
|
return (
|
|
83
115
|
<a className="nav-logo" href={href} aria-label={label}>
|
|
84
|
-
<
|
|
85
|
-
{wordmark !== null && <span className="wordmark">{wordmark}</span>}
|
|
86
|
-
{logo?.run && <span className="wordmark-run" aria-hidden="true" />}
|
|
116
|
+
<LockupParts name={name} logo={logo} />
|
|
87
117
|
{recipient && (
|
|
88
118
|
<>
|
|
89
119
|
<span className="nav-x" aria-hidden="true">
|
|
@@ -2,6 +2,7 @@ import { ChevronRight, MessageCircle, X } from "lucide-react";
|
|
|
2
2
|
import { type RefObject, useEffect, useId, useRef, useState } from "react";
|
|
3
3
|
import { useDismiss } from "../hooks/useDismiss";
|
|
4
4
|
import { newTabProps } from "../lib/newTabProps";
|
|
5
|
+
import { holdPhoneNumbers, isTel } from "../lib/phoneText";
|
|
5
6
|
import type { ContactDockConfig } from "../types";
|
|
6
7
|
import { dockIcons } from "./icons";
|
|
7
8
|
|
|
@@ -21,6 +22,13 @@ export interface ContactDockProps extends ContactDockConfig {
|
|
|
21
22
|
* `.sticky-cta`. `null` lifts over nothing.
|
|
22
23
|
*/
|
|
23
24
|
lift?: string | null;
|
|
25
|
+
/**
|
|
26
|
+
* A selector for the fixed header the launcher never rises into: as the
|
|
27
|
+
* dock lifts over a tall footer it stops just under the header's bottom
|
|
28
|
+
* edge. Defaults to the package's own header (`header.nav`); `null`
|
|
29
|
+
* reads the screen's top edge alone.
|
|
30
|
+
*/
|
|
31
|
+
header?: string | null;
|
|
24
32
|
/**
|
|
25
33
|
* Whether the dock tracks the page: it lifts over the phone's sticky bar
|
|
26
34
|
* once that bar shows, and rises above the footer. Off holds it at its
|
|
@@ -39,6 +47,9 @@ export interface ContactDockProps extends ContactDockConfig {
|
|
|
39
47
|
defaultOpen?: boolean;
|
|
40
48
|
}
|
|
41
49
|
|
|
50
|
+
/** The default header: the package's own fixed bar. */
|
|
51
|
+
const DEFAULT_HEADER = "header.nav";
|
|
52
|
+
|
|
42
53
|
/** The default lift: the package's own bar, or a site's bar of the old class. */
|
|
43
54
|
const DEFAULT_LIFT = "[data-dock-lift], .sticky-cta";
|
|
44
55
|
|
|
@@ -64,14 +75,17 @@ const LAUNCHER_HEIGHT = 52;
|
|
|
64
75
|
* The corner the dock sits in: the same inset from the right and the bottom
|
|
65
76
|
* edge (16 on a phone, 24 above), lifted over the phone's sticky bar once
|
|
66
77
|
* that bar is showing, and never over the footer: as the footer's top edge
|
|
67
|
-
* comes up the viewport, the dock rides up to stay just above it
|
|
68
|
-
*
|
|
78
|
+
* comes up the viewport, the dock rides up to stay just above it, until it
|
|
79
|
+
* reaches the fixed header: it never rises into the header, and a footer
|
|
80
|
+
* taller than the room left holds it there rather than chasing the footer.
|
|
81
|
+
* Exported for the tests; a site never calls it.
|
|
69
82
|
*/
|
|
70
83
|
export function dockPlacement({
|
|
71
84
|
viewportWidth,
|
|
72
85
|
viewportHeight,
|
|
73
86
|
barHeight,
|
|
74
87
|
avoidTop,
|
|
88
|
+
headerBottom = 0,
|
|
75
89
|
}: {
|
|
76
90
|
viewportWidth: number;
|
|
77
91
|
viewportHeight: number;
|
|
@@ -79,15 +93,19 @@ export function dockPlacement({
|
|
|
79
93
|
barHeight: number;
|
|
80
94
|
/** The avoided element's top edge in the viewport, or null when there is none. */
|
|
81
95
|
avoidTop: number | null;
|
|
96
|
+
/** The fixed header's bottom edge in the viewport, or 0 with no header. */
|
|
97
|
+
headerBottom?: number;
|
|
82
98
|
}): { inset: number; bottom: number } {
|
|
83
99
|
const phone = viewportWidth <= PHONE_MAX;
|
|
84
100
|
const inset = phone ? 16 : 24;
|
|
85
101
|
const overBar = phone && barHeight > 0 ? barHeight + inset : inset;
|
|
86
102
|
const covered = avoidTop === null ? 0 : Math.max(0, viewportHeight - avoidTop);
|
|
87
103
|
const overFooter = covered > 0 ? covered + inset : 0;
|
|
88
|
-
// Never past the top of the screen: a footer taller
|
|
89
|
-
//
|
|
90
|
-
|
|
104
|
+
// Never into the header, nor past the top of the screen: a footer taller
|
|
105
|
+
// than the room left holds the launcher just under the header (the
|
|
106
|
+
// burger's row on a phone), still reachable and covering nothing of it.
|
|
107
|
+
const top = Math.max(0, headerBottom);
|
|
108
|
+
const ceiling = Math.max(inset, viewportHeight - top - LAUNCHER_HEIGHT - inset);
|
|
91
109
|
return { inset, bottom: Math.round(Math.min(ceiling, Math.max(overBar, overFooter))) };
|
|
92
110
|
}
|
|
93
111
|
|
|
@@ -108,6 +126,7 @@ export function ContactDock({
|
|
|
108
126
|
footnote,
|
|
109
127
|
avoid = "footer",
|
|
110
128
|
lift = DEFAULT_LIFT,
|
|
129
|
+
header = DEFAULT_HEADER,
|
|
111
130
|
track = true,
|
|
112
131
|
closeLabel = "Close",
|
|
113
132
|
panelCloseLabel = "Close panel",
|
|
@@ -135,6 +154,7 @@ export function ContactDock({
|
|
|
135
154
|
// the page's elements change, never on a scroll frame.
|
|
136
155
|
let bar: HTMLElement | null = null;
|
|
137
156
|
let footer: Element | null = null;
|
|
157
|
+
let head: Element | null = null;
|
|
138
158
|
const measure = () => {
|
|
139
159
|
const showing = barShowing(bar);
|
|
140
160
|
const next = dockPlacement({
|
|
@@ -142,6 +162,7 @@ export function ContactDock({
|
|
|
142
162
|
viewportHeight: window.innerHeight,
|
|
143
163
|
barHeight: showing && bar ? bar.getBoundingClientRect().height : 0,
|
|
144
164
|
avoidTop: footer ? footer.getBoundingClientRect().top : null,
|
|
165
|
+
headerBottom: head ? head.getBoundingClientRect().bottom : 0,
|
|
145
166
|
});
|
|
146
167
|
setPlace((current) =>
|
|
147
168
|
current && current.inset === next.inset && current.bottom === next.bottom ? current : next,
|
|
@@ -158,6 +179,7 @@ export function ContactDock({
|
|
|
158
179
|
const shows =
|
|
159
180
|
typeof MutationObserver === "undefined" ? undefined : new MutationObserver(schedule);
|
|
160
181
|
const findBar = () => (lift ? document.querySelector<HTMLElement>(lift) : null);
|
|
182
|
+
const findHeader = () => (header ? document.querySelector(header) : null);
|
|
161
183
|
const findFooter = () =>
|
|
162
184
|
avoid === null
|
|
163
185
|
? null
|
|
@@ -167,6 +189,7 @@ export function ContactDock({
|
|
|
167
189
|
const bind = () => {
|
|
168
190
|
bar = findBar();
|
|
169
191
|
footer = findFooter();
|
|
192
|
+
head = findHeader();
|
|
170
193
|
sizes?.disconnect();
|
|
171
194
|
shows?.disconnect();
|
|
172
195
|
// The page's own height moves the footer (a late image, an opened
|
|
@@ -186,7 +209,7 @@ export function ContactDock({
|
|
|
186
209
|
// two selectors again: the dock rebinds, observing and measuring anew,
|
|
187
210
|
// only when the bar or the footer it finds is not the one it holds.
|
|
188
211
|
const check = () => {
|
|
189
|
-
if (findBar() !== bar || findFooter() !== footer) bind();
|
|
212
|
+
if (findBar() !== bar || findFooter() !== footer || findHeader() !== head) bind();
|
|
190
213
|
};
|
|
191
214
|
// The dock's own changes (its icon swapping as it opens) never move the bar
|
|
192
215
|
// or the footer, so they are not looked at.
|
|
@@ -211,7 +234,7 @@ export function ContactDock({
|
|
|
211
234
|
shows?.disconnect();
|
|
212
235
|
added?.disconnect();
|
|
213
236
|
};
|
|
214
|
-
}, [avoid, lift, track]);
|
|
237
|
+
}, [avoid, lift, header, track]);
|
|
215
238
|
|
|
216
239
|
useDismiss(open, rootRef, (reason) => {
|
|
217
240
|
setOpen(false);
|
|
@@ -250,9 +273,13 @@ export function ContactDock({
|
|
|
250
273
|
>
|
|
251
274
|
<div className="cd-head">
|
|
252
275
|
<div className="cd-head-text">
|
|
253
|
-
|
|
276
|
+
{/* A heading by role, never an h2 element: a site's heading rules
|
|
277
|
+
and the brand's heading tokens are for its page titles, not
|
|
278
|
+
this small label (Component Rules 21). */}
|
|
279
|
+
{/* biome-ignore lint/a11y/useSemanticElements: an h2 element would take a site's heading rules and tokens, see above */}
|
|
280
|
+
<div className="cd-title" id={headingId} role="heading" aria-level={2}>
|
|
254
281
|
{heading}
|
|
255
|
-
</
|
|
282
|
+
</div>
|
|
256
283
|
{subtitle && <p className="cd-sub">{subtitle}</p>}
|
|
257
284
|
</div>
|
|
258
285
|
<button
|
|
@@ -268,23 +295,28 @@ export function ContactDock({
|
|
|
268
295
|
</button>
|
|
269
296
|
</div>
|
|
270
297
|
<ul className="cd-items">
|
|
271
|
-
{items.map((item) => {
|
|
298
|
+
{items.map((item, at) => {
|
|
272
299
|
const Icon = dockIcons[item.icon ?? "chat"];
|
|
300
|
+
// A call row holds its number whole and wraps its words.
|
|
301
|
+
const words = (text: string) => (isTel(item.href) ? holdPhoneNumbers(text) : text);
|
|
273
302
|
const inner = (
|
|
274
303
|
<>
|
|
275
304
|
<span className="cd-item-icon">
|
|
276
305
|
<Icon size={20} aria-hidden="true" />
|
|
277
306
|
</span>
|
|
278
307
|
<span className="cd-item-text">
|
|
279
|
-
<span className="cd-item-label">{item.label}</span>
|
|
280
|
-
{item.description &&
|
|
308
|
+
<span className="cd-item-label">{words(item.label)}</span>
|
|
309
|
+
{item.description && (
|
|
310
|
+
<span className="cd-item-desc">{words(item.description)}</span>
|
|
311
|
+
)}
|
|
281
312
|
</span>
|
|
282
313
|
<ChevronRight className="cd-item-go" size={18} aria-hidden="true" />
|
|
283
314
|
</>
|
|
284
315
|
);
|
|
285
316
|
const className = ["cd-item", item.lead && "is-lead"].filter(Boolean).join(" ");
|
|
286
317
|
return (
|
|
287
|
-
|
|
318
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: two items may share a label or a link, so the place keeps the key unique; items never reorder
|
|
319
|
+
<li key={at}>
|
|
288
320
|
{item.href !== undefined ? (
|
|
289
321
|
<a
|
|
290
322
|
className={className}
|