create-eventus-app 0.1.5 → 0.2.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/package.json
CHANGED
package/template/src/App.tsx
CHANGED
|
@@ -3,6 +3,8 @@ import {
|
|
|
3
3
|
EventusContextProvider,
|
|
4
4
|
useEventusContext,
|
|
5
5
|
} from "@eventusgo/sdk/react";
|
|
6
|
+
import { eventus } from "@eventusgo/sdk";
|
|
7
|
+
import { useEffect, useState } from "react";
|
|
6
8
|
|
|
7
9
|
import logoDark from "./assets/logo_black_transparent.png";
|
|
8
10
|
import logoLight from "./assets/logo_white_transparent.png";
|
|
@@ -17,6 +19,8 @@ export default function App() {
|
|
|
17
19
|
|
|
18
20
|
function WelcomeScreen() {
|
|
19
21
|
const { context, runtimeSource } = useEventusContext();
|
|
22
|
+
const [launchCount, setLaunchCount] = useState<number | null>(null);
|
|
23
|
+
const [copyLabel, setCopyLabel] = useState("Copy App ID");
|
|
20
24
|
const userName =
|
|
21
25
|
context.user?.name ??
|
|
22
26
|
context.user?.displayName ??
|
|
@@ -26,6 +30,39 @@ function WelcomeScreen() {
|
|
|
26
30
|
const runtimeLabel =
|
|
27
31
|
runtimeSource === "native" ? "Connected to Eventus X" : "Mock preview";
|
|
28
32
|
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
let cancelled = false;
|
|
35
|
+
|
|
36
|
+
void (async () => {
|
|
37
|
+
if (!manifest.permissions?.includes("storage.local")) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
const nextLaunchCount =
|
|
43
|
+
((await eventus.actions.storage.get<number>("launchCount")) ?? 0) + 1;
|
|
44
|
+
await eventus.actions.storage.set("launchCount", nextLaunchCount);
|
|
45
|
+
|
|
46
|
+
if (!cancelled) {
|
|
47
|
+
setLaunchCount(nextLaunchCount);
|
|
48
|
+
}
|
|
49
|
+
} catch {
|
|
50
|
+
if (!cancelled) {
|
|
51
|
+
setLaunchCount(null);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
})();
|
|
55
|
+
|
|
56
|
+
return () => {
|
|
57
|
+
cancelled = true;
|
|
58
|
+
};
|
|
59
|
+
}, []);
|
|
60
|
+
|
|
61
|
+
async function handleCopyAppId(): Promise<void> {
|
|
62
|
+
await eventus.actions.copyText({ text: manifest.appId });
|
|
63
|
+
setCopyLabel("Copied");
|
|
64
|
+
}
|
|
65
|
+
|
|
29
66
|
return (
|
|
30
67
|
<main className="welcome-shell">
|
|
31
68
|
<section className={`welcome-card theme-${context.theme}`}>
|
|
@@ -59,6 +96,16 @@ function WelcomeScreen() {
|
|
|
59
96
|
<span>App ID</span>
|
|
60
97
|
<strong>{manifest.appId}</strong>
|
|
61
98
|
</div>
|
|
99
|
+
<div className="welcome-chip">
|
|
100
|
+
<span>Launch Count</span>
|
|
101
|
+
<strong>{launchCount ?? "Syncing"}</strong>
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
|
|
105
|
+
<div className="welcome-actions">
|
|
106
|
+
<button className="welcome-action" onClick={() => void handleCopyAppId()}>
|
|
107
|
+
{copyLabel}
|
|
108
|
+
</button>
|
|
62
109
|
</div>
|
|
63
110
|
</section>
|
|
64
111
|
</main>
|
package/template/src/styles.css
CHANGED
|
@@ -177,6 +177,32 @@ h1 {
|
|
|
177
177
|
font-weight: 700;
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
+
.welcome-actions {
|
|
181
|
+
margin-top: 24px;
|
|
182
|
+
display: flex;
|
|
183
|
+
flex-wrap: wrap;
|
|
184
|
+
gap: 12px;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.welcome-action {
|
|
188
|
+
border: 0;
|
|
189
|
+
border-radius: 999px;
|
|
190
|
+
padding: 12px 18px;
|
|
191
|
+
font: inherit;
|
|
192
|
+
font-weight: 700;
|
|
193
|
+
letter-spacing: 0.02em;
|
|
194
|
+
cursor: pointer;
|
|
195
|
+
color: #f8fbff;
|
|
196
|
+
background: #102347;
|
|
197
|
+
box-shadow: 0 12px 30px rgba(16, 35, 71, 0.18);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.theme-dark .welcome-action {
|
|
201
|
+
background: #f2f6ff;
|
|
202
|
+
color: #102347;
|
|
203
|
+
box-shadow: none;
|
|
204
|
+
}
|
|
205
|
+
|
|
180
206
|
@media (max-width: 640px) {
|
|
181
207
|
.welcome-shell {
|
|
182
208
|
padding: 18px;
|