@superwall/studio 1.6.0 → 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.
- package/README.md +27 -10
- package/dist/assets/index-BMe9fPdZ.css +1 -0
- package/dist/assets/index-Czsb6jZs.js +11 -0
- package/dist/index.html +3 -3
- package/dist/lib/components/Dialog.d.ts +7 -0
- package/dist/lib/components/EmptyState.d.ts +9 -0
- package/dist/lib/components/InlineCode.d.ts +2 -0
- package/dist/lib/components/PaywallToasts.d.ts +8 -0
- package/dist/lib/components/SuperwallLogo.d.ts +9 -0
- package/dist/lib/components/Tooltip.d.ts +3 -1
- package/dist/lib/components/chrome/TopBar.d.ts +2 -3
- package/dist/lib/components/controls.d.ts +10 -1
- package/dist/lib/components/icons.d.ts +30 -17
- package/dist/lib/components/menus/ActionMenu.d.ts +4 -1
- package/dist/lib/components/menus/Menu.d.ts +19 -0
- package/dist/lib/index.d.ts +3 -1
- package/dist/lib/index.js +2590 -2064
- package/dist/lib/lib/actions.d.ts +3 -2
- package/dist/lib/lib/contract.d.ts +4 -0
- package/dist/lib/lib/notify.d.ts +4 -1
- package/dist/lib/lib/promotion.d.ts +17 -0
- package/dist/lib/lib/steps.d.ts +2 -1
- package/dist/lib/lib/surfaces.d.ts +10 -4
- package/dist/lib/studio.css +1 -1
- package/package.json +2 -2
- package/src/StudioApp.tsx +3 -2
- package/src/components/Dialog.tsx +74 -0
- package/src/components/DownloadScreenshot.tsx +13 -20
- package/src/components/EmptyState.tsx +32 -0
- package/src/components/InlineCode.tsx +7 -0
- package/src/components/OpenInApp.tsx +15 -14
- package/src/components/PaywallToasts.tsx +44 -37
- package/src/components/PreviewOnDevice.tsx +61 -43
- package/src/components/SuperwallLogo.tsx +72 -0
- package/src/components/SurfaceCard.tsx +34 -18
- package/src/components/Tooltip.tsx +25 -2
- package/src/components/chrome/StudioShell.tsx +1 -1
- package/src/components/chrome/Toolbar.tsx +10 -8
- package/src/components/chrome/TopBar.tsx +21 -22
- package/src/components/controls.tsx +116 -31
- package/src/components/icons.tsx +140 -59
- package/src/components/menus/ActionMenu.tsx +221 -97
- package/src/components/menus/CompareMenu.tsx +48 -67
- package/src/components/menus/Menu.tsx +144 -0
- package/src/components/panels/MissingProducts.tsx +27 -34
- package/src/components/panels/SidePanel.tsx +9 -9
- package/src/components/panels/VariablesPanel.tsx +57 -49
- package/src/components/preview/Canvas.tsx +9 -13
- package/src/components/preview/DeviceFrame.tsx +4 -6
- package/src/index.ts +9 -0
- package/src/lib/actions.ts +13 -4
- package/src/lib/contract.ts +2 -0
- package/src/lib/notify.tsx +15 -18
- package/src/lib/project.ts +1 -0
- package/src/lib/promotion.ts +47 -0
- package/src/lib/steps.ts +9 -1
- package/src/lib/surfaces.ts +22 -2
- package/src/main.tsx +22 -10
- package/src/screens/SurfaceEditor.tsx +101 -63
- package/src/screens/SurfaceList.tsx +112 -69
- package/src/scroll-fade.css +425 -0
- package/src/styles.css +380 -182
- package/dist/assets/index-CljhSsYl.js +0 -11
- package/dist/assets/index-DrsTCwot.css +0 -1
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { createPortal } from "react-dom";
|
|
3
|
+
import { CheckIcon } from "../icons";
|
|
4
|
+
|
|
5
|
+
export type PopupAlign = "start" | "end";
|
|
6
|
+
|
|
7
|
+
export const useDismiss = (
|
|
8
|
+
refs: readonly React.RefObject<HTMLElement | null>[],
|
|
9
|
+
open: boolean,
|
|
10
|
+
onDismiss: () => void,
|
|
11
|
+
) => {
|
|
12
|
+
const dismiss = React.useRef(onDismiss);
|
|
13
|
+
dismiss.current = onDismiss;
|
|
14
|
+
|
|
15
|
+
React.useEffect(() => {
|
|
16
|
+
if (!open) return undefined;
|
|
17
|
+
const outside = (event: MouseEvent) => {
|
|
18
|
+
const path = event.composedPath();
|
|
19
|
+
if (!refs.some((ref) => ref.current && path.includes(ref.current))) dismiss.current();
|
|
20
|
+
};
|
|
21
|
+
const escape = (event: KeyboardEvent) => {
|
|
22
|
+
if (event.key === "Escape") dismiss.current();
|
|
23
|
+
};
|
|
24
|
+
window.addEventListener("mousedown", outside);
|
|
25
|
+
window.addEventListener("keydown", escape);
|
|
26
|
+
return () => {
|
|
27
|
+
window.removeEventListener("mousedown", outside);
|
|
28
|
+
window.removeEventListener("keydown", escape);
|
|
29
|
+
};
|
|
30
|
+
}, [refs, open]);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const usePopupAlign = (
|
|
34
|
+
ref: React.RefObject<HTMLElement | null>,
|
|
35
|
+
open: boolean,
|
|
36
|
+
): PopupAlign => {
|
|
37
|
+
const [align, setAlign] = React.useState<PopupAlign>("start");
|
|
38
|
+
|
|
39
|
+
React.useLayoutEffect(() => {
|
|
40
|
+
const anchor = ref.current;
|
|
41
|
+
if (!open || !anchor) return;
|
|
42
|
+
const box = anchor.getBoundingClientRect();
|
|
43
|
+
setAlign(box.left + box.width / 2 > window.innerWidth / 2 ? "end" : "start");
|
|
44
|
+
}, [ref, open]);
|
|
45
|
+
|
|
46
|
+
return align;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
type Placement = Pick<React.CSSProperties, "top" | "bottom" | "left">;
|
|
50
|
+
|
|
51
|
+
const GUTTER = 12;
|
|
52
|
+
|
|
53
|
+
const portalRoot = (anchor: HTMLElement | null): Element | ShadowRoot => {
|
|
54
|
+
const studio = anchor?.closest(".sw-studio");
|
|
55
|
+
if (studio) return studio;
|
|
56
|
+
const root = anchor?.getRootNode();
|
|
57
|
+
return root instanceof ShadowRoot ? root : document.body;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const MenuPopup = ({
|
|
61
|
+
popupRef,
|
|
62
|
+
anchor,
|
|
63
|
+
side,
|
|
64
|
+
align,
|
|
65
|
+
className = "",
|
|
66
|
+
children,
|
|
67
|
+
}: React.PropsWithChildren<{
|
|
68
|
+
popupRef: React.RefObject<HTMLDivElement | null>;
|
|
69
|
+
anchor: React.RefObject<HTMLElement | null>;
|
|
70
|
+
side: "top" | "bottom";
|
|
71
|
+
align: PopupAlign;
|
|
72
|
+
className?: string;
|
|
73
|
+
}>) => {
|
|
74
|
+
const [placement, setPlacement] = React.useState<Placement | undefined>(undefined);
|
|
75
|
+
|
|
76
|
+
React.useLayoutEffect(() => {
|
|
77
|
+
const place = () => {
|
|
78
|
+
const box = anchor.current?.getBoundingClientRect();
|
|
79
|
+
if (!box) return;
|
|
80
|
+
const width = popupRef.current?.offsetWidth ?? 0;
|
|
81
|
+
const desired = align === "end" ? box.right - width : box.left;
|
|
82
|
+
setPlacement({
|
|
83
|
+
...(side === "top"
|
|
84
|
+
? { bottom: window.innerHeight - box.top + 4 }
|
|
85
|
+
: { top: box.bottom + 4 }),
|
|
86
|
+
left: Math.max(GUTTER, Math.min(desired, window.innerWidth - GUTTER - width)),
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
place();
|
|
90
|
+
window.addEventListener("resize", place);
|
|
91
|
+
window.addEventListener("scroll", place, true);
|
|
92
|
+
return () => {
|
|
93
|
+
window.removeEventListener("resize", place);
|
|
94
|
+
window.removeEventListener("scroll", place, true);
|
|
95
|
+
};
|
|
96
|
+
}, [anchor, popupRef, side, align]);
|
|
97
|
+
|
|
98
|
+
return createPortal(
|
|
99
|
+
<div
|
|
100
|
+
ref={popupRef}
|
|
101
|
+
className={`fixed z-30 flex max-w-[calc(100vw-1.5rem)] flex-col overflow-hidden rounded-sm border border-border bg-popover text-foreground ${
|
|
102
|
+
placement ? "" : "invisible"
|
|
103
|
+
} ${className}`}
|
|
104
|
+
style={placement}
|
|
105
|
+
data-menu-popup=""
|
|
106
|
+
>
|
|
107
|
+
{children}
|
|
108
|
+
</div>,
|
|
109
|
+
portalRoot(anchor.current),
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export const MenuItem = ({
|
|
114
|
+
label,
|
|
115
|
+
hint,
|
|
116
|
+
selected,
|
|
117
|
+
onSelect,
|
|
118
|
+
}: {
|
|
119
|
+
label: string;
|
|
120
|
+
hint?: string;
|
|
121
|
+
selected?: boolean;
|
|
122
|
+
onSelect: () => void;
|
|
123
|
+
}) => (
|
|
124
|
+
<button
|
|
125
|
+
type="button"
|
|
126
|
+
className={`grid w-full min-w-0 grid-cols-[1fr_0.875rem] items-center gap-2 rounded-sm border border-transparent ps-[calc(--spacing(2.5)-1px)] pe-2 text-left text-sm text-foreground outline-none hover:bg-accent focus-visible:bg-accent ${
|
|
127
|
+
hint ? "py-[calc(--spacing(1.5)-1px)]" : "py-[calc(--spacing(1)-1px)]"
|
|
128
|
+
}`}
|
|
129
|
+
aria-current={selected || undefined}
|
|
130
|
+
onClick={onSelect}
|
|
131
|
+
>
|
|
132
|
+
<span className="flex min-w-0 flex-col">
|
|
133
|
+
<span className="truncate">{label}</span>
|
|
134
|
+
{hint && <span className="truncate text-xs/4 text-fg-tertiary">{hint}</span>}
|
|
135
|
+
</span>
|
|
136
|
+
{selected ? <CheckIcon className="text-primary" /> : <span />}
|
|
137
|
+
</button>
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
export const MenuGroupLabel = ({ children }: React.PropsWithChildren) => (
|
|
141
|
+
<span className="block px-2.5 py-1.5 text-xs font-medium text-fg-tertiary">{children}</span>
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
export const MenuSeparator = () => <span className="mx-2.5 my-1 block h-px bg-border" />;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Dialog } from "../Dialog";
|
|
2
|
+
|
|
1
3
|
export const MissingProducts = ({
|
|
2
4
|
paywall,
|
|
3
5
|
missing,
|
|
@@ -7,40 +9,31 @@ export const MissingProducts = ({
|
|
|
7
9
|
missing: { reference: string; identifier: string }[];
|
|
8
10
|
onDismiss: () => void;
|
|
9
11
|
}) => (
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
<div className="bg-panel flex w-full max-w-md flex-col gap-4 rounded border border-cream/20 p-5">
|
|
17
|
-
<div className="flex flex-col gap-1.5">
|
|
18
|
-
<span id="sw-missing-products" className="text-[0.9375rem] font-medium text-cream">
|
|
19
|
-
{missing.length === 1 ? "A product is missing" : `${missing.length} products are missing`}
|
|
20
|
-
</span>
|
|
21
|
-
<span className="text-[0.8125rem] leading-relaxed text-cream/60">
|
|
22
|
-
{`${paywall} declares ${missing.length === 1 ? "a product" : "products"} Superwall has no record of. Every variable on ${missing.length === 1 ? "it" : "them"} will be undefined here and on device.`}
|
|
23
|
-
</span>
|
|
24
|
-
</div>
|
|
25
|
-
|
|
26
|
-
<ul className="flex flex-col gap-1.5 border-y border-cream/10 py-3">
|
|
27
|
-
{missing.map((entry) => (
|
|
28
|
-
<li key={entry.reference} className="flex items-baseline justify-between gap-3">
|
|
29
|
-
<span className="font-mono text-[11px] text-cream/70">{entry.reference}</span>
|
|
30
|
-
<span className="truncate font-mono text-[11px] text-cream/40">{entry.identifier}</span>
|
|
31
|
-
</li>
|
|
32
|
-
))}
|
|
33
|
-
</ul>
|
|
34
|
-
|
|
35
|
-
<span className="text-xs text-cream/45">
|
|
36
|
-
Add {missing.length === 1 ? "it" : "them"} in the Superwall dashboard, or point the config
|
|
37
|
-
at{missing.length === 1 ? " a product" : " products"} that exists. Pushing is refused until
|
|
38
|
-
then.
|
|
39
|
-
</span>
|
|
40
|
-
|
|
41
|
-
<button type="button" className="sw-btn sw-btn--primary self-end" onClick={onDismiss}>
|
|
12
|
+
<Dialog
|
|
13
|
+
title={missing.length === 1 ? "A product is missing" : `${missing.length} products are missing`}
|
|
14
|
+
description={`${paywall} declares ${missing.length === 1 ? "a product" : "products"} Superwall has no record of. Every variable on ${missing.length === 1 ? "it" : "them"} will be undefined here and on device.`}
|
|
15
|
+
onClose={onDismiss}
|
|
16
|
+
footer={
|
|
17
|
+
<button type="button" className="sw-btn sw-btn--primary" onClick={onDismiss}>
|
|
42
18
|
View anyway
|
|
43
19
|
</button>
|
|
44
|
-
|
|
45
|
-
|
|
20
|
+
}
|
|
21
|
+
>
|
|
22
|
+
<ul className="m-0 flex list-none flex-col divide-y divide-border overflow-hidden rounded-sm border border-border p-0">
|
|
23
|
+
{missing.map((entry) => (
|
|
24
|
+
<li
|
|
25
|
+
key={entry.reference}
|
|
26
|
+
className="flex items-center justify-between gap-4 px-3 py-2.5 text-sm"
|
|
27
|
+
>
|
|
28
|
+
<span className="truncate">{entry.reference}</span>
|
|
29
|
+
<span className="truncate text-fg-tertiary tabular-nums">{entry.identifier}</span>
|
|
30
|
+
</li>
|
|
31
|
+
))}
|
|
32
|
+
</ul>
|
|
33
|
+
<p className="m-0 text-sm text-fg-secondary">
|
|
34
|
+
Add {missing.length === 1 ? "it" : "them"} in the Superwall dashboard, or point the config at
|
|
35
|
+
{missing.length === 1 ? " a product" : " products"} that exists. Pushing is refused until
|
|
36
|
+
then.
|
|
37
|
+
</p>
|
|
38
|
+
</Dialog>
|
|
46
39
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { XIcon } from "../icons";
|
|
3
3
|
|
|
4
4
|
export const SidePanel = ({
|
|
5
5
|
open,
|
|
@@ -12,25 +12,25 @@ export const SidePanel = ({
|
|
|
12
12
|
onClose: () => void;
|
|
13
13
|
}>) => (
|
|
14
14
|
<aside
|
|
15
|
-
className={`flex-none overflow-hidden transition-[width] duration-
|
|
16
|
-
open ? "w-
|
|
15
|
+
className={`flex-none overflow-hidden transition-[width] duration-move ease-out motion-reduce:transition-none ${
|
|
16
|
+
open ? "w-80" : "w-0"
|
|
17
17
|
}`}
|
|
18
18
|
aria-hidden={!open}
|
|
19
19
|
inert={!open}
|
|
20
20
|
>
|
|
21
|
-
<div className="
|
|
22
|
-
<div className="flex h-
|
|
23
|
-
<span className="text-
|
|
21
|
+
<div className="flex h-full w-80 flex-col border-l border-border bg-background">
|
|
22
|
+
<div className="flex h-12 flex-none items-center justify-between border-b border-border ps-4 pe-2.5">
|
|
23
|
+
<span className="text-sm font-medium">{title}</span>
|
|
24
24
|
<button
|
|
25
25
|
type="button"
|
|
26
|
-
className="sw-btn sw-btn--icon
|
|
26
|
+
className="sw-btn sw-btn--sm sw-btn--icon sw-btn--ghost"
|
|
27
27
|
aria-label={`Close ${title.toLowerCase()}`}
|
|
28
28
|
onClick={onClose}
|
|
29
29
|
>
|
|
30
|
-
<
|
|
30
|
+
<XIcon />
|
|
31
31
|
</button>
|
|
32
32
|
</div>
|
|
33
|
-
<div className="flex-1 overflow-y-auto
|
|
33
|
+
<div className="min-h-0 flex-1 scroll-fade overflow-y-auto">{children}</div>
|
|
34
34
|
</div>
|
|
35
35
|
</aside>
|
|
36
36
|
);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import { Switch } from "../controls";
|
|
2
3
|
import { ChevronDownIcon } from "../icons";
|
|
3
4
|
import type { VariableOverrides } from "../../lib/variables";
|
|
4
5
|
|
|
@@ -15,7 +16,7 @@ const GROUPS: { key: VariableGroup; label: string; blurb: string }[] = [
|
|
|
15
16
|
{ key: "user", label: "User", blurb: "Attributes your app sets" },
|
|
16
17
|
{ key: "device", label: "Device", blurb: "Platform, locale, OS — the SDK fills these in" },
|
|
17
18
|
{ key: "params", label: "Params", blurb: "Passed in at the placement" },
|
|
18
|
-
{ key: "products", label: "Products", blurb: "Store data for this paywall
|
|
19
|
+
{ key: "products", label: "Products", blurb: "Store data for this paywall’s products" },
|
|
19
20
|
];
|
|
20
21
|
|
|
21
22
|
const display = (value: unknown): string =>
|
|
@@ -47,13 +48,13 @@ const Row = ({
|
|
|
47
48
|
const current = overridden ? override : row.value;
|
|
48
49
|
|
|
49
50
|
return (
|
|
50
|
-
<div className="flex flex-col gap-
|
|
51
|
-
<div className="flex items-
|
|
52
|
-
<span className="truncate
|
|
51
|
+
<div className="flex flex-col gap-2">
|
|
52
|
+
<div className="flex min-h-5 items-center justify-between gap-2">
|
|
53
|
+
<span className="truncate text-xs font-medium text-fg-tertiary">{row.path}</span>
|
|
53
54
|
{overridden && (
|
|
54
55
|
<button
|
|
55
56
|
type="button"
|
|
56
|
-
className="
|
|
57
|
+
className="sw-btn sw-btn--plain shrink-0 text-xs"
|
|
57
58
|
aria-label={`Reset ${row.path}`}
|
|
58
59
|
onClick={() => onChange(undefined)}
|
|
59
60
|
>
|
|
@@ -63,18 +64,11 @@ const Row = ({
|
|
|
63
64
|
</div>
|
|
64
65
|
{typeof current === "boolean" ? (
|
|
65
66
|
<span className="flex h-7 items-center">
|
|
66
|
-
<
|
|
67
|
-
type="button"
|
|
68
|
-
className="sw-switch"
|
|
69
|
-
role="switch"
|
|
70
|
-
aria-checked={current}
|
|
71
|
-
aria-label={row.path}
|
|
72
|
-
onClick={() => onChange(!current)}
|
|
73
|
-
/>
|
|
67
|
+
<Switch label={row.path} checked={current} onChange={(checked) => onChange(checked)} />
|
|
74
68
|
</span>
|
|
75
69
|
) : (
|
|
76
70
|
<input
|
|
77
|
-
className="sw-input
|
|
71
|
+
className="sw-input sw-input--sm"
|
|
78
72
|
aria-label={row.path}
|
|
79
73
|
value={display(current)}
|
|
80
74
|
placeholder={display(row.value)}
|
|
@@ -101,53 +95,67 @@ const Group = ({
|
|
|
101
95
|
overrideOf: (path: string) => unknown;
|
|
102
96
|
onChange: (path: string, value: unknown) => void;
|
|
103
97
|
}) => {
|
|
104
|
-
const [
|
|
98
|
+
const [state, setState] = React.useState<"closed" | "open" | "closing">("closed");
|
|
99
|
+
const open = state === "open";
|
|
105
100
|
const overridden = rows.filter((row) => overrideOf(row.path) !== undefined).length;
|
|
106
101
|
|
|
107
102
|
return (
|
|
108
|
-
<section className="border-b border-
|
|
103
|
+
<section className="border-b border-border">
|
|
109
104
|
<button
|
|
110
105
|
type="button"
|
|
111
|
-
className="flex w-full items-center gap-
|
|
106
|
+
className="group relative flex w-full items-center gap-4 px-4 py-2.5 text-left transition-colors duration-hover before:pointer-events-none before:absolute before:inset-0 before:border before:border-transparent before:transition-colors before:duration-hover hover:bg-foreground/3 focus-visible:before:border-primary"
|
|
112
107
|
aria-expanded={open}
|
|
113
|
-
onClick={() =>
|
|
108
|
+
onClick={() => setState((current) => (current === "open" ? "closing" : "open"))}
|
|
114
109
|
>
|
|
115
|
-
<span className="flex min-w-0 flex-
|
|
116
|
-
<span className="flex items-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
{overridden >
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
rows.length
|
|
123
|
-
)
|
|
124
|
-
|
|
110
|
+
<span className="flex min-w-0 flex-1 flex-col">
|
|
111
|
+
<span className="flex items-center gap-1.5 text-sm font-medium">
|
|
112
|
+
{label}
|
|
113
|
+
{overridden > 0 ? (
|
|
114
|
+
<span className="font-normal text-primary tabular-nums">{`${overridden} set`}</span>
|
|
115
|
+
) : (
|
|
116
|
+
rows.length > 0 && (
|
|
117
|
+
<span className="font-normal text-fg-tertiary tabular-nums">{rows.length}</span>
|
|
118
|
+
)
|
|
119
|
+
)}
|
|
125
120
|
</span>
|
|
126
|
-
<span className="truncate text-xs text-
|
|
127
|
-
</span>
|
|
128
|
-
<span
|
|
129
|
-
className={`ml-auto shrink-0 text-cream/40 transition-transform ${open ? "" : "-rotate-90"}`}
|
|
130
|
-
aria-hidden="true"
|
|
131
|
-
>
|
|
132
|
-
<ChevronDownIcon />
|
|
121
|
+
<span className="truncate text-xs/4 text-fg-tertiary">{blurb}</span>
|
|
133
122
|
</span>
|
|
123
|
+
<ChevronDownIcon
|
|
124
|
+
className={`icon-tertiary transition-disclosure group-hover:filter-none ${open ? "rotate-180" : ""}`}
|
|
125
|
+
/>
|
|
134
126
|
</button>
|
|
135
127
|
|
|
136
|
-
{
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
128
|
+
{state !== "closed" && (
|
|
129
|
+
<div
|
|
130
|
+
className={`grid transition-[grid-template-rows,opacity] duration-move ease-out starting:grid-rows-[0fr] starting:opacity-0 ${
|
|
131
|
+
open ? "grid-rows-[1fr] opacity-100" : "grid-rows-[0fr] opacity-0"
|
|
132
|
+
}`}
|
|
133
|
+
aria-hidden={open ? undefined : true}
|
|
134
|
+
inert={!open}
|
|
135
|
+
onTransitionEnd={(event) => {
|
|
136
|
+
if (event.target === event.currentTarget && state === "closing") setState("closed");
|
|
137
|
+
}}
|
|
138
|
+
>
|
|
139
|
+
<div className="min-h-0 overflow-hidden">
|
|
140
|
+
{rows.length === 0 ? (
|
|
141
|
+
<span className="block px-4 pb-4 text-xs text-fg-tertiary">
|
|
142
|
+
Nothing here for this paywall.
|
|
143
|
+
</span>
|
|
144
|
+
) : (
|
|
145
|
+
<div className="flex flex-col gap-3 px-4 pt-1 pb-4">
|
|
146
|
+
{rows.map((row) => (
|
|
147
|
+
<Row
|
|
148
|
+
key={row.path}
|
|
149
|
+
row={row}
|
|
150
|
+
override={overrideOf(row.path)}
|
|
151
|
+
onChange={(value) => onChange(row.path, value)}
|
|
152
|
+
/>
|
|
153
|
+
))}
|
|
154
|
+
</div>
|
|
155
|
+
)}
|
|
149
156
|
</div>
|
|
150
|
-
|
|
157
|
+
</div>
|
|
158
|
+
)}
|
|
151
159
|
</section>
|
|
152
160
|
);
|
|
153
161
|
};
|
|
@@ -250,6 +250,8 @@ export const Canvas = ({
|
|
|
250
250
|
attached.delete(frame);
|
|
251
251
|
const target = sameOriginWindow(frame);
|
|
252
252
|
if (!target) return;
|
|
253
|
+
const controller = new AbortController();
|
|
254
|
+
const { signal } = controller;
|
|
253
255
|
const onWheel = (event: WheelEvent) => {
|
|
254
256
|
if (isZoomGesture(event)) {
|
|
255
257
|
const rect = frame.getBoundingClientRect();
|
|
@@ -299,22 +301,16 @@ export const Canvas = ({
|
|
|
299
301
|
if (press?.panning) {
|
|
300
302
|
setDragging(false);
|
|
301
303
|
grab(false);
|
|
302
|
-
target.addEventListener("click", swallow, { capture: true, once: true });
|
|
304
|
+
target.addEventListener("click", swallow, { capture: true, once: true, signal });
|
|
303
305
|
}
|
|
304
306
|
press = null;
|
|
305
307
|
};
|
|
306
|
-
target.addEventListener("wheel", onWheel, { passive: false });
|
|
307
|
-
target.addEventListener("pointerdown", onPointerDown);
|
|
308
|
-
target.addEventListener("pointermove", onPointerMove);
|
|
309
|
-
target.addEventListener("pointerup", onPointerUp);
|
|
310
|
-
target.addEventListener("pointercancel", onPointerUp);
|
|
311
|
-
attached.set(frame, () =>
|
|
312
|
-
target.removeEventListener("wheel", onWheel);
|
|
313
|
-
target.removeEventListener("pointerdown", onPointerDown);
|
|
314
|
-
target.removeEventListener("pointermove", onPointerMove);
|
|
315
|
-
target.removeEventListener("pointerup", onPointerUp);
|
|
316
|
-
target.removeEventListener("pointercancel", onPointerUp);
|
|
317
|
-
});
|
|
308
|
+
target.addEventListener("wheel", onWheel, { passive: false, signal });
|
|
309
|
+
target.addEventListener("pointerdown", onPointerDown, { signal });
|
|
310
|
+
target.addEventListener("pointermove", onPointerMove, { signal });
|
|
311
|
+
target.addEventListener("pointerup", onPointerUp, { signal });
|
|
312
|
+
target.addEventListener("pointercancel", onPointerUp, { signal });
|
|
313
|
+
attached.set(frame, () => controller.abort());
|
|
318
314
|
};
|
|
319
315
|
const onLoad = (event: Event) => {
|
|
320
316
|
if (event.target instanceof HTMLIFrameElement) attach(event.target);
|
|
@@ -16,7 +16,7 @@ export const DevicePlaceholder = ({
|
|
|
16
16
|
height: number;
|
|
17
17
|
}>) => (
|
|
18
18
|
<div
|
|
19
|
-
className="flex flex-none items-center justify-center overflow-hidden
|
|
19
|
+
className="flex flex-none items-center justify-center overflow-hidden rounded-sm bg-background p-6 text-center text-sm text-fg-secondary outline outline-foreground/20"
|
|
20
20
|
data-testid="device-placeholder"
|
|
21
21
|
style={{ width, height }}
|
|
22
22
|
>
|
|
@@ -95,11 +95,9 @@ export const DeviceFrame = ({
|
|
|
95
95
|
|
|
96
96
|
return (
|
|
97
97
|
<div
|
|
98
|
-
className=
|
|
99
|
-
chrome ? "shadow-[0_0_0_1px] shadow-cream/25" : "border border-cream/20"
|
|
100
|
-
}`}
|
|
98
|
+
className="relative flex-none overflow-hidden bg-background outline outline-foreground/20"
|
|
101
99
|
data-testid="device-frame"
|
|
102
|
-
style={{ width, height, borderRadius: chrome?.radius ??
|
|
100
|
+
style={{ width, height, borderRadius: chrome?.radius ?? 3 }}
|
|
103
101
|
>
|
|
104
102
|
{sheet && (
|
|
105
103
|
<div
|
|
@@ -142,7 +140,7 @@ export const DeviceFrame = ({
|
|
|
142
140
|
key={frame.generation}
|
|
143
141
|
hostState={hostState}
|
|
144
142
|
delegate={delegate}
|
|
145
|
-
className={`absolute inset-0 border-0 bg-white transition-opacity duration-
|
|
143
|
+
className={`absolute inset-0 border-0 bg-white transition-opacity duration-hover ${
|
|
146
144
|
frame === visible ? "opacity-100" : "opacity-0"
|
|
147
145
|
}`}
|
|
148
146
|
title={title}
|
package/src/index.ts
CHANGED
|
@@ -17,6 +17,13 @@ export { DEFAULT_DEVICE_ID, deviceById, STUDIO_DEVICES } from "./lib/devices";
|
|
|
17
17
|
export type { StudioDevice } from "./lib/devices";
|
|
18
18
|
export { hostStateFor, studioDefaults } from "./lib/host";
|
|
19
19
|
export { hasActions } from "./lib/surfaces";
|
|
20
|
+
export { devServerActions } from "./lib/actions";
|
|
21
|
+
export {
|
|
22
|
+
latestVersion,
|
|
23
|
+
liveVersion,
|
|
24
|
+
promotionDirection,
|
|
25
|
+
type PromotionDirection,
|
|
26
|
+
} from "./lib/promotion";
|
|
20
27
|
export { devServerLink } from "./lib/scheme";
|
|
21
28
|
export {
|
|
22
29
|
StudioHostProvider,
|
|
@@ -43,7 +50,9 @@ export type {
|
|
|
43
50
|
Samples,
|
|
44
51
|
StudioActionName,
|
|
45
52
|
StudioActionProgress,
|
|
53
|
+
StudioActionRequest,
|
|
46
54
|
StudioActionResult,
|
|
55
|
+
StudioActions,
|
|
47
56
|
StudioPresentation,
|
|
48
57
|
StudioSource,
|
|
49
58
|
StudioStatus,
|
package/src/lib/actions.ts
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
import { surfacePath } from "./preview";
|
|
2
2
|
import type {
|
|
3
3
|
Samples,
|
|
4
|
-
|
|
4
|
+
StudioActionProgress,
|
|
5
|
+
StudioActionRequest,
|
|
5
6
|
StudioActionResult,
|
|
7
|
+
StudioActions,
|
|
6
8
|
StudioStatus,
|
|
7
9
|
StudioSurface,
|
|
8
10
|
} from "./surfaces";
|
|
9
11
|
|
|
10
12
|
export const runAction = async (
|
|
11
13
|
surface: StudioSurface,
|
|
12
|
-
|
|
13
|
-
onStep?:
|
|
14
|
+
request: StudioActionRequest,
|
|
15
|
+
onStep?: StudioActionProgress,
|
|
14
16
|
): Promise<StudioActionResult> => {
|
|
15
17
|
try {
|
|
16
18
|
const response = await fetch("/__studio/action", {
|
|
17
19
|
method: "POST",
|
|
18
20
|
headers: { "Content-Type": "application/json" },
|
|
19
21
|
body: JSON.stringify({
|
|
20
|
-
action,
|
|
22
|
+
action: request.action,
|
|
23
|
+
version: request.version,
|
|
21
24
|
kind: surface.kind,
|
|
22
25
|
id: surface.id,
|
|
23
26
|
project: surface.project,
|
|
@@ -68,6 +71,12 @@ export const fetchStatus = async (surface: StudioSurface): Promise<StudioStatus>
|
|
|
68
71
|
}
|
|
69
72
|
};
|
|
70
73
|
|
|
74
|
+
export const devServerActions: StudioActions = {
|
|
75
|
+
offered: ["push", "promote", "publish"],
|
|
76
|
+
run: runAction,
|
|
77
|
+
status: fetchStatus,
|
|
78
|
+
};
|
|
79
|
+
|
|
71
80
|
export const fetchScreenshot = async (surface: StudioSurface): Promise<string | undefined> => {
|
|
72
81
|
const response = await fetch(`/__studio/screenshot${surfacePath(surface)}`);
|
|
73
82
|
const value = (await response.json()) as { url?: string; unreachable?: string };
|
package/src/lib/contract.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export type StudioActionName = "push" | "promote" | "publish";
|
|
2
2
|
|
|
3
|
+
export type StudioActionRequest = { action: StudioActionName; version?: number };
|
|
4
|
+
|
|
3
5
|
export type StudioActionResult =
|
|
4
6
|
| { ok: true; version: number; live: boolean }
|
|
5
7
|
| { ok: false; error: string };
|
package/src/lib/notify.tsx
CHANGED
|
@@ -1,31 +1,28 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { toast } from "sonner";
|
|
3
|
-
import {
|
|
3
|
+
import { ToastCard } from "../components/PaywallToasts";
|
|
4
|
+
import {
|
|
5
|
+
AlertTriangleIcon,
|
|
6
|
+
CheckCircleIcon,
|
|
7
|
+
InfoCircleIcon,
|
|
8
|
+
type IconComponent,
|
|
9
|
+
} from "../components/icons";
|
|
4
10
|
|
|
5
11
|
type Tone = "info" | "success" | "warning";
|
|
6
12
|
|
|
7
|
-
const
|
|
8
|
-
info: "text-cream/45",
|
|
9
|
-
success: "text-accent",
|
|
10
|
-
warning: "text-red",
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const ICON: Record<Tone, () => React.ReactElement> = {
|
|
13
|
+
const ICON: Record<Tone, IconComponent> = {
|
|
14
14
|
info: InfoCircleIcon,
|
|
15
15
|
success: CheckCircleIcon,
|
|
16
16
|
warning: AlertTriangleIcon,
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
export const notify = (
|
|
20
|
-
|
|
19
|
+
export const notify = (
|
|
20
|
+
title: React.ReactNode,
|
|
21
|
+
{ tone = "info", description }: { tone?: Tone; description?: React.ReactNode } = {},
|
|
22
|
+
) => {
|
|
21
23
|
toast.custom(() => (
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
<Icon />
|
|
26
|
-
</span>
|
|
27
|
-
<span className="text-[0.8125rem] leading-5 font-medium text-cream">{message}</span>
|
|
28
|
-
</div>
|
|
29
|
-
</div>
|
|
24
|
+
<ToastCard icon={ICON[tone]} tone={tone} description={description}>
|
|
25
|
+
{title}
|
|
26
|
+
</ToastCard>
|
|
30
27
|
));
|
|
31
28
|
};
|
package/src/lib/project.ts
CHANGED
|
@@ -42,6 +42,7 @@ const parseSurface = (value: unknown): StudioSurface | undefined => {
|
|
|
42
42
|
kind,
|
|
43
43
|
id: value.id,
|
|
44
44
|
...(typeof value.project === "string" ? { project: value.project } : {}),
|
|
45
|
+
...(typeof value.label === "string" && value.label !== "" ? { label: value.label } : {}),
|
|
45
46
|
routes: isStringArray(value.routes) ? value.routes : [],
|
|
46
47
|
products: isStringRecord(value.products) ? value.products : {},
|
|
47
48
|
locales: isStringArray(value.locales) ? value.locales : [],
|