@superwall/studio 1.6.1 → 1.6.2

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.
Files changed (63) hide show
  1. package/README.md +27 -10
  2. package/dist/assets/index-BMe9fPdZ.css +1 -0
  3. package/dist/assets/index-Czsb6jZs.js +11 -0
  4. package/dist/index.html +3 -3
  5. package/dist/lib/components/Dialog.d.ts +7 -0
  6. package/dist/lib/components/EmptyState.d.ts +9 -0
  7. package/dist/lib/components/InlineCode.d.ts +2 -0
  8. package/dist/lib/components/PaywallToasts.d.ts +8 -0
  9. package/dist/lib/components/SuperwallLogo.d.ts +9 -0
  10. package/dist/lib/components/Tooltip.d.ts +3 -1
  11. package/dist/lib/components/chrome/TopBar.d.ts +2 -3
  12. package/dist/lib/components/controls.d.ts +10 -1
  13. package/dist/lib/components/icons.d.ts +30 -17
  14. package/dist/lib/components/menus/ActionMenu.d.ts +4 -1
  15. package/dist/lib/components/menus/Menu.d.ts +19 -0
  16. package/dist/lib/index.d.ts +3 -1
  17. package/dist/lib/index.js +2582 -2054
  18. package/dist/lib/lib/actions.d.ts +3 -2
  19. package/dist/lib/lib/contract.d.ts +4 -0
  20. package/dist/lib/lib/notify.d.ts +4 -1
  21. package/dist/lib/lib/promotion.d.ts +17 -0
  22. package/dist/lib/lib/steps.d.ts +2 -1
  23. package/dist/lib/lib/surfaces.d.ts +10 -4
  24. package/dist/lib/studio.css +1 -1
  25. package/package.json +2 -2
  26. package/src/StudioApp.tsx +3 -2
  27. package/src/components/Dialog.tsx +74 -0
  28. package/src/components/DownloadScreenshot.tsx +13 -20
  29. package/src/components/EmptyState.tsx +32 -0
  30. package/src/components/InlineCode.tsx +7 -0
  31. package/src/components/OpenInApp.tsx +15 -14
  32. package/src/components/PaywallToasts.tsx +44 -37
  33. package/src/components/PreviewOnDevice.tsx +61 -43
  34. package/src/components/SuperwallLogo.tsx +72 -0
  35. package/src/components/SurfaceCard.tsx +34 -18
  36. package/src/components/Tooltip.tsx +25 -2
  37. package/src/components/chrome/StudioShell.tsx +1 -1
  38. package/src/components/chrome/Toolbar.tsx +10 -8
  39. package/src/components/chrome/TopBar.tsx +21 -22
  40. package/src/components/controls.tsx +116 -31
  41. package/src/components/icons.tsx +140 -59
  42. package/src/components/menus/ActionMenu.tsx +221 -97
  43. package/src/components/menus/CompareMenu.tsx +48 -67
  44. package/src/components/menus/Menu.tsx +144 -0
  45. package/src/components/panels/MissingProducts.tsx +27 -34
  46. package/src/components/panels/SidePanel.tsx +9 -9
  47. package/src/components/panels/VariablesPanel.tsx +57 -49
  48. package/src/components/preview/DeviceFrame.tsx +4 -6
  49. package/src/index.ts +9 -0
  50. package/src/lib/actions.ts +13 -4
  51. package/src/lib/contract.ts +2 -0
  52. package/src/lib/notify.tsx +15 -18
  53. package/src/lib/project.ts +1 -0
  54. package/src/lib/promotion.ts +47 -0
  55. package/src/lib/steps.ts +9 -1
  56. package/src/lib/surfaces.ts +22 -2
  57. package/src/main.tsx +22 -10
  58. package/src/screens/SurfaceEditor.tsx +101 -63
  59. package/src/screens/SurfaceList.tsx +112 -69
  60. package/src/scroll-fade.css +425 -0
  61. package/src/styles.css +380 -182
  62. package/dist/assets/index-CTn2zVi-.js +0 -11
  63. package/dist/assets/index-DrsTCwot.css +0 -1
