-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathApp.tsx
More file actions
122 lines (110 loc) · 3.22 KB
/
App.tsx
File metadata and controls
122 lines (110 loc) · 3.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import {
Banner,
Card,
CardView,
KnockGuideProvider,
KnockProvider,
Modal,
useGuide,
} from "@knocklabs/react";
import "@knocklabs/react/dist/index.css";
import { useEffect, useState } from "react";
import { Link, Route, Routes } from "react-router";
interface ChangelogCardContent {
headline: string;
title: string;
body: string;
}
const ChangelogCard = () => {
const { guide, step } = useGuide<ChangelogCardContent>({ type: "changelog-card" });
useEffect(() => {
if (step) step.markAsSeen();
}, [step]);
if (!guide || !step) return null;
return (
<CardView.Default
content={step.content}
onDismiss={() => step.markAsArchived()}
/>
);
};
const Navigation = () => {
return (
<nav style={{ display: "flex", gap: "12px" }}>
<Link to="/">Home</Link>
<Link to="/produce">Produce</Link>
<Link to="/meat">Meat</Link>
<Link to="/seafood">Seafood</Link>
<Link to="/dairy/butter">Dairy > Butter</Link>
<Link to="/dairy/cheese">Dairy > Cheese</Link>
<Link to="/dairy/eggs">Dairy > Eggs</Link>
</nav>
);
};
const Page = ({ title }: { title: string }) => <div>Viewing: {title}</div>;
function App() {
const [colorMode, setColorMode] = useState<"dark" | "light">("light");
return (
<KnockProvider
apiKey={import.meta.env.VITE_KNOCK_API_KEY!}
user={{ id: import.meta.env.VITE_KNOCK_USER_ID! }}
host={import.meta.env.VITE_KNOCK_HOST}
logLevel="debug"
>
<KnockGuideProvider
channelId={import.meta.env.VITE_KNOCK_GUIDE_CHANNEL_ID}
readyToTarget={true}
listenForUpdates={true}
colorMode={colorMode}
toolbar="v2"
>
<div style={{ padding: "1rem 2rem" }}>
<h1>Knock In-App Guide Example</h1>
<div
style={{
display: "flex",
justifyContent: "space-between",
height: "20px",
}}
>
<Navigation />
<button
onClick={() =>
setColorMode(colorMode === "dark" ? "light" : "dark")
}
>
Toggle color mode: {colorMode}
</button>
</div>
<div style={{ marginTop: "20px" }} />
<Banner />
<div style={{ marginTop: "20px" }} />
<Card />
<div style={{ marginTop: "20px" }} />
<Modal />
<div style={{ marginTop: "20px" }} />
<ChangelogCard />
<Routes>
<Route index element={<Page title="home" />} />
<Route path="/produce" element={<Page title="Produce" />} />
<Route path="/meat" element={<Page title="Meat" />} />
<Route path="/seafood" element={<Page title="Seafood" />} />
<Route
path="/dairy/butter"
element={<Page title="Dairy > Butter" />}
/>
<Route
path="/dairy/cheese"
element={<Page title="Dairy > Cheese" />}
/>
<Route
path="/dairy/eggs"
element={<Page title="Dairy > Eggs" />}
/>
</Routes>
</div>
</KnockGuideProvider>
</KnockProvider>
);
}
export default App;