@superwall/studio 1.3.0 → 1.4.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/dist/assets/index-GB-RwJI6.js +11 -0
- package/dist/assets/index-Sz7S5UsH.css +1 -0
- package/dist/index.html +2 -2
- package/dist/lib/components/DownloadScreenshot.d.ts +6 -0
- package/dist/lib/components/PreviewOnDevice.d.ts +6 -0
- package/dist/lib/components/Tooltip.d.ts +5 -0
- package/dist/lib/index.d.ts +4 -0
- package/dist/lib/index.js +2168 -1153
- package/dist/lib/lib/actions.d.ts +1 -0
- package/dist/lib/lib/notify.d.ts +4 -0
- package/dist/lib/lib/project.d.ts +1 -0
- package/dist/lib/lib/scheme.d.ts +11 -0
- package/dist/lib/lib/surfaces.d.ts +3 -0
- package/dist/lib/studio.css +1 -1
- package/package.json +3 -2
- package/src/components/DownloadScreenshot.tsx +106 -0
- package/src/components/OpenInApp.tsx +5 -25
- package/src/components/PaywallToasts.tsx +1 -1
- package/src/components/PreviewOnDevice.tsx +133 -0
- package/src/components/SurfaceCard.tsx +1 -1
- package/src/components/Tooltip.tsx +27 -0
- package/src/components/menus/ActionMenu.tsx +8 -8
- package/src/components/menus/CompareMenu.tsx +1 -1
- package/src/components/panels/MissingProducts.tsx +1 -1
- package/src/index.ts +4 -0
- package/src/lib/actions.ts +7 -0
- package/src/lib/notify.tsx +31 -0
- package/src/lib/project.ts +2 -0
- package/src/lib/scheme.ts +31 -0
- package/src/lib/surfaces.ts +3 -0
- package/src/screens/SurfaceEditor.tsx +4 -0
- package/src/screens/SurfaceList.tsx +2 -2
- package/src/styles.css +43 -8
- package/dist/assets/index-CEz-HnIH.js +0 -11
- package/dist/assets/index-_HCp6gCi.css +0 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { toast } from "sonner";
|
|
3
|
+
import { AlertTriangleIcon, CheckCircleIcon, InfoCircleIcon } from "../components/icons";
|
|
4
|
+
|
|
5
|
+
type Tone = "info" | "success" | "warning";
|
|
6
|
+
|
|
7
|
+
const TINT: Record<Tone, string> = {
|
|
8
|
+
info: "text-cream/45",
|
|
9
|
+
success: "text-accent",
|
|
10
|
+
warning: "text-red",
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const ICON: Record<Tone, () => React.ReactElement> = {
|
|
14
|
+
info: InfoCircleIcon,
|
|
15
|
+
success: CheckCircleIcon,
|
|
16
|
+
warning: AlertTriangleIcon,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const notify = (message: React.ReactNode, tone: Tone = "info") => {
|
|
20
|
+
const Icon = ICON[tone];
|
|
21
|
+
toast.custom(() => (
|
|
22
|
+
<div className="bg-panel font-sans w-[344px] rounded border border-cream/15 p-3">
|
|
23
|
+
<div className="grid grid-cols-[14px_1fr] items-start gap-x-2.5">
|
|
24
|
+
<span className={`flex h-5 items-center justify-center ${TINT[tone]}`}>
|
|
25
|
+
<Icon />
|
|
26
|
+
</span>
|
|
27
|
+
<span className="text-[0.8125rem] leading-5 font-medium text-cream">{message}</span>
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
));
|
|
31
|
+
};
|
package/src/lib/project.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { SampleDefaults } from "./variables";
|
|
|
4
4
|
export type StudioProjectPayload = {
|
|
5
5
|
title: string;
|
|
6
6
|
scheme?: string;
|
|
7
|
+
networkOrigin?: string;
|
|
7
8
|
surfaces: StudioSurface[];
|
|
8
9
|
samples: SampleDefaults;
|
|
9
10
|
diagnostics: string[];
|
|
@@ -53,6 +54,7 @@ export const parseProjectPayload = (data: unknown): StudioProjectPayload => {
|
|
|
53
54
|
return {
|
|
54
55
|
title: typeof data.title === "string" ? data.title : "superwall",
|
|
55
56
|
scheme: typeof data.scheme === "string" ? data.scheme : undefined,
|
|
57
|
+
networkOrigin: typeof data.networkOrigin === "string" ? data.networkOrigin : undefined,
|
|
56
58
|
surfaces,
|
|
57
59
|
diagnostics: isStringArray(data.diagnostics) ? data.diagnostics : [],
|
|
58
60
|
samples: {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const STORAGE_KEY = "superwall-device-scheme";
|
|
2
|
+
|
|
3
|
+
export const readScheme = (): string | undefined => {
|
|
4
|
+
try {
|
|
5
|
+
return window.localStorage.getItem(STORAGE_KEY) ?? undefined;
|
|
6
|
+
} catch {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const storeScheme = (value: string) => {
|
|
12
|
+
try {
|
|
13
|
+
window.localStorage.setItem(STORAGE_KEY, value);
|
|
14
|
+
} catch {
|
|
15
|
+
/* private browsing */
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The link that points a device at this machine's `superwall dev` server.
|
|
21
|
+
*
|
|
22
|
+
* The SDK parses `superwall_dev` as the dev server base and the optional
|
|
23
|
+
* `superwall_dev_surface` as the surface to open with — see `DevServerPreview`
|
|
24
|
+
* in the iOS SDK, which refuses any base that is not loopback, `.local`, or a
|
|
25
|
+
* private-network address.
|
|
26
|
+
*/
|
|
27
|
+
export const devServerLink = (scheme: string, origin: string, surfaceId?: string): string => {
|
|
28
|
+
const surface =
|
|
29
|
+
surfaceId === undefined ? "" : `&superwall_dev_surface=${encodeURIComponent(surfaceId)}`;
|
|
30
|
+
return `${scheme}://?superwall_dev=${encodeURIComponent(origin)}${surface}`;
|
|
31
|
+
};
|
package/src/lib/surfaces.ts
CHANGED
|
@@ -30,6 +30,7 @@ export type CompareTarget = { type: "live" } | { type: "surface"; surface: Studi
|
|
|
30
30
|
|
|
31
31
|
export type StudioSource = {
|
|
32
32
|
scheme?: string;
|
|
33
|
+
networkOrigin?: string;
|
|
33
34
|
title: string;
|
|
34
35
|
surfaces: StudioSurface[];
|
|
35
36
|
diagnostics?: string[];
|
|
@@ -37,6 +38,8 @@ export type StudioSource = {
|
|
|
37
38
|
previewUrl: PreviewUrlBuilder;
|
|
38
39
|
standaloneUrl?: PreviewUrlBuilder;
|
|
39
40
|
capabilities?: { actions: boolean };
|
|
41
|
+
previewLink?: (surface: StudioSurface) => Promise<string>;
|
|
42
|
+
screenshotUrl?: (surface: StudioSurface) => Promise<string | undefined>;
|
|
40
43
|
compareHint?: string;
|
|
41
44
|
};
|
|
42
45
|
|
|
@@ -5,6 +5,8 @@ import { CompareMenu, type CompareOption } from "../components/menus/CompareMenu
|
|
|
5
5
|
import { DeviceFrame, DevicePlaceholder } from "../components/preview/DeviceFrame";
|
|
6
6
|
import { MissingProducts } from "../components/panels/MissingProducts";
|
|
7
7
|
import { PaywallToasts, useStudioDelegate } from "../components/PaywallToasts";
|
|
8
|
+
import { DownloadScreenshot } from "../components/DownloadScreenshot";
|
|
9
|
+
import { PreviewOnDevice } from "../components/PreviewOnDevice";
|
|
8
10
|
import { Segmented, Select, Switch } from "../components/controls";
|
|
9
11
|
import {
|
|
10
12
|
ExternalIcon,
|
|
@@ -375,6 +377,8 @@ export const SurfaceEditor = ({
|
|
|
375
377
|
<ExternalIcon />
|
|
376
378
|
</button>
|
|
377
379
|
)}
|
|
380
|
+
<DownloadScreenshot source={source} surface={surface} />
|
|
381
|
+
<PreviewOnDevice source={source} surface={surface} />
|
|
378
382
|
{actionsEnabled && (
|
|
379
383
|
<ActionMenu
|
|
380
384
|
progress={progress}
|
|
@@ -95,7 +95,7 @@ export const SurfaceList = ({
|
|
|
95
95
|
<div className="flex-1 overflow-y-auto px-3 pt-6 pb-16 sm:px-6 sm:pt-10" ref={scroller}>
|
|
96
96
|
<div className="mx-auto max-w-[1080px]">
|
|
97
97
|
{source.diagnostics && source.diagnostics.length > 0 && (
|
|
98
|
-
<div className="border-red bg-red/10 mb-6 border-l-2 px-4 py-3 text-[0.8125rem] whitespace-pre-wrap">
|
|
98
|
+
<div className="border-red bg-red/10 mb-6 rounded border-l-2 px-4 py-3 text-[0.8125rem] whitespace-pre-wrap">
|
|
99
99
|
{source.diagnostics.join("\n")}
|
|
100
100
|
</div>
|
|
101
101
|
)}
|
|
@@ -149,7 +149,7 @@ export const SurfaceList = ({
|
|
|
149
149
|
))}
|
|
150
150
|
|
|
151
151
|
{source.surfaces.length === 0 && (
|
|
152
|
-
<div className="border border-dashed border-cream/20 p-12 text-center text-cream/55">
|
|
152
|
+
<div className="rounded border border-dashed border-cream/20 p-12 text-center text-cream/55">
|
|
153
153
|
No paywalls yet — create{" "}
|
|
154
154
|
<code className="font-mono text-[0.8125rem] text-cream">
|
|
155
155
|
superwall/paywalls/<id>/app/page.tsx
|
package/src/styles.css
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
@import "tailwindcss";
|
|
2
2
|
|
|
3
3
|
@theme {
|
|
4
|
+
/* One restrained corner at every scale, so a control's size never changes
|
|
5
|
+
the visual language. Genuinely circular shapes stay 9999px. */
|
|
6
|
+
--radius: 3px;
|
|
7
|
+
--radius-xs: 3px;
|
|
8
|
+
--radius-sm: 3px;
|
|
9
|
+
--radius-md: 3px;
|
|
10
|
+
--radius-lg: 3px;
|
|
11
|
+
--radius-xl: 3px;
|
|
12
|
+
--radius-2xl: 3px;
|
|
13
|
+
--radius-3xl: 3px;
|
|
14
|
+
|
|
15
|
+
/* Structure is one hairline everywhere; controls carry a slightly stronger
|
|
16
|
+
edge because they hold a shape of their own. */
|
|
17
|
+
--hairline: color-mix(in srgb, var(--color-cream) 10%, transparent);
|
|
18
|
+
--edge: color-mix(in srgb, var(--color-cream) 18%, transparent);
|
|
19
|
+
|
|
4
20
|
--color-ink: #1a1918;
|
|
5
21
|
--color-bar: #211f1d;
|
|
6
22
|
--color-panel: #242220;
|
|
@@ -44,13 +60,14 @@
|
|
|
44
60
|
|
|
45
61
|
@layer components {
|
|
46
62
|
.sw-btn {
|
|
63
|
+
border-radius: var(--radius);
|
|
47
64
|
display: inline-flex;
|
|
48
65
|
align-items: center;
|
|
49
66
|
justify-content: center;
|
|
50
67
|
gap: 7px;
|
|
51
68
|
height: 30px;
|
|
52
69
|
padding: 0 12px;
|
|
53
|
-
border: 1px solid
|
|
70
|
+
border: 1px solid var(--edge);
|
|
54
71
|
background: transparent;
|
|
55
72
|
color: var(--color-cream);
|
|
56
73
|
font-size: 0.8125rem;
|
|
@@ -59,17 +76,23 @@
|
|
|
59
76
|
transition: background-color 150ms ease;
|
|
60
77
|
}
|
|
61
78
|
|
|
62
|
-
.sw-btn:hover {
|
|
79
|
+
.sw-btn:hover:not(:disabled):not(.sw-btn--blocked) {
|
|
63
80
|
background: color-mix(in srgb, var(--color-cream) 5%, transparent);
|
|
64
81
|
}
|
|
65
82
|
|
|
83
|
+
.sw-btn:disabled,
|
|
84
|
+
.sw-btn--blocked {
|
|
85
|
+
opacity: 0.4;
|
|
86
|
+
cursor: not-allowed;
|
|
87
|
+
}
|
|
88
|
+
|
|
66
89
|
.sw-btn--primary {
|
|
67
90
|
background: var(--color-cream);
|
|
68
91
|
border-color: var(--color-cream);
|
|
69
92
|
color: var(--color-ink);
|
|
70
93
|
}
|
|
71
94
|
|
|
72
|
-
.sw-btn--primary:hover {
|
|
95
|
+
.sw-btn--primary:hover:not(:disabled):not(.sw-btn--blocked) {
|
|
73
96
|
background: color-mix(in srgb, var(--color-cream) 85%, transparent);
|
|
74
97
|
}
|
|
75
98
|
|
|
@@ -91,11 +114,12 @@
|
|
|
91
114
|
}
|
|
92
115
|
|
|
93
116
|
.sw-chip {
|
|
117
|
+
border-radius: var(--radius);
|
|
94
118
|
display: inline-flex;
|
|
95
119
|
align-items: center;
|
|
96
120
|
height: 20px;
|
|
97
121
|
padding: 0 7px;
|
|
98
|
-
border: 1px solid
|
|
122
|
+
border: 1px solid var(--edge);
|
|
99
123
|
color: var(--color-cream);
|
|
100
124
|
white-space: nowrap;
|
|
101
125
|
}
|
|
@@ -114,11 +138,12 @@
|
|
|
114
138
|
}
|
|
115
139
|
|
|
116
140
|
.sw-select {
|
|
141
|
+
border-radius: var(--radius);
|
|
117
142
|
appearance: none;
|
|
118
143
|
cursor: pointer;
|
|
119
144
|
height: 30px;
|
|
120
145
|
padding: 0 24px 0 9px;
|
|
121
|
-
border: 1px solid
|
|
146
|
+
border: 1px solid var(--edge);
|
|
122
147
|
background:
|
|
123
148
|
linear-gradient(
|
|
124
149
|
45deg,
|
|
@@ -144,8 +169,9 @@
|
|
|
144
169
|
}
|
|
145
170
|
|
|
146
171
|
.sw-segmented {
|
|
172
|
+
border-radius: var(--radius);
|
|
147
173
|
display: inline-flex;
|
|
148
|
-
border: 1px solid
|
|
174
|
+
border: 1px solid var(--edge);
|
|
149
175
|
height: 30px;
|
|
150
176
|
}
|
|
151
177
|
|
|
@@ -163,7 +189,15 @@
|
|
|
163
189
|
}
|
|
164
190
|
|
|
165
191
|
.sw-segmented button + button {
|
|
166
|
-
border-left: 1px solid
|
|
192
|
+
border-left: 1px solid var(--edge);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.sw-segmented button:first-child {
|
|
196
|
+
border-radius: calc(var(--radius) - 1px) 0 0 calc(var(--radius) - 1px);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.sw-segmented button:last-child {
|
|
200
|
+
border-radius: 0 calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0;
|
|
167
201
|
}
|
|
168
202
|
|
|
169
203
|
.sw-segmented button[aria-pressed="true"] {
|
|
@@ -181,9 +215,10 @@
|
|
|
181
215
|
}
|
|
182
216
|
|
|
183
217
|
.sw-input {
|
|
218
|
+
border-radius: var(--radius);
|
|
184
219
|
height: 30px;
|
|
185
220
|
padding: 0 9px;
|
|
186
|
-
border: 1px solid
|
|
221
|
+
border: 1px solid var(--edge);
|
|
187
222
|
background: transparent;
|
|
188
223
|
color: var(--color-cream);
|
|
189
224
|
font: inherit;
|