@@ -1,27 +1,38 @@
1
1
  import * as React from "react";
2
- import { ChevronDownIcon } from "../icons";
2
+ import { ChevronDownIcon, ChevronsUpDownIcon, SpinnerIcon } from "../icons";
3
+ import { timeAgo } from "../../lib/time";
4
+ import { Tooltip } from "../Tooltip";
5
+ import { MenuItem, MenuPopup, useDismiss } from "./Menu";
3
6
  import {
4
7
  ACTION_STEPS,
5
- STEP_LABELS,
8
+ stepLabel,
6
9
  type StudioActionStep,
7
10
  type StudioStepState,
8
11
  } from "../../lib/steps";
9
- import { type StudioActionName } from "../../lib/surfaces";
12
+ import {
13
+ PROMOTION_LABEL,
14
+ promotionBlocker,
15
+ promotionDirection,
16
+ promotionHint,
17
+ type Promotion,
18
+ type PromotionDirection,
19
+ } from "../../lib/promotion";
20
+ import { type StudioActionName, type StudioVersion } from "../../lib/surfaces";
10
21
 
11
- const ACTIONS: readonly { name: StudioActionName; label: string; hint: string }[] = [
12
- { name: "push", label: "Push", hint: "New version, nothing live changes" },
13
- { name: "promote", label: "Promote", hint: "Make the latest push live" },
14
- { name: "publish", label: "Publish", hint: "Push and make it live" },
15
- ];
22
+ const HINTS: Record<Exclude<StudioActionName, "promote">, string> = {
23
+ push: "New version, nothing live changes",
24
+ publish: "Push and make it live",
25
+ };
16
26
 
17
- const labelFor = (name: StudioActionName): string =>
18
- ACTIONS.find((action) => action.name === name)?.label ?? name;
27
+ const labelFor = (name: StudioActionName, direction: PromotionDirection): string =>
28
+ name === "push" ? "Push" : name === "publish" ? "Publish" : PROMOTION_LABEL[direction].label;
19
29
 
20
- const runningLabel: Record<StudioActionName, string> = {
21
- push: "Pushing…",
22
- publish: "Publishing…",
23
- promote: "Promoting…",
24
- };
30
+ const runningLabel = (name: StudioActionName, direction: PromotionDirection): string =>
31
+ name === "push"
32
+ ? "Pushing…"
33
+ : name === "publish"
34
+ ? "Publishing…"
35
+ : PROMOTION_LABEL[direction].running;
25
36
 
