@auscera/design-labs 0.0.0-stage → 0.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/apps/workspace/.skills/design-labs/SKILL.md +63 -0
- package/apps/workspace/.skills/design-labs/references/commands.md +38 -0
- package/apps/workspace/AGENTS.md +9 -0
- package/apps/workspace/app/(lab)/compare/page.tsx +2 -0
- package/apps/workspace/app/(lab)/lab.css +412 -0
- package/apps/workspace/app/(lab)/layout.tsx +21 -0
- package/apps/workspace/app/(lab)/page.tsx +2 -0
- package/apps/workspace/app/api/annotations/route.ts +94 -0
- package/apps/workspace/app/api/versions/events/route.ts +63 -0
- package/apps/workspace/app/api/versions/route.ts +7 -0
- package/apps/workspace/components/animated-icons.tsx +72 -0
- package/apps/workspace/components/dotmatrix-loader.css +1228 -0
- package/apps/workspace/components/glass-controls.tsx +47 -0
- package/apps/workspace/components/lab-providers.tsx +17 -0
- package/apps/workspace/components/molecules/brand-lockup.tsx +13 -0
- package/apps/workspace/components/molecules/pane-url-popover.css +92 -0
- package/apps/workspace/components/molecules/pane-url-popover.tsx +191 -0
- package/apps/workspace/components/pane-preferences.tsx +75 -0
- package/apps/workspace/components/pane-viewport.css +34 -0
- package/apps/workspace/components/pane-viewport.tsx +199 -0
- package/apps/workspace/components/preview-pane.css +293 -0
- package/apps/workspace/components/preview-pane.tsx +662 -0
- package/apps/workspace/components/ui/dotm-triangle-11.tsx +170 -0
- package/apps/workspace/components/ui/dotmatrix-core.tsx +1649 -0
- package/apps/workspace/components/ui/dotmatrix-hooks.ts +224 -0
- package/apps/workspace/components/version-select.tsx +220 -0
- package/apps/workspace/components/workspace.tsx +313 -0
- package/apps/workspace/eslint.config.mjs +3 -0
- package/apps/workspace/lab.config.json +1 -0
- package/apps/workspace/lib/annotation-export.ts +28 -0
- package/apps/workspace/lib/annotation-types.ts +38 -0
- package/apps/workspace/lib/device-presets.ts +103 -0
- package/apps/workspace/lib/use-annotation-bridge.ts +130 -0
- package/apps/workspace/lib/version-types.ts +12 -0
- package/apps/workspace/lib/website-url.ts +78 -0
- package/apps/workspace/next-env.d.ts +6 -0
- package/apps/workspace/next.config.mjs +1 -0
- package/apps/workspace/package.json +35 -0
- package/apps/workspace/public/apple-touch-icon.png +0 -0
- package/apps/workspace/public/brand/design-labs-script.LICENSE.txt +93 -0
- package/apps/workspace/public/brand/design-labs-script.woff2 +0 -0
- package/apps/workspace/public/brand/logo.webp +0 -0
- package/apps/workspace/public/brand/wordmark.css +42 -0
- package/apps/workspace/public/favicon.ico +0 -0
- package/apps/workspace/public/icon-192.png +0 -0
- package/apps/workspace/public/icon-512.png +0 -0
- package/apps/workspace/public/preview-bridge.js +411 -0
- package/apps/workspace/public/site.webmanifest +1 -0
- package/apps/workspace/scripts/annotation-store.mjs +308 -0
- package/apps/workspace/scripts/lab.mjs +414 -0
- package/apps/workspace/scripts/migrate.mjs +2 -0
- package/apps/workspace/scripts/prepare-preview.mjs +203 -0
- package/apps/workspace/tsconfig.json +24 -0
- package/package.json +9 -3
- package/scripts/install.mjs +67 -0
- package/scripts/update.mjs +204 -0
- package/README.md +0 -3
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
|
|
5
|
+
import type { DotMatrixPhase } from "./dotmatrix-core";
|
|
6
|
+
|
|
7
|
+
export function usePrefersReducedMotion(): boolean {
|
|
8
|
+
const [prefersReducedMotion, setPrefersReducedMotion] = useState(false);
|
|
9
|
+
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const query = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
12
|
+
|
|
13
|
+
const update = () => {
|
|
14
|
+
setPrefersReducedMotion(query.matches);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
update();
|
|
18
|
+
query.addEventListener("change", update);
|
|
19
|
+
|
|
20
|
+
return () => {
|
|
21
|
+
query.removeEventListener("change", update);
|
|
22
|
+
};
|
|
23
|
+
}, []);
|
|
24
|
+
|
|
25
|
+
return prefersReducedMotion;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface UseCyclePhaseOptions {
|
|
29
|
+
active: boolean;
|
|
30
|
+
cycleMsBase: number;
|
|
31
|
+
speed?: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function useCyclePhase({ active, cycleMsBase, speed = 1 }: UseCyclePhaseOptions): number {
|
|
35
|
+
const [phase, setPhase] = useState(0);
|
|
36
|
+
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (!active) {
|
|
39
|
+
setPhase(0);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const safeSpeed = speed > 0 ? speed : 1;
|
|
44
|
+
const raw = cycleMsBase / safeSpeed;
|
|
45
|
+
const cycleMs = raw > 0 && Number.isFinite(raw) ? raw : 1000;
|
|
46
|
+
const start = performance.now();
|
|
47
|
+
let rafId = 0;
|
|
48
|
+
|
|
49
|
+
const tick = (now: number) => {
|
|
50
|
+
const elapsed = ((now - start) % cycleMs + cycleMs) % cycleMs;
|
|
51
|
+
setPhase(elapsed / cycleMs);
|
|
52
|
+
rafId = requestAnimationFrame(tick);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
rafId = requestAnimationFrame(tick);
|
|
56
|
+
return () => cancelAnimationFrame(rafId);
|
|
57
|
+
}, [active, cycleMsBase, speed]);
|
|
58
|
+
|
|
59
|
+
return phase;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
interface UseSteppedCycleOptions {
|
|
63
|
+
active: boolean;
|
|
64
|
+
cycleMsBase: number;
|
|
65
|
+
steps: number;
|
|
66
|
+
speed?: number;
|
|
67
|
+
idleStep?: number;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
type FrameListener = (now: number) => void;
|
|
71
|
+
|
|
72
|
+
const listeners = new Set<FrameListener>();
|
|
73
|
+
let rafId: number | null = null;
|
|
74
|
+
|
|
75
|
+
function emit(now: number) {
|
|
76
|
+
listeners.forEach((listener) => {
|
|
77
|
+
listener(now);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function tick(now: number) {
|
|
82
|
+
emit(now);
|
|
83
|
+
if (listeners.size > 0) {
|
|
84
|
+
rafId = window.requestAnimationFrame(tick);
|
|
85
|
+
} else {
|
|
86
|
+
rafId = null;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function subscribeFrame(listener: FrameListener) {
|
|
91
|
+
listeners.add(listener);
|
|
92
|
+
if (rafId === null) {
|
|
93
|
+
rafId = window.requestAnimationFrame(tick);
|
|
94
|
+
}
|
|
95
|
+
return () => {
|
|
96
|
+
listeners.delete(listener);
|
|
97
|
+
if (listeners.size === 0 && rafId !== null) {
|
|
98
|
+
window.cancelAnimationFrame(rafId);
|
|
99
|
+
rafId = null;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function useSteppedCycle({
|
|
105
|
+
active,
|
|
106
|
+
cycleMsBase,
|
|
107
|
+
steps,
|
|
108
|
+
speed = 1,
|
|
109
|
+
idleStep = 0
|
|
110
|
+
}: UseSteppedCycleOptions): number {
|
|
111
|
+
const safeSteps = Math.max(1, Math.floor(steps));
|
|
112
|
+
const safeSpeed = speed > 0 ? speed : 1;
|
|
113
|
+
const rawCycleMs = cycleMsBase / safeSpeed;
|
|
114
|
+
const rawStepMs = rawCycleMs / safeSteps;
|
|
115
|
+
const stepMs = rawStepMs > 0 && Number.isFinite(rawStepMs) ? rawStepMs : 1;
|
|
116
|
+
const cycleMs = stepMs * safeSteps;
|
|
117
|
+
|
|
118
|
+
const [step, setStep] = useState(() => (active ? 0 : idleStep));
|
|
119
|
+
const startMsRef = useRef<number>(0);
|
|
120
|
+
const activeRef = useRef(false);
|
|
121
|
+
const currentStepRef = useRef(idleStep);
|
|
122
|
+
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
if (!active) {
|
|
125
|
+
activeRef.current = false;
|
|
126
|
+
currentStepRef.current = idleStep;
|
|
127
|
+
setStep(idleStep);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const updateStep = (now: number) => {
|
|
132
|
+
if (!activeRef.current) {
|
|
133
|
+
startMsRef.current = now;
|
|
134
|
+
activeRef.current = true;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const elapsed = Math.max(0, now - startMsRef.current);
|
|
138
|
+
const nextStep = Math.floor((elapsed % cycleMs) / stepMs) % safeSteps;
|
|
139
|
+
if (nextStep !== currentStepRef.current) {
|
|
140
|
+
currentStepRef.current = nextStep;
|
|
141
|
+
setStep(nextStep);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
updateStep(performance.now());
|
|
146
|
+
return subscribeFrame(updateStep);
|
|
147
|
+
}, [active, cycleMs, idleStep, safeSteps, stepMs]);
|
|
148
|
+
|
|
149
|
+
return active ? step : idleStep;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
interface UseDotMatrixPhasesOptions {
|
|
153
|
+
animated?: boolean;
|
|
154
|
+
hoverAnimated?: boolean;
|
|
155
|
+
speed?: number;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
interface DotMatrixPhasesResult {
|
|
159
|
+
phase: DotMatrixPhase;
|
|
160
|
+
onMouseEnter: () => void;
|
|
161
|
+
onMouseLeave: () => void;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export function useDotMatrixPhases({
|
|
165
|
+
animated = false,
|
|
166
|
+
hoverAnimated = false,
|
|
167
|
+
speed = 1
|
|
168
|
+
}: UseDotMatrixPhasesOptions): DotMatrixPhasesResult {
|
|
169
|
+
const safeSpeed = speed > 0 ? speed : 1;
|
|
170
|
+
const autoRun = Boolean(animated && !hoverAnimated);
|
|
171
|
+
const [hoverPhase, setHoverPhase] = useState<DotMatrixPhase>("idle");
|
|
172
|
+
const timeouts = useRef<number[]>([]);
|
|
173
|
+
const hoverGen = useRef(0);
|
|
174
|
+
|
|
175
|
+
const clearTimers = useCallback(() => {
|
|
176
|
+
for (let i = 0; i < timeouts.current.length; i += 1) {
|
|
177
|
+
window.clearTimeout(timeouts.current[i]!);
|
|
178
|
+
}
|
|
179
|
+
timeouts.current = [];
|
|
180
|
+
}, []);
|
|
181
|
+
|
|
182
|
+
useEffect(() => {
|
|
183
|
+
hoverGen.current += 1;
|
|
184
|
+
clearTimers();
|
|
185
|
+
return clearTimers;
|
|
186
|
+
}, [autoRun, hoverAnimated, clearTimers]);
|
|
187
|
+
|
|
188
|
+
const onMouseEnter = useCallback(() => {
|
|
189
|
+
if (!hoverAnimated || autoRun) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
clearTimers();
|
|
193
|
+
const gen = ++hoverGen.current;
|
|
194
|
+
setHoverPhase("collapse");
|
|
195
|
+
const collapseMs = Math.max(1, Math.round(300 / safeSpeed));
|
|
196
|
+
const id = window.setTimeout(() => {
|
|
197
|
+
if (hoverGen.current !== gen) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
setHoverPhase("hoverRipple");
|
|
201
|
+
}, collapseMs);
|
|
202
|
+
timeouts.current.push(id);
|
|
203
|
+
}, [hoverAnimated, autoRun, safeSpeed, clearTimers]);
|
|
204
|
+
|
|
205
|
+
const onMouseLeave = useCallback(() => {
|
|
206
|
+
if (!hoverAnimated || autoRun) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
hoverGen.current += 1;
|
|
210
|
+
clearTimers();
|
|
211
|
+
setHoverPhase("idle");
|
|
212
|
+
}, [hoverAnimated, autoRun, clearTimers]);
|
|
213
|
+
|
|
214
|
+
const phase: DotMatrixPhase = autoRun ? "loadingRipple" : hoverAnimated ? hoverPhase : "idle";
|
|
215
|
+
|
|
216
|
+
return useMemo(
|
|
217
|
+
() => ({
|
|
218
|
+
phase,
|
|
219
|
+
onMouseEnter,
|
|
220
|
+
onMouseLeave
|
|
221
|
+
}),
|
|
222
|
+
[phase, onMouseEnter, onMouseLeave]
|
|
223
|
+
);
|
|
224
|
+
}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
5
|
+
import { Check, ChevronDown, Link, Pencil } from "./animated-icons";
|
|
6
|
+
|
|
7
|
+
import { formatWebsiteUrl } from "../lib/website-url";
|
|
8
|
+
export const URL_OPTION_KEY = "@design-labs:url";
|
|
9
|
+
type UrlChoice = {
|
|
10
|
+
value: string;
|
|
11
|
+
active: boolean;
|
|
12
|
+
onSelect: (anchor: HTMLButtonElement) => void;
|
|
13
|
+
onEdit: (anchor: HTMLButtonElement) => void;
|
|
14
|
+
};
|
|
15
|
+
type Option = { key: string; label: string; production?: boolean };
|
|
16
|
+
|
|
17
|
+
/** A portalled glass listbox keeps the popup outside clipped pane frames. */
|
|
18
|
+
export function VersionSelect({
|
|
19
|
+
options: versions,
|
|
20
|
+
value: versionValue,
|
|
21
|
+
url,
|
|
22
|
+
onChange,
|
|
23
|
+
}: {
|
|
24
|
+
options: Option[];
|
|
25
|
+
value: string;
|
|
26
|
+
url?: UrlChoice;
|
|
27
|
+
onChange: (value: string) => void;
|
|
28
|
+
}) {
|
|
29
|
+
const options: Option[] = url
|
|
30
|
+
? [
|
|
31
|
+
...versions,
|
|
32
|
+
{
|
|
33
|
+
key: URL_OPTION_KEY,
|
|
34
|
+
label: url.value ? formatWebsiteUrl(url.value) : "Website URL…",
|
|
35
|
+
},
|
|
36
|
+
]
|
|
37
|
+
: versions;
|
|
38
|
+
const value = url?.active ? URL_OPTION_KEY : versionValue;
|
|
39
|
+
const id = useId();
|
|
40
|
+
const trigger = useRef<HTMLButtonElement>(null);
|
|
41
|
+
const menu = useRef<HTMLDivElement>(null);
|
|
42
|
+
const [open, setOpen] = useState(false);
|
|
43
|
+
const [active, setActive] = useState(0);
|
|
44
|
+
const [position, setPosition] = useState({
|
|
45
|
+
left: 0,
|
|
46
|
+
top: 0,
|
|
47
|
+
width: 240,
|
|
48
|
+
maxHeight: 280,
|
|
49
|
+
});
|
|
50
|
+
const hasSavedUrl = Boolean(url?.value);
|
|
51
|
+
const selected = options.findIndex((option) => option.key === value);
|
|
52
|
+
const label = (option: Option) =>
|
|
53
|
+
`${option.label}${option.production && !/^production\b/i.test(option.label) ? " · Production" : ""}`;
|
|
54
|
+
function reveal(index = Math.max(selected, 0)) {
|
|
55
|
+
setActive(index);
|
|
56
|
+
setOpen(true);
|
|
57
|
+
}
|
|
58
|
+
function choose(index: number) {
|
|
59
|
+
if (options[index]?.key === URL_OPTION_KEY && url && trigger.current)
|
|
60
|
+
url.onSelect(trigger.current);
|
|
61
|
+
else if (options[index]) onChange(options[index].key);
|
|
62
|
+
setOpen(false);
|
|
63
|
+
trigger.current?.focus();
|
|
64
|
+
}
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
if (!open) return;
|
|
67
|
+
const place = () => {
|
|
68
|
+
const rect = trigger.current?.getBoundingClientRect();
|
|
69
|
+
if (!rect) return;
|
|
70
|
+
const width = Math.min(Math.max(rect.width, 280), window.innerWidth - 24);
|
|
71
|
+
const below = window.innerHeight - rect.bottom - 12;
|
|
72
|
+
const above = rect.top - 12;
|
|
73
|
+
const height = Math.min(
|
|
74
|
+
320,
|
|
75
|
+
options.length * 44 + 12 + (hasSavedUrl ? 40 : 0),
|
|
76
|
+
);
|
|
77
|
+
const upward = below < height && above > below;
|
|
78
|
+
const maxHeight = Math.max(48, Math.min(height, upward ? above : below));
|
|
79
|
+
setPosition({
|
|
80
|
+
left: Math.max(12, Math.min(rect.left, window.innerWidth - width - 12)),
|
|
81
|
+
top: upward ? rect.top - maxHeight - 6 : rect.bottom + 6,
|
|
82
|
+
width,
|
|
83
|
+
maxHeight,
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
const dismiss = (event: PointerEvent) => {
|
|
87
|
+
if (
|
|
88
|
+
!trigger.current?.contains(event.target as Node) &&
|
|
89
|
+
!menu.current?.contains(event.target as Node)
|
|
90
|
+
)
|
|
91
|
+
setOpen(false);
|
|
92
|
+
};
|
|
93
|
+
const blur = () => setOpen(false);
|
|
94
|
+
place();
|
|
95
|
+
window.addEventListener("resize", place);
|
|
96
|
+
window.addEventListener("scroll", place, true);
|
|
97
|
+
window.addEventListener("blur", blur);
|
|
98
|
+
document.addEventListener("pointerdown", dismiss);
|
|
99
|
+
return () => {
|
|
100
|
+
window.removeEventListener("resize", place);
|
|
101
|
+
window.removeEventListener("scroll", place, true);
|
|
102
|
+
window.removeEventListener("blur", blur);
|
|
103
|
+
document.removeEventListener("pointerdown", dismiss);
|
|
104
|
+
};
|
|
105
|
+
}, [open, options.length, hasSavedUrl]);
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
if (open)
|
|
108
|
+
menu.current
|
|
109
|
+
?.querySelector(`[data-index="${active}"]`)
|
|
110
|
+
?.scrollIntoView({ block: "nearest" });
|
|
111
|
+
}, [open, active]);
|
|
112
|
+
return (
|
|
113
|
+
<>
|
|
114
|
+
<button
|
|
115
|
+
ref={trigger}
|
|
116
|
+
type="button"
|
|
117
|
+
className="version-select"
|
|
118
|
+
role="combobox"
|
|
119
|
+
aria-label="Website version"
|
|
120
|
+
aria-haspopup="listbox"
|
|
121
|
+
aria-expanded={open}
|
|
122
|
+
aria-controls={open ? id : undefined}
|
|
123
|
+
aria-activedescendant={open ? `${id}-${active}` : undefined}
|
|
124
|
+
onClick={() => (open ? setOpen(false) : reveal())}
|
|
125
|
+
onKeyDown={(event) => {
|
|
126
|
+
if (
|
|
127
|
+
[
|
|
128
|
+
"ArrowDown",
|
|
129
|
+
"ArrowUp",
|
|
130
|
+
"Home",
|
|
131
|
+
"End",
|
|
132
|
+
"Enter",
|
|
133
|
+
" ",
|
|
134
|
+
"Escape",
|
|
135
|
+
].includes(event.key)
|
|
136
|
+
)
|
|
137
|
+
event.preventDefault();
|
|
138
|
+
if (event.key === "Escape" || event.key === "Tab") {
|
|
139
|
+
setOpen(false);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
143
|
+
if (open) choose(active);
|
|
144
|
+
else reveal();
|
|
145
|
+
} else if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
146
|
+
if (!open) reveal();
|
|
147
|
+
else
|
|
148
|
+
setActive(
|
|
149
|
+
(index) =>
|
|
150
|
+
(index +
|
|
151
|
+
(event.key === "ArrowDown" ? 1 : -1) +
|
|
152
|
+
options.length) %
|
|
153
|
+
options.length,
|
|
154
|
+
);
|
|
155
|
+
} else if (event.key === "Home") reveal(0);
|
|
156
|
+
else if (event.key === "End") reveal(options.length - 1);
|
|
157
|
+
else if (
|
|
158
|
+
event.key.length === 1 &&
|
|
159
|
+
!event.ctrlKey &&
|
|
160
|
+
!event.metaKey &&
|
|
161
|
+
!event.altKey
|
|
162
|
+
) {
|
|
163
|
+
const match = options.findIndex((option) =>
|
|
164
|
+
option.label.toLowerCase().startsWith(event.key.toLowerCase()),
|
|
165
|
+
);
|
|
166
|
+
if (match >= 0) reveal(match);
|
|
167
|
+
}
|
|
168
|
+
}}
|
|
169
|
+
>
|
|
170
|
+
<span title={url?.active ? url.value : undefined}>
|
|
171
|
+
{options[selected] ? label(options[selected]) : "Choose version"}
|
|
172
|
+
</span>
|
|
173
|
+
<ChevronDown size={14} aria-hidden />
|
|
174
|
+
</button>
|
|
175
|
+
{open &&
|
|
176
|
+
createPortal(
|
|
177
|
+
<div ref={menu} className="version-menu" style={position}>
|
|
178
|
+
<div id={id} role="listbox" aria-label="Website versions">
|
|
179
|
+
{options.map((option, index) => (
|
|
180
|
+
<div
|
|
181
|
+
key={option.key}
|
|
182
|
+
id={`${id}-${index}`}
|
|
183
|
+
data-index={index}
|
|
184
|
+
role="option"
|
|
185
|
+
aria-selected={value === option.key}
|
|
186
|
+
className={`version-option${active === index ? " is-active" : ""}`}
|
|
187
|
+
onPointerMove={() => setActive(index)}
|
|
188
|
+
onPointerDown={(event) => event.preventDefault()}
|
|
189
|
+
onClick={() => choose(index)}
|
|
190
|
+
>
|
|
191
|
+
{option.key === URL_OPTION_KEY && (
|
|
192
|
+
<Link size={14} aria-hidden />
|
|
193
|
+
)}
|
|
194
|
+
<span title={label(option)}>
|
|
195
|
+
{option.key === URL_OPTION_KEY
|
|
196
|
+
? `Website URL${url?.value ? ` · ${label(option)}` : "…"}`
|
|
197
|
+
: label(option)}
|
|
198
|
+
</span>
|
|
199
|
+
{value === option.key && <Check size={14} aria-hidden />}
|
|
200
|
+
</div>
|
|
201
|
+
))}
|
|
202
|
+
</div>
|
|
203
|
+
{url?.value && (
|
|
204
|
+
<button
|
|
205
|
+
className="button version-url-edit"
|
|
206
|
+
onClick={() => {
|
|
207
|
+
setOpen(false);
|
|
208
|
+
if (trigger.current) url.onEdit(trigger.current);
|
|
209
|
+
}}
|
|
210
|
+
>
|
|
211
|
+
<Pencil size={13} aria-hidden />
|
|
212
|
+
Edit website URL
|
|
213
|
+
</button>
|
|
214
|
+
)}
|
|
215
|
+
</div>,
|
|
216
|
+
document.body,
|
|
217
|
+
)}
|
|
218
|
+
</>
|
|
219
|
+
);
|
|
220
|
+
}
|