forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage.tsx
More file actions
256 lines (246 loc) · 7.09 KB
/
Copy pathpage.tsx
File metadata and controls
256 lines (246 loc) · 7.09 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
import fs from "node:fs";
import path from "node:path";
import { parse } from "yaml";
type Demo = {
id: string;
name: string;
description?: string;
route?: string;
command?: string;
tags?: string[];
};
type Manifest = {
name: string;
slug: string;
description?: string;
features?: string[];
demos: Demo[];
};
const TAG_ORDER = [
"chat-ui",
"interactivity",
"generative-ui",
"agent-capabilities",
"agent-state",
"multi-agent",
"headless",
"platform",
"other",
];
const TAG_LABELS: Record<string, string> = {
"chat-ui": "Chat UI",
interactivity: "Interactivity",
"generative-ui": "Generative UI",
"agent-capabilities": "Agent Capabilities",
"agent-state": "Agent State",
"multi-agent": "Multi-Agent",
headless: "Headless",
platform: "Platform",
other: "Other",
};
function loadManifest(): Manifest {
const manifestPath = path.join(process.cwd(), "manifest.yaml");
return parse(fs.readFileSync(manifestPath, "utf8")) as Manifest;
}
function groupByTag(
demos: Demo[],
features: string[],
): { tag: string; demos: Demo[] }[] {
// Demos within each tag follow `manifest.features` ordering — that's
// the team's curated "first-impression" arc (polished flagship →
// simplest start → variants). Demos missing from the features list
// fall to the end of their tag.
const featureIndex = new Map(features.map((id, i) => [id, i]));
const orderOf = (id: string) =>
featureIndex.get(id) ?? Number.MAX_SAFE_INTEGER;
const map = new Map<string, Demo[]>();
for (const demo of demos) {
const tag = demo.tags?.[0] ?? "other";
if (!map.has(tag)) map.set(tag, []);
map.get(tag)!.push(demo);
}
for (const list of map.values()) {
list.sort((a, b) => orderOf(a.id) - orderOf(b.id));
}
const tags = Array.from(map.keys()).sort((a, b) => {
const ai = TAG_ORDER.indexOf(a);
const bi = TAG_ORDER.indexOf(b);
return (ai === -1 ? 99 : ai) - (bi === -1 ? 99 : bi);
});
return tags.map((tag) => ({ tag, demos: map.get(tag)! }));
}
export default function Home() {
const manifest = loadManifest();
const runnable = (manifest.demos ?? []).filter((d) => d.route);
const groups = groupByTag(runnable, manifest.features ?? []);
return (
<div
style={{
position: "fixed",
inset: 0,
overflowY: "auto",
background: "var(--background)",
color: "var(--foreground)",
}}
>
<main
style={{
maxWidth: "980px",
margin: "0 auto",
padding: "3rem 1.5rem 4rem",
}}
>
<header
style={{
paddingBottom: "1.5rem",
borderBottom: "1px solid var(--border)",
marginBottom: "2rem",
}}
>
<div
style={{
fontSize: "0.75rem",
fontWeight: 600,
letterSpacing: "0.08em",
textTransform: "uppercase",
color: "var(--muted-foreground)",
marginBottom: "0.5rem",
}}
>
CopilotKit Showcase
</div>
<h1
style={{
fontSize: "2.25rem",
fontWeight: 700,
letterSpacing: "-0.02em",
margin: 0,
}}
>
{manifest.name}
</h1>
<p
style={{
color: "var(--muted-foreground)",
fontSize: "1rem",
lineHeight: 1.6,
marginTop: "0.75rem",
maxWidth: "62ch",
}}
>
{manifest.description ??
"Browse runnable demos for this integration."}
</p>
<div
style={{
display: "flex",
gap: "0.5rem",
marginTop: "1rem",
fontSize: "0.8125rem",
color: "var(--muted-foreground)",
}}
>
<span>
<strong style={{ color: "var(--foreground)" }}>
{runnable.length}
</strong>{" "}
demos
</span>
<span>·</span>
<span>{groups.length} categories</span>
<span>·</span>
<span>
integration{" "}
<code
style={{
background: "var(--muted)",
padding: "0.125rem 0.4rem",
borderRadius: "0.375rem",
fontSize: "0.8125rem",
}}
>
{manifest.slug}
</code>
</span>
</div>
</header>
{groups.map(({ tag, demos }) => (
<section key={tag} style={{ marginBottom: "2.5rem" }}>
<h2
style={{
fontSize: "0.8125rem",
fontWeight: 600,
textTransform: "uppercase",
letterSpacing: "0.08em",
color: "var(--muted-foreground)",
margin: "0 0 0.875rem",
}}
>
{TAG_LABELS[tag] ?? tag.replace(/-/g, " ")}
<span
style={{
marginLeft: "0.5rem",
fontWeight: 400,
color: "var(--muted-foreground)",
opacity: 0.6,
}}
>
{demos.length}
</span>
</h2>
<div
style={{
display: "grid",
gridTemplateColumns: "repeat(auto-fill, minmax(260px, 1fr))",
gap: "0.75rem",
}}
>
{demos.map((demo) => (
<a key={demo.id} href={demo.route} className="demo-card">
<h3
style={{
fontSize: "1rem",
fontWeight: 600,
letterSpacing: "-0.01em",
margin: "0 0 0.375rem",
color: "var(--foreground)",
}}
>
{demo.name}
</h3>
{demo.description && (
<p
style={{
fontSize: "0.8125rem",
lineHeight: 1.5,
color: "var(--muted-foreground)",
margin: 0,
display: "-webkit-box",
WebkitLineClamp: 3,
WebkitBoxOrient: "vertical",
overflow: "hidden",
}}
>
{demo.description}
</p>
)}
<div
style={{
marginTop: "0.75rem",
fontFamily: "ui-monospace, monospace",
fontSize: "0.75rem",
color: "var(--muted-foreground)",
opacity: 0.7,
}}
>
{demo.route}
</div>
</a>
))}
</div>
</section>
))}
</main>
</div>
);
}