26
37
  export type ActionProgress = {
27
38
  action: StudioActionName;
@@ -29,61 +40,71 @@ export type ActionProgress = {
29
40
  error?: string;
30
41
  };
31
42
 
32
- const StepGlyph = ({ state }: { state: StudioStepState }) => {
33
- if (state === "active") return <span className="bg-accent h-2 w-2 rounded-full animate-pulse" />;
34
- if (state === "done") return <span className="bg-accent h-2 w-2 rounded-full" />;
35
- if (state === "failed") return <span className="bg-red h-2 w-2 rounded-full" />;
36
- return <span className="bg-cream/55 h-2 w-2 rounded-full" />;
43
+ const DOT: Record<Exclude<StudioStepState, "active">, string> = {
44
+ done: "bg-primary",
45
+ failed: "bg-destructive",
46
+ pending: "bg-fg-muted",
37
47
  };
38
48
 
39
- const ProgressPanel = ({ progress }: { progress: ActionProgress }) => {
49
+ const ProgressPanel = ({
50
+ progress,
51
+ direction,
52
+ target,
53
+ }: {
54
+ progress: ActionProgress;
55
+ direction: PromotionDirection;
56
+ target: number | undefined;
57
+ }) => {
40
58
  const steps = ACTION_STEPS[progress.action];
41
59
  const done = steps.filter((step) => progress.steps[step] === "done").length;
42
60
  const failed = progress.error !== undefined;
43
61
 
44
62
  return (
45
- <div className="w-64">
46
- <div className="border-b border-cream/10 px-3 py-2.5">
47
- <div className="text-[0.8125rem] font-medium">
63
+ <div className="flex w-72 max-w-full flex-col">
64
+ <div className="flex flex-col gap-2 p-3">
65
+ <span className="-mt-1 text-sm font-medium">
48
66
  {failed
49
- ? `${labelFor(progress.action)} failed`
67
+ ? `${labelFor(progress.action, direction)} failed`
50
68
  : done === steps.length
51
- ? `${labelFor(progress.action)} complete`
52
- : runningLabel[progress.action]}
53
- </div>
54
- <div className="mt-2 h-0.5 w-full bg-cream/10">
55
- <div
56
- className={`h-full transition-[width] duration-300 ease-out ${failed ? "bg-red" : "bg-accent"}`}
69
+ ? `${labelFor(progress.action, direction)} complete`
70
+ : runningLabel(progress.action, direction)}
71
+ </span>
72
+ <span className="block h-1 w-full overflow-hidden rounded-sm bg-muted">
73
+ <span
74
+ className={`block h-full transition-[width] duration-move ease-out ${failed ? "bg-destructive" : "bg-primary"}`}
57
75
  style={{ width: `${(done / steps.length) * 100}%` }}
58
76
  />
59
- </div>
77
+ </span>
60
78
  </div>
61
- <ul className="m-0 list-none px-3 py-2">
79
+ <ul className="m-0 flex list-none flex-col border-t border-border p-1">
62
80
  {steps.map((step, index) => {
63
81
  const state = progress.steps[step] ?? "pending";
64
82
  return (
65
- <li key={step} className="flex items-center gap-2.5 py-1.5">
66
- <span
67
- className={`w-4 font-mono text-[0.625rem] tabular-nums ${
68
- state === "pending" ? "text-cream/25" : "text-cream/55"
69
- }`}
70
- >
83
+ <li key={step} className="flex items-center gap-2 px-2.5 py-1">
84
+ <span className="w-4 text-xs text-fg-muted tabular-nums">
71
85
  {String(index + 1).padStart(2, "0")}
72
86
  </span>
73
87
  <span
74
- className={`flex-1 text-[0.8125rem] ${
75
- state === "pending" ? "text-cream/40" : "text-cream"
76
- }`}
88
+ className={`flex-1 text-sm ${state === "pending" ? "text-fg-tertiary" : "text-foreground"}`}
77
89
  >
78
- {STEP_LABELS[step]}
90
+ {stepLabel(step, progress.action === "promote" ? direction : "promote", target)}
79
91
  </span>
80
- <StepGlyph state={state} />
92
+ {state === "active" ? (
93
+ <span className="flex size-4 flex-none items-center justify-center text-primary">
94
+ <SpinnerIcon />
95
+ </span>
96
+ ) : (
97
+ <span className={`size-2 flex-none rounded-full ${DOT[state]}`} />
98
+ )}
81
99
  </li>
82
100
  );
83
101
  })}
84
102
  </ul>
85
103
  {progress.error && (
86
- <div className="text-red border-t border-cream/10 px-3 py-2.5 text-xs whitespace-pre-wrap">
104
+ <div
105
+ className="border-t border-border p-3 text-xs whitespace-pre-wrap text-destructive-foreground"
106
+ role="alert"
107
+ >
87
108
  {progress.error}
88
109
  </div>
89
110
  )}
@@ -91,84 +112,187 @@ const ProgressPanel = ({ progress }: { progress: ActionProgress }) => {
91
112
  );
92
113
  };
93
114
 
115
+ const versionLabel = (entry: StudioVersion): string =>
116
+ `v${entry.version}${entry.live ? " · Live" : ""}`;
117
+
118
+ const versionHint = (entry: StudioVersion): string => {
119
+ if (entry.live) return "What SDKs receive today";
120
+ const ago = entry.pushedAt ? timeAgo(entry.pushedAt) : undefined;
121
+ return ago ? `Pushed ${ago}` : "Pushed snapshot";
122
+ };
123
+
124
+ const SEGMENT = "sw-btn sw-btn--sm sw-btn--primary";
125
+
126
+ const VersionMenu = ({
127
+ versions,
128
+ target,
129
+ disabled,
130
+ onPick,
131
+ }: {
132
+ versions: readonly StudioVersion[];
133
+ target: number | undefined;
134
+ disabled: boolean;
135
+ onPick: (version: number) => void;
136
+ }) => {
137
+ const [open, setOpen] = React.useState(false);
138
+ const menuRef = React.useRef<HTMLDivElement>(null);
139
+ const popupRef = React.useRef<HTMLDivElement>(null);
140
+ const dismissRefs = React.useMemo(() => [menuRef, popupRef], []);
141
+ useDismiss(dismissRefs, open, () => setOpen(false));
142
+ const current = versions.find((entry) => entry.version === target);
143
+
144
+ return (
145
+ <div className="relative flex" ref={menuRef}>
146
+ <button
147
+ type="button"
148
+ className="sw-btn sw-btn--sm"
149
+ aria-label="Version"
150
+ aria-expanded={open}
151
+ disabled={disabled}
152
+ onClick={() => setOpen((value) => !value)}
153
+ >
154
+ {current ? versionLabel(current) : `v${target}`}
155
+ <ChevronsUpDownIcon className="icon-tertiary" />
156
+ </button>
157
+ {open && (
158
+ <MenuPopup popupRef={popupRef} anchor={menuRef} side="bottom" align="end" className="w-56">
159
+ <div className="flex max-h-64 scroll-fade flex-col overflow-y-auto p-1" data-menu-list="">
160
+ {versions.map((entry) => (
161
+ <MenuItem
162
+ key={entry.version}
163
+ label={versionLabel(entry)}
164
+ hint={versionHint(entry)}
165
+ selected={entry.version === target}
166
+ onSelect={() => {
167
+ setOpen(false);
168
+ onPick(entry.version);
169
+ }}
170
+ />
171
+ ))}
172
+ </div>
173
+ </MenuPopup>
174
+ )}
175
+ </div>
176
+ );
177
+ };
178
+
94
179
  export const ActionMenu = ({
180
+ offered,
181
+ promotion,
95
182
  progress,
96
183
  blocked,
97
184
  onRun,
98
185
  onBlocked,
99
186
  }: {
187
+ offered: readonly StudioActionName[];
188
+ promotion: Promotion;
100
189
  progress: ActionProgress | undefined;
101
190
  blocked?: string;
102
191
  onRun: (action: StudioActionName) => void;
103
192
  onBlocked?: () => void;
104
193
  }) => {
105
- const [selected, setSelected] = React.useState<StudioActionName>("push");
194
+ const [selected, setSelected] = React.useState<StudioActionName>(offered[0] ?? "push");
106
195
  const [open, setOpen] = React.useState(false);
107
196
  const menuRef = React.useRef<HTMLDivElement>(null);
108
197
 
109
- const stopped = blocked !== undefined;
198
+ const direction = promotionDirection(promotion.target, promotion.live);
199
+ const [run, setRun] = React.useState({ direction, target: promotion.target });
200
+ const ordered = [...promotion.versions].sort((a, b) => b.version - a.version);
201
+ const pick = promotion.pick;
202
+ const picker = pick !== undefined && ordered.length > 0;
203
+ const chooser = offered.length > 1;
204
+
205
+ const stop = selected === "promote" ? promotionBlocker(promotion) : blocked;
206
+ const stopped = stop !== undefined;
110
207
  const busy =
111
208
  progress !== undefined &&
112
209
  progress.error === undefined &&
113
210
  ACTION_STEPS[progress.action].some((step) => progress.steps[step] !== "done");
114
211
  const showPanel = progress !== undefined;
115
212
 
116
- React.useEffect(() => {
117
- if (!open) return undefined;
118
- const close = (event: MouseEvent) => {
119
- if (menuRef.current && !event.composedPath().includes(menuRef.current)) setOpen(false);
120
- };
121
- window.addEventListener("mousedown", close);
122
- return () => window.removeEventListener("mousedown", close);
123
- }, [open]);
213
+ const popupRef = React.useRef<HTMLDivElement>(null);
214
+ const dismissRefs = React.useMemo(() => [menuRef, popupRef], []);
215
+ useDismiss(dismissRefs, open, () => setOpen(false));
124
216
 
125
- return (
126
- <div className="relative flex" ref={menuRef}>
127
- <button
128
- type="button"
129
- className="sw-btn sw-btn--primary rounded-r-none disabled:cursor-not-allowed disabled:opacity-40"
130
- disabled={busy}
131
- title={blocked}
132
- onClick={() => (stopped ? onBlocked?.() : onRun(selected))}
133
- >
134
- {busy ? runningLabel[progress.action] : labelFor(selected)}
135
- </button>
136
- <button
137
- type="button"
138
- className="sw-btn sw-btn--primary -ml-px w-6 rounded-l-none !px-0 disabled:cursor-not-allowed disabled:opacity-40"
139
- aria-label="Choose action"
140
- aria-expanded={open}
141
- title={blocked}
142
- disabled={busy}
143
- onClick={() => setOpen((value) => !value)}
144
- >
145
- <ChevronDownIcon />
146
- </button>
217
+ const start = () => {
218
+ if (stopped) {
219
+ if (selected !== "promote") onBlocked?.();
220
+ return;
221
+ }
222
+ setRun({ direction, target: promotion.target });
223
+ onRun(selected);
224
+ };
225
+
226
+ const choose = (action: StudioActionName) => {
227
+ setSelected(action);
228
+ setOpen(false);
229
+ };
147
230
 
148
- {(showPanel || open) && (
149
- <div className="bg-bar absolute top-full right-0 z-20 mt-[calc(0.5rem+2px)] overflow-hidden rounded border border-cream/20">
150
- {showPanel ? (
151
- <ProgressPanel progress={progress} />
152
- ) : (
153
- <div className="w-64">
154
- {ACTIONS.map((action) => (
231
+ return (
232
+ <div className="flex items-center gap-2">
233
+ {picker && (
234
+ <VersionMenu
235
+ versions={ordered}
236
+ target={promotion.target}
237
+ disabled={busy}
238
+ onPick={(version) => {
239
+ pick(version);
240
+ if (offered.includes("promote")) setSelected("promote");
241
+ }}
242
+ />
243
+ )}
244
+ <div className="relative flex" ref={menuRef}>
245
+ <Tooltip hint={stop}>
246
+ <span className="flex">
247
+ <button
248
+ type="button"
249
+ className={`${SEGMENT} ${chooser ? "rounded-e-none border-e-0" : ""}`}
250
+ disabled={busy || (stopped && selected === "promote")}
251
+ aria-busy={busy || undefined}
252
+ onClick={start}
253
+ >
254
+ {busy && <SpinnerIcon />}
255
+ {busy ? runningLabel(progress.action, run.direction) : labelFor(selected, direction)}
256
+ </button>
257
+ {chooser && (
258
+ <>
259
+ <span aria-hidden="true" className="w-px bg-primary-foreground/24" />
155
260
  <button
156
- key={action.name}
157
261
  type="button"
158
- className="flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left transition-colors hover:bg-cream/5"
159
- onClick={() => {
160
- setSelected(action.name);
161
- setOpen(false);
162
- }}
262
+ className={`${SEGMENT} sw-btn--icon rounded-s-none border-s-0`}
263
+ aria-label="Choose action"
264
+ aria-expanded={open}
265
+ aria-busy={busy || undefined}
266
+ disabled={busy}
267
+ onClick={() => setOpen((value) => !value)}
163
268
  >
164
- <span className="text-[0.8125rem] font-medium">{action.label}</span>
165
- <span className="text-xs text-cream/55">{action.hint}</span>
269
+ <ChevronDownIcon />
166
270
  </button>
167
- ))}
168
- </div>
169
- )}
170
- </div>
171
- )}
271
+ </>
272
+ )}
273
+ </span>
274
+ </Tooltip>
275
+
276
+ {(showPanel || open) && (
277
+ <MenuPopup popupRef={popupRef} anchor={menuRef} side="bottom" align="end">
278
+ {showPanel ? (
279
+ <ProgressPanel progress={progress} direction={run.direction} target={run.target} />
280
+ ) : (
281
+ <div className="flex w-max min-w-56 flex-col p-1">
282
+ {offered.map((action) => (
283
+ <MenuItem
284
+ key={action}
285
+ label={labelFor(action, direction)}
286
+ hint={action === "promote" ? promotionHint(promotion) : HINTS[action]}
287
+ selected={action === selected}
288
+ onSelect={() => choose(action)}
289
+ />
290
+ ))}
291
+ </div>
292
+ )}
293
+ </MenuPopup>
294
+ )}
295
+ </div>
172
296
  </div>
173
297
  );
174
298
  };
@@ -1,5 +1,13 @@
1
1
  import * as React from "react";
2
- import { ColumnsIcon } from "../icons";
2
+ import { ColumnsIcon, SearchIcon } from "../icons";
3
+ import {
4
+ MenuGroupLabel,
5
+ MenuItem,
6
+ MenuPopup,
7
+ MenuSeparator,
8
+ useDismiss,
9
+ usePopupAlign,
10
+ } from "./Menu";
3
11
  import type { CompareTarget } from "../../lib/surfaces";
4
12
 
5
13
  export type CompareOption = {
@@ -9,39 +17,6 @@ export type CompareOption = {
9
17
  target: CompareTarget;
10
18
  };
11
19
 
12
- const Row = ({
13
- label,
14
- hint,
15
- selected,
16
- onSelect,
17
- }: {
18
- label: string;
19
- hint: string;
20
- selected: boolean;
21
- onSelect: () => void;
22
- }) => (
23
- <button
24
- type="button"
25
- className="flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left transition-colors hover:bg-cream/5"
26
- aria-current={selected || undefined}
27
- onClick={onSelect}
28
- >
29
- <span className="flex max-w-full items-center gap-1.5 text-[0.8125rem] font-medium">
30
- <span className="truncate">{label}</span>
31
- {selected && (
32
- <span className="bg-accent size-[5px] shrink-0 rounded-full" aria-hidden="true" />
33
- )}
34
- </span>
35
- <span className="max-w-full truncate text-xs text-cream/55">{hint}</span>
36
- </button>
37
- );
38
-
39
- const Heading = ({ children }: React.PropsWithChildren) => (
40
- <span className="block px-3 pt-2 pb-1 text-[0.6875rem] tracking-wide text-cream/45 uppercase">
41
- {children}
42
- </span>
43
- );
44
-
45
20
  export const CompareMenu = ({
46
21
  active,
47
22
  options,
@@ -57,14 +32,10 @@ export const CompareMenu = ({
57
32
  const [query, setQuery] = React.useState("");
58
33
  const menuRef = React.useRef<HTMLDivElement>(null);
59
34
 
60
- React.useEffect(() => {
61
- if (!open) return undefined;
62
- const close = (event: MouseEvent) => {
63
- if (menuRef.current && !event.composedPath().includes(menuRef.current)) setOpen(false);
64
- };
65
- window.addEventListener("mousedown", close);
66
- return () => window.removeEventListener("mousedown", close);
67
- }, [open]);
35
+ const popupRef = React.useRef<HTMLDivElement>(null);
36
+ const dismissRefs = React.useMemo(() => [menuRef, popupRef], []);
37
+ useDismiss(dismissRefs, open, () => setOpen(false));
38
+ const align = usePopupAlign(menuRef, open);
68
39
 
69
40
  React.useEffect(() => {
70
41
  if (!open) setQuery("");
@@ -89,10 +60,9 @@ export const CompareMenu = ({
89
60
  const origins = options.filter((option) => option.target.type === "origin").filter(matches);
90
61
  const versions = options.filter((option) => option.target.type === "version").filter(matches);
91
62
  const paywalls = options.filter((option) => option.target.type === "surface").filter(matches);
92
- const grouped = [origins, versions, paywalls].filter((group) => group.length > 0).length > 1;
93
63
  const rows = (group: CompareOption[]) =>
94
64
  group.map((option) => (
95
- <Row
65
+ <MenuItem
96
66
  key={option.key}
97
67
  label={option.label}
98
68
  hint={option.hint}
@@ -100,6 +70,12 @@ export const CompareMenu = ({
100
70
  onSelect={() => choose(option.target)}
101
71
  />
102
72
  ));
73
+ const groups = [
74
+ { label: "Rebuilt from", options: origins },
75
+ { label: "Versions", options: versions },
76
+ { label: "Paywalls", options: paywalls },
77
+ ].filter((group) => group.options.length > 0);
78
+ const grouped = groups.length > 1;
103
79
 
104
80
  return (
105
81
  <div className="relative flex" ref={menuRef}>
@@ -115,51 +91,56 @@ export const CompareMenu = ({
115
91
  </button>
116
92
 
117
93
  {open && (
118
- <div className="bg-bar absolute bottom-full left-0 z-20 mb-[calc(0.5rem+2px)] flex w-72 flex-col overflow-hidden rounded border border-cream/20">
119
- <div className="p-2">
94
+ <MenuPopup popupRef={popupRef} anchor={menuRef} side="top" align={align} className="w-72">
95
+ <label className="flex items-center gap-2.5 border-b border-border ps-3 pe-2.5">
96
+ <SearchIcon className="icon-tertiary" />
120
97
  <input
121
- className="sw-input"
98
+ className="h-9 min-w-0 flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-fg-muted"
122
99
  type="search"
123
100
  value={query}
124
101
  placeholder="Search versions and paywalls"
125
102
  aria-label="Search versions and paywalls"
126
103
  onChange={(event) => setQuery(event.target.value)}
127
104
  />
128
- </div>
105
+ </label>
129
106
 
130
- <div className="max-h-64 overflow-y-auto">
131
- {origins.length + versions.length + paywalls.length === 0 ? (
132
- <span className="block px-3 pt-2 pb-4 text-[0.8125rem] text-cream/45">
107
+ <div
108
+ className="flex max-h-64 scroll-fade flex-col gap-1.5 overflow-y-auto p-1"
109
+ data-menu-list=""
110
+ >
111
+ {groups.length === 0 ? (
112
+ <span className="block px-2.5 py-1 text-sm text-fg-tertiary">
133
113
  {needle === ""
134
- ? "No pushed versions or other paywalls here."
135
- : `Nothing matches “${query.trim()}”.`}
114
+ ? "No pushed versions or other paywalls"
115
+ : `No versions or paywalls match “${query.trim()}”`}
136
116
  </span>
137
117
  ) : (
138
- <>
139
- {grouped && origins.length > 0 && <Heading>Rebuilt from</Heading>}
140
- {rows(origins)}
141
- {grouped && versions.length > 0 && <Heading>Versions</Heading>}
142
- {rows(versions)}
143
- {grouped && paywalls.length > 0 && <Heading>Paywalls</Heading>}
144
- {rows(paywalls)}
145
- </>
118
+ groups.map((group) => (
119
+ <div key={group.label} className="flex flex-col">
120
+ {grouped && <MenuGroupLabel>{group.label}</MenuGroupLabel>}
121
+ {rows(group.options)}
122
+ </div>
123
+ ))
146
124
  )}
147
125
  </div>
148
126
 
149
- <div className="flex flex-col border-t border-cream/10">
127
+ <div className="flex flex-col border-t border-border p-1">
150
128
  {notice && (
151
- <span className="block px-3 pt-2 text-xs text-cream/55" role="status">
152
- {notice}
153
- </span>
129
+ <>
130
+ <span className="block px-2.5 py-1.5 text-xs text-fg-secondary" role="status">
131
+ {notice}
132
+ </span>
133
+ <MenuSeparator />
134
+ </>
154
135
  )}
155
- <Row
136
+ <MenuItem
156
137
  label="Off"
157
138
  hint="A single preview"
158
139
  selected={active === undefined}
159
140
  onSelect={() => choose(undefined)}
160
141
  />
161
142
  </div>
162
- </div>
143
+ </MenuPopup>
163
144
  )}
164
145
  </div>
165
146
  );