@lssm/example.learning-journey-ui-gamified 0.0.0-canary-20251212210835
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/.turbo/turbo-build.log +22 -0
- package/CHANGELOG.md +13 -0
- package/README.md +30 -0
- package/dist/DayCalendar-Cha869Bi.mjs +178 -0
- package/dist/components/index.d.mts +2 -0
- package/dist/components/index.mjs +4 -0
- package/dist/components-kh0CpIG2.mjs +1 -0
- package/dist/index-Bi5V3Ihq.d.mts +33 -0
- package/dist/index-DrzEZfnF.d.mts +44 -0
- package/dist/index.d.mts +18 -0
- package/dist/index.mjs +59 -0
- package/dist/views/index.d.mts +2 -0
- package/dist/views/index.mjs +4 -0
- package/dist/views-B-DapxWu.mjs +467 -0
- package/package.json +53 -0
- package/src/GamifiedMiniApp.tsx +94 -0
- package/src/components/DayCalendar.tsx +54 -0
- package/src/components/FlashCard.tsx +101 -0
- package/src/components/MasteryRing.tsx +82 -0
- package/src/components/index.ts +4 -0
- package/src/index.ts +9 -0
- package/src/views/Overview.tsx +165 -0
- package/src/views/Progress.tsx +181 -0
- package/src/views/Steps.tsx +51 -0
- package/src/views/Timeline.tsx +198 -0
- package/src/views/index.ts +5 -0
- package/tsconfig.json +10 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/tsdown.config.js +13 -0
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
import { n as MasteryRing, r as FlashCard, t as DayCalendar } from "./DayCalendar-Cha869Bi.mjs";
|
|
2
|
+
import { Card, CardContent, CardHeader, CardTitle } from "@lssm/lib.ui-kit-web/ui/card";
|
|
3
|
+
import { BadgeDisplay, StreakCounter, XpBar } from "@lssm/example.learning-journey-ui-shared";
|
|
4
|
+
import { Button } from "@lssm/lib.design-system";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
//#region src/views/Overview.tsx
|
|
8
|
+
function Overview({ track, progress, onStart }) {
|
|
9
|
+
const totalXp = track.totalXp ?? track.steps.reduce((sum, s) => sum + (s.xpReward ?? 0), 0) + (track.completionRewards?.xpBonus ?? 0);
|
|
10
|
+
const completedSteps = progress.completedStepIds.length;
|
|
11
|
+
const totalSteps = track.steps.length;
|
|
12
|
+
const isComplete = completedSteps === totalSteps;
|
|
13
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
14
|
+
className: "space-y-6",
|
|
15
|
+
children: [
|
|
16
|
+
/* @__PURE__ */ jsx(Card, {
|
|
17
|
+
className: "overflow-hidden bg-gradient-to-br from-violet-500/10 via-purple-500/10 to-fuchsia-500/10",
|
|
18
|
+
children: /* @__PURE__ */ jsx(CardContent, {
|
|
19
|
+
className: "p-6",
|
|
20
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
21
|
+
className: "flex flex-col items-center gap-4 text-center md:flex-row md:text-left",
|
|
22
|
+
children: [
|
|
23
|
+
/* @__PURE__ */ jsx("div", {
|
|
24
|
+
className: "flex h-20 w-20 items-center justify-center rounded-2xl bg-gradient-to-br from-violet-500 to-purple-600 text-4xl shadow-lg",
|
|
25
|
+
children: isComplete ? "🏆" : "🎯"
|
|
26
|
+
}),
|
|
27
|
+
/* @__PURE__ */ jsxs("div", {
|
|
28
|
+
className: "flex-1",
|
|
29
|
+
children: [/* @__PURE__ */ jsx("h1", {
|
|
30
|
+
className: "text-2xl font-bold",
|
|
31
|
+
children: track.name
|
|
32
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
33
|
+
className: "text-muted-foreground mt-1",
|
|
34
|
+
children: track.description
|
|
35
|
+
})]
|
|
36
|
+
}),
|
|
37
|
+
/* @__PURE__ */ jsx("div", {
|
|
38
|
+
className: "flex items-center gap-3",
|
|
39
|
+
children: /* @__PURE__ */ jsx(StreakCounter, {
|
|
40
|
+
days: progress.streakDays,
|
|
41
|
+
size: "lg"
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
]
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
}),
|
|
48
|
+
/* @__PURE__ */ jsxs("div", {
|
|
49
|
+
className: "grid gap-4 md:grid-cols-3",
|
|
50
|
+
children: [
|
|
51
|
+
/* @__PURE__ */ jsxs(Card, { children: [/* @__PURE__ */ jsx(CardHeader, {
|
|
52
|
+
className: "pb-2",
|
|
53
|
+
children: /* @__PURE__ */ jsx(CardTitle, {
|
|
54
|
+
className: "text-muted-foreground text-sm font-medium",
|
|
55
|
+
children: "XP Progress"
|
|
56
|
+
})
|
|
57
|
+
}), /* @__PURE__ */ jsxs(CardContent, { children: [/* @__PURE__ */ jsx("div", {
|
|
58
|
+
className: "text-3xl font-bold text-violet-500",
|
|
59
|
+
children: progress.xpEarned.toLocaleString()
|
|
60
|
+
}), /* @__PURE__ */ jsx(XpBar, {
|
|
61
|
+
current: progress.xpEarned,
|
|
62
|
+
max: totalXp,
|
|
63
|
+
showLabel: false,
|
|
64
|
+
size: "sm"
|
|
65
|
+
})] })] }),
|
|
66
|
+
/* @__PURE__ */ jsxs(Card, { children: [/* @__PURE__ */ jsx(CardHeader, {
|
|
67
|
+
className: "pb-2",
|
|
68
|
+
children: /* @__PURE__ */ jsx(CardTitle, {
|
|
69
|
+
className: "text-muted-foreground text-sm font-medium",
|
|
70
|
+
children: "Steps Completed"
|
|
71
|
+
})
|
|
72
|
+
}), /* @__PURE__ */ jsxs(CardContent, { children: [/* @__PURE__ */ jsxs("div", {
|
|
73
|
+
className: "text-3xl font-bold",
|
|
74
|
+
children: [
|
|
75
|
+
completedSteps,
|
|
76
|
+
" ",
|
|
77
|
+
/* @__PURE__ */ jsxs("span", {
|
|
78
|
+
className: "text-muted-foreground text-lg",
|
|
79
|
+
children: ["/ ", totalSteps]
|
|
80
|
+
})
|
|
81
|
+
]
|
|
82
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
83
|
+
className: "bg-muted mt-2 h-2 w-full overflow-hidden rounded-full",
|
|
84
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
85
|
+
className: "h-full bg-green-500 transition-all duration-500",
|
|
86
|
+
style: { width: `${completedSteps / totalSteps * 100}%` }
|
|
87
|
+
})
|
|
88
|
+
})] })] }),
|
|
89
|
+
/* @__PURE__ */ jsxs(Card, { children: [/* @__PURE__ */ jsx(CardHeader, {
|
|
90
|
+
className: "pb-2",
|
|
91
|
+
children: /* @__PURE__ */ jsx(CardTitle, {
|
|
92
|
+
className: "text-muted-foreground text-sm font-medium",
|
|
93
|
+
children: "Badges Earned"
|
|
94
|
+
})
|
|
95
|
+
}), /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx(BadgeDisplay, {
|
|
96
|
+
badges: progress.badges,
|
|
97
|
+
size: "lg"
|
|
98
|
+
}) })] })
|
|
99
|
+
]
|
|
100
|
+
}),
|
|
101
|
+
!isComplete && /* @__PURE__ */ jsxs(Card, { children: [/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsxs(CardTitle, {
|
|
102
|
+
className: "flex items-center gap-2",
|
|
103
|
+
children: [/* @__PURE__ */ jsx("span", { children: "🎯" }), /* @__PURE__ */ jsx("span", { children: "Next Challenge" })]
|
|
104
|
+
}) }), /* @__PURE__ */ jsx(CardContent, { children: (() => {
|
|
105
|
+
const nextStep = track.steps.find((s) => !progress.completedStepIds.includes(s.id));
|
|
106
|
+
if (!nextStep) return null;
|
|
107
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
108
|
+
className: "flex items-center justify-between gap-4",
|
|
109
|
+
children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", {
|
|
110
|
+
className: "font-semibold",
|
|
111
|
+
children: nextStep.title
|
|
112
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
113
|
+
className: "text-muted-foreground text-sm",
|
|
114
|
+
children: nextStep.description
|
|
115
|
+
})] }), /* @__PURE__ */ jsxs("div", {
|
|
116
|
+
className: "flex items-center gap-3",
|
|
117
|
+
children: [nextStep.xpReward && /* @__PURE__ */ jsxs("span", {
|
|
118
|
+
className: "rounded-full bg-green-500/10 px-3 py-1 text-sm font-semibold text-green-500",
|
|
119
|
+
children: [
|
|
120
|
+
"+",
|
|
121
|
+
nextStep.xpReward,
|
|
122
|
+
" XP"
|
|
123
|
+
]
|
|
124
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
125
|
+
onClick: onStart,
|
|
126
|
+
children: "Start"
|
|
127
|
+
})]
|
|
128
|
+
})]
|
|
129
|
+
});
|
|
130
|
+
})() })] }),
|
|
131
|
+
isComplete && /* @__PURE__ */ jsx(Card, {
|
|
132
|
+
className: "border-green-500/50 bg-green-500/5",
|
|
133
|
+
children: /* @__PURE__ */ jsxs(CardContent, {
|
|
134
|
+
className: "flex items-center gap-4 p-6",
|
|
135
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
136
|
+
className: "text-4xl",
|
|
137
|
+
children: "🎉"
|
|
138
|
+
}), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", {
|
|
139
|
+
className: "text-lg font-semibold text-green-500",
|
|
140
|
+
children: "Track Complete!"
|
|
141
|
+
}), /* @__PURE__ */ jsxs("p", {
|
|
142
|
+
className: "text-muted-foreground",
|
|
143
|
+
children: [
|
|
144
|
+
"You've mastered all ",
|
|
145
|
+
totalSteps,
|
|
146
|
+
" challenges and earned",
|
|
147
|
+
" ",
|
|
148
|
+
progress.xpEarned,
|
|
149
|
+
" XP."
|
|
150
|
+
]
|
|
151
|
+
})] })]
|
|
152
|
+
})
|
|
153
|
+
})
|
|
154
|
+
]
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
//#endregion
|
|
159
|
+
//#region src/views/Steps.tsx
|
|
160
|
+
function Steps({ track, progress, onStepComplete }) {
|
|
161
|
+
const currentStepIndex = track.steps.findIndex((s) => !progress.completedStepIds.includes(s.id));
|
|
162
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
163
|
+
className: "space-y-6",
|
|
164
|
+
children: [
|
|
165
|
+
/* @__PURE__ */ jsxs("div", {
|
|
166
|
+
className: "text-center",
|
|
167
|
+
children: [/* @__PURE__ */ jsx("h2", {
|
|
168
|
+
className: "text-xl font-bold",
|
|
169
|
+
children: "Complete Your Challenges"
|
|
170
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
171
|
+
className: "text-muted-foreground",
|
|
172
|
+
children: "Tap each card to reveal the action, then mark as complete"
|
|
173
|
+
})]
|
|
174
|
+
}),
|
|
175
|
+
/* @__PURE__ */ jsx("div", {
|
|
176
|
+
className: "grid gap-4 md:grid-cols-2",
|
|
177
|
+
children: track.steps.map((step, index) => {
|
|
178
|
+
return /* @__PURE__ */ jsx(FlashCard, {
|
|
179
|
+
step,
|
|
180
|
+
isCompleted: progress.completedStepIds.includes(step.id),
|
|
181
|
+
isCurrent: index === currentStepIndex,
|
|
182
|
+
onComplete: () => onStepComplete?.(step.id)
|
|
183
|
+
}, step.id);
|
|
184
|
+
})
|
|
185
|
+
}),
|
|
186
|
+
/* @__PURE__ */ jsxs("div", {
|
|
187
|
+
className: "text-muted-foreground text-center text-sm",
|
|
188
|
+
children: [
|
|
189
|
+
progress.completedStepIds.length,
|
|
190
|
+
" of ",
|
|
191
|
+
track.steps.length,
|
|
192
|
+
" completed",
|
|
193
|
+
track.completionRewards?.xpBonus && /* @__PURE__ */ jsxs("span", {
|
|
194
|
+
className: "ml-2 text-green-500",
|
|
195
|
+
children: [
|
|
196
|
+
"(+",
|
|
197
|
+
track.completionRewards.xpBonus,
|
|
198
|
+
" XP bonus on completion)"
|
|
199
|
+
]
|
|
200
|
+
})
|
|
201
|
+
]
|
|
202
|
+
})
|
|
203
|
+
]
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
//#endregion
|
|
208
|
+
//#region src/views/Progress.tsx
|
|
209
|
+
function Progress({ track, progress }) {
|
|
210
|
+
const totalXp = track.totalXp ?? track.steps.reduce((sum, s) => sum + (s.xpReward ?? 0), 0) + (track.completionRewards?.xpBonus ?? 0);
|
|
211
|
+
const completedSteps = progress.completedStepIds.length;
|
|
212
|
+
const totalSteps = track.steps.length;
|
|
213
|
+
const percentComplete = totalSteps > 0 ? completedSteps / totalSteps * 100 : 0;
|
|
214
|
+
const surfaces = /* @__PURE__ */ new Map();
|
|
215
|
+
track.steps.forEach((step) => {
|
|
216
|
+
const surface = step.metadata?.surface ?? "general";
|
|
217
|
+
const current = surfaces.get(surface) ?? {
|
|
218
|
+
total: 0,
|
|
219
|
+
completed: 0
|
|
220
|
+
};
|
|
221
|
+
surfaces.set(surface, {
|
|
222
|
+
total: current.total + 1,
|
|
223
|
+
completed: current.completed + (progress.completedStepIds.includes(step.id) ? 1 : 0)
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
const surfaceColors = [
|
|
227
|
+
"green",
|
|
228
|
+
"blue",
|
|
229
|
+
"violet",
|
|
230
|
+
"orange"
|
|
231
|
+
];
|
|
232
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
233
|
+
className: "space-y-6",
|
|
234
|
+
children: [
|
|
235
|
+
/* @__PURE__ */ jsxs(Card, { children: [/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsxs(CardTitle, {
|
|
236
|
+
className: "flex items-center gap-2",
|
|
237
|
+
children: [/* @__PURE__ */ jsx("span", { children: "⚡" }), /* @__PURE__ */ jsx("span", { children: "Experience Points" })]
|
|
238
|
+
}) }), /* @__PURE__ */ jsxs(CardContent, {
|
|
239
|
+
className: "space-y-4",
|
|
240
|
+
children: [
|
|
241
|
+
/* @__PURE__ */ jsxs("div", {
|
|
242
|
+
className: "flex items-baseline gap-2",
|
|
243
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
244
|
+
className: "text-4xl font-bold text-violet-500",
|
|
245
|
+
children: progress.xpEarned.toLocaleString()
|
|
246
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
247
|
+
className: "text-muted-foreground",
|
|
248
|
+
children: [
|
|
249
|
+
"/ ",
|
|
250
|
+
totalXp.toLocaleString(),
|
|
251
|
+
" XP"
|
|
252
|
+
]
|
|
253
|
+
})]
|
|
254
|
+
}),
|
|
255
|
+
/* @__PURE__ */ jsx(XpBar, {
|
|
256
|
+
current: progress.xpEarned,
|
|
257
|
+
max: totalXp,
|
|
258
|
+
showLabel: false,
|
|
259
|
+
size: "lg"
|
|
260
|
+
}),
|
|
261
|
+
track.completionRewards?.xpBonus && percentComplete < 100 && /* @__PURE__ */ jsxs("p", {
|
|
262
|
+
className: "text-muted-foreground text-sm",
|
|
263
|
+
children: [
|
|
264
|
+
"🎁 Complete all steps for a",
|
|
265
|
+
" ",
|
|
266
|
+
/* @__PURE__ */ jsxs("span", {
|
|
267
|
+
className: "font-semibold text-green-500",
|
|
268
|
+
children: [
|
|
269
|
+
"+",
|
|
270
|
+
track.completionRewards.xpBonus,
|
|
271
|
+
" XP"
|
|
272
|
+
]
|
|
273
|
+
}),
|
|
274
|
+
" ",
|
|
275
|
+
"bonus!"
|
|
276
|
+
]
|
|
277
|
+
})
|
|
278
|
+
]
|
|
279
|
+
})] }),
|
|
280
|
+
/* @__PURE__ */ jsxs(Card, { children: [/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsxs(CardTitle, {
|
|
281
|
+
className: "flex items-center gap-2",
|
|
282
|
+
children: [/* @__PURE__ */ jsx("span", { children: "🎯" }), /* @__PURE__ */ jsx("span", { children: "Skill Mastery" })]
|
|
283
|
+
}) }), /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsxs("div", {
|
|
284
|
+
className: "flex flex-wrap justify-center gap-6",
|
|
285
|
+
children: [Array.from(surfaces.entries()).map(([surface, data], index) => /* @__PURE__ */ jsx(MasteryRing, {
|
|
286
|
+
label: surface.charAt(0).toUpperCase() + surface.slice(1),
|
|
287
|
+
percentage: data.completed / data.total * 100,
|
|
288
|
+
color: surfaceColors[index % surfaceColors.length],
|
|
289
|
+
size: "lg"
|
|
290
|
+
}, surface)), /* @__PURE__ */ jsx(MasteryRing, {
|
|
291
|
+
label: "Overall",
|
|
292
|
+
percentage: percentComplete,
|
|
293
|
+
color: "violet",
|
|
294
|
+
size: "lg"
|
|
295
|
+
})]
|
|
296
|
+
}) })] }),
|
|
297
|
+
/* @__PURE__ */ jsxs(Card, { children: [/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsxs(CardTitle, {
|
|
298
|
+
className: "flex items-center gap-2",
|
|
299
|
+
children: [/* @__PURE__ */ jsx("span", { children: "🏅" }), /* @__PURE__ */ jsx("span", { children: "Badges Earned" })]
|
|
300
|
+
}) }), /* @__PURE__ */ jsxs(CardContent, { children: [/* @__PURE__ */ jsx(BadgeDisplay, {
|
|
301
|
+
badges: progress.badges,
|
|
302
|
+
size: "lg",
|
|
303
|
+
maxVisible: 10
|
|
304
|
+
}), progress.badges.length === 0 && /* @__PURE__ */ jsx("p", {
|
|
305
|
+
className: "text-muted-foreground text-sm",
|
|
306
|
+
children: "Complete the track to earn your first badge!"
|
|
307
|
+
})] })] }),
|
|
308
|
+
/* @__PURE__ */ jsxs(Card, { children: [/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsxs(CardTitle, {
|
|
309
|
+
className: "flex items-center gap-2",
|
|
310
|
+
children: [/* @__PURE__ */ jsx("span", { children: "📊" }), /* @__PURE__ */ jsx("span", { children: "Step Breakdown" })]
|
|
311
|
+
}) }), /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx("div", {
|
|
312
|
+
className: "space-y-2",
|
|
313
|
+
children: track.steps.map((step) => {
|
|
314
|
+
const isCompleted = progress.completedStepIds.includes(step.id);
|
|
315
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
316
|
+
className: "flex items-center justify-between rounded-lg border p-3",
|
|
317
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
318
|
+
className: "flex items-center gap-3",
|
|
319
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
320
|
+
className: isCompleted ? "text-green-500" : "text-muted-foreground",
|
|
321
|
+
children: isCompleted ? "✓" : "○"
|
|
322
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
323
|
+
className: isCompleted ? "text-foreground" : "text-muted-foreground",
|
|
324
|
+
children: step.title
|
|
325
|
+
})]
|
|
326
|
+
}), step.xpReward && /* @__PURE__ */ jsxs("span", {
|
|
327
|
+
className: `text-sm font-medium ${isCompleted ? "text-green-500" : "text-muted-foreground"}`,
|
|
328
|
+
children: [
|
|
329
|
+
isCompleted ? "+" : "",
|
|
330
|
+
step.xpReward,
|
|
331
|
+
" XP"
|
|
332
|
+
]
|
|
333
|
+
})]
|
|
334
|
+
}, step.id);
|
|
335
|
+
})
|
|
336
|
+
}) })] })
|
|
337
|
+
]
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
//#endregion
|
|
342
|
+
//#region src/views/Timeline.tsx
|
|
343
|
+
function Timeline({ track, progress }) {
|
|
344
|
+
if (track.steps.some((s) => s.availability?.unlockOnDay !== void 0)) {
|
|
345
|
+
const totalDays = Math.max(...track.steps.map((s) => s.availability?.unlockOnDay ?? 1), 7);
|
|
346
|
+
const completedDays = track.steps.filter((s) => progress.completedStepIds.includes(s.id)).map((s) => s.availability?.unlockOnDay ?? 1);
|
|
347
|
+
const currentDay = track.steps.find((s) => !progress.completedStepIds.includes(s.id))?.availability?.unlockOnDay ?? 1;
|
|
348
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
349
|
+
className: "space-y-6",
|
|
350
|
+
children: [
|
|
351
|
+
/* @__PURE__ */ jsxs("div", {
|
|
352
|
+
className: "text-center",
|
|
353
|
+
children: [/* @__PURE__ */ jsx("h2", {
|
|
354
|
+
className: "text-xl font-bold",
|
|
355
|
+
children: track.name
|
|
356
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
357
|
+
className: "text-muted-foreground",
|
|
358
|
+
children: "Complete each day's challenge to progress"
|
|
359
|
+
})]
|
|
360
|
+
}),
|
|
361
|
+
/* @__PURE__ */ jsxs(Card, { children: [/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsxs(CardTitle, {
|
|
362
|
+
className: "flex items-center gap-2",
|
|
363
|
+
children: [/* @__PURE__ */ jsx("span", { children: "📅" }), /* @__PURE__ */ jsx("span", { children: "Your Journey" })]
|
|
364
|
+
}) }), /* @__PURE__ */ jsx(CardContent, {
|
|
365
|
+
className: "flex justify-center",
|
|
366
|
+
children: /* @__PURE__ */ jsx(DayCalendar, {
|
|
367
|
+
totalDays,
|
|
368
|
+
currentDay,
|
|
369
|
+
completedDays
|
|
370
|
+
})
|
|
371
|
+
})] }),
|
|
372
|
+
/* @__PURE__ */ jsxs(Card, { children: [/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsxs(CardTitle, {
|
|
373
|
+
className: "flex items-center gap-2",
|
|
374
|
+
children: [/* @__PURE__ */ jsx("span", { children: "📝" }), /* @__PURE__ */ jsx("span", { children: "Daily Challenges" })]
|
|
375
|
+
}) }), /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx("div", {
|
|
376
|
+
className: "space-y-3",
|
|
377
|
+
children: track.steps.map((step) => {
|
|
378
|
+
const day = step.availability?.unlockOnDay ?? 1;
|
|
379
|
+
const isCompleted = progress.completedStepIds.includes(step.id);
|
|
380
|
+
const isLocked = day > currentDay;
|
|
381
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
382
|
+
className: `flex items-start gap-4 rounded-lg border p-4 ${isLocked ? "opacity-50" : ""}`,
|
|
383
|
+
children: [
|
|
384
|
+
/* @__PURE__ */ jsx("div", {
|
|
385
|
+
className: "bg-muted flex h-10 w-10 shrink-0 items-center justify-center rounded-lg font-semibold",
|
|
386
|
+
children: isCompleted ? "✓" : isLocked ? "🔒" : day
|
|
387
|
+
}),
|
|
388
|
+
/* @__PURE__ */ jsxs("div", {
|
|
389
|
+
className: "flex-1",
|
|
390
|
+
children: [/* @__PURE__ */ jsx("h4", {
|
|
391
|
+
className: "font-semibold",
|
|
392
|
+
children: step.title
|
|
393
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
394
|
+
className: "text-muted-foreground text-sm",
|
|
395
|
+
children: step.description
|
|
396
|
+
})]
|
|
397
|
+
}),
|
|
398
|
+
step.xpReward && /* @__PURE__ */ jsxs("span", {
|
|
399
|
+
className: `text-sm font-medium ${isCompleted ? "text-green-500" : "text-muted-foreground"}`,
|
|
400
|
+
children: [
|
|
401
|
+
"+",
|
|
402
|
+
step.xpReward,
|
|
403
|
+
" XP"
|
|
404
|
+
]
|
|
405
|
+
})
|
|
406
|
+
]
|
|
407
|
+
}, step.id);
|
|
408
|
+
})
|
|
409
|
+
}) })] })
|
|
410
|
+
]
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
414
|
+
className: "space-y-6",
|
|
415
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
416
|
+
className: "text-center",
|
|
417
|
+
children: [/* @__PURE__ */ jsx("h2", {
|
|
418
|
+
className: "text-xl font-bold",
|
|
419
|
+
children: "Learning Path"
|
|
420
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
421
|
+
className: "text-muted-foreground",
|
|
422
|
+
children: "Follow the steps to master this skill"
|
|
423
|
+
})]
|
|
424
|
+
}), /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsx(CardContent, {
|
|
425
|
+
className: "p-6",
|
|
426
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
427
|
+
className: "relative",
|
|
428
|
+
children: [/* @__PURE__ */ jsx("div", { className: "bg-border absolute top-0 left-5 h-full w-0.5" }), /* @__PURE__ */ jsx("div", {
|
|
429
|
+
className: "space-y-6",
|
|
430
|
+
children: track.steps.map((step, index) => {
|
|
431
|
+
const isCompleted = progress.completedStepIds.includes(step.id);
|
|
432
|
+
const isCurrent = !isCompleted && track.steps.slice(0, index).every((s) => progress.completedStepIds.includes(s.id));
|
|
433
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
434
|
+
className: "relative flex gap-4 pl-2",
|
|
435
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
436
|
+
className: `relative z-10 flex h-8 w-8 shrink-0 items-center justify-center rounded-full border-2 ${isCompleted ? "border-green-500 bg-green-500 text-white" : isCurrent ? "border-violet-500 bg-violet-500 text-white" : "border-border bg-background"}`,
|
|
437
|
+
children: isCompleted ? "✓" : index + 1
|
|
438
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
439
|
+
className: "flex-1 pb-4",
|
|
440
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
441
|
+
className: "flex items-start justify-between gap-2",
|
|
442
|
+
children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h4", {
|
|
443
|
+
className: `font-semibold ${isCompleted ? "text-foreground" : isCurrent ? "text-violet-500" : "text-muted-foreground"}`,
|
|
444
|
+
children: step.title
|
|
445
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
446
|
+
className: "text-muted-foreground mt-1 text-sm",
|
|
447
|
+
children: step.description
|
|
448
|
+
})] }), step.xpReward && /* @__PURE__ */ jsxs("span", {
|
|
449
|
+
className: `shrink-0 rounded-full px-2 py-1 text-xs font-semibold ${isCompleted ? "bg-green-500/10 text-green-500" : "bg-muted text-muted-foreground"}`,
|
|
450
|
+
children: [
|
|
451
|
+
"+",
|
|
452
|
+
step.xpReward,
|
|
453
|
+
" XP"
|
|
454
|
+
]
|
|
455
|
+
})]
|
|
456
|
+
})
|
|
457
|
+
})]
|
|
458
|
+
}, step.id);
|
|
459
|
+
})
|
|
460
|
+
})]
|
|
461
|
+
})
|
|
462
|
+
}) })]
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
//#endregion
|
|
467
|
+
export { Overview as i, Progress as n, Steps as r, Timeline as t };
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lssm/example.learning-journey-ui-gamified",
|
|
3
|
+
"version": "0.0.0-canary-20251212210835",
|
|
4
|
+
"description": "Duolingo-style gamified learning UI for drills and quests.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./src/index.ts",
|
|
10
|
+
"./views": "./src/views/index.ts",
|
|
11
|
+
"./components": "./src/components/index.ts",
|
|
12
|
+
"./*": "./*"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "bun build:bundle && bun build:types",
|
|
16
|
+
"build:bundle": "tsdown",
|
|
17
|
+
"build:types": "tsc --noEmit",
|
|
18
|
+
"dev": "bun build:bundle --watch",
|
|
19
|
+
"clean": "rimraf dist .turbo",
|
|
20
|
+
"lint": "bun lint:fix",
|
|
21
|
+
"lint:fix": "eslint src --fix",
|
|
22
|
+
"lint:check": "eslint src",
|
|
23
|
+
"test": "bun test"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@lssm/example.learning-journey-ui-shared": "workspace:*",
|
|
27
|
+
"@lssm/example.learning-journey.duo-drills": "workspace:*",
|
|
28
|
+
"@lssm/example.learning-journey.quest-challenges": "workspace:*",
|
|
29
|
+
"@lssm/module.learning-journey": "workspace:*",
|
|
30
|
+
"@lssm/lib.design-system": "workspace:*",
|
|
31
|
+
"@lssm/lib.ui-kit-web": "workspace:*",
|
|
32
|
+
"react": "^19.1.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@lssm/tool.tsdown": "workspace:*",
|
|
36
|
+
"@lssm/tool.typescript": "workspace:*",
|
|
37
|
+
"@types/react": "^19.1.6",
|
|
38
|
+
"tsdown": "^0.17.0",
|
|
39
|
+
"typescript": "^5.9.3"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
43
|
+
},
|
|
44
|
+
"module": "./dist/index.js",
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"exports": {
|
|
47
|
+
".": "./dist/index.js",
|
|
48
|
+
"./views": "./dist/views/index.js",
|
|
49
|
+
"./components": "./dist/components/index.js",
|
|
50
|
+
"./*": "./*"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useState, useCallback } from 'react';
|
|
4
|
+
import { Card, CardContent } from '@lssm/lib.ui-kit-web/ui/card';
|
|
5
|
+
import {
|
|
6
|
+
ViewTabs,
|
|
7
|
+
useLearningProgress,
|
|
8
|
+
type LearningView,
|
|
9
|
+
type LearningMiniAppProps,
|
|
10
|
+
} from '@lssm/example.learning-journey-ui-shared';
|
|
11
|
+
import { Overview } from './views/Overview';
|
|
12
|
+
import { Steps } from './views/Steps';
|
|
13
|
+
import { Progress } from './views/Progress';
|
|
14
|
+
import { Timeline } from './views/Timeline';
|
|
15
|
+
|
|
16
|
+
type GamifiedMiniAppProps = Omit<LearningMiniAppProps, 'progress'> & {
|
|
17
|
+
progress?: LearningMiniAppProps['progress'];
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export function GamifiedMiniApp({
|
|
21
|
+
track,
|
|
22
|
+
progress: externalProgress,
|
|
23
|
+
onStepComplete: externalOnStepComplete,
|
|
24
|
+
onViewChange,
|
|
25
|
+
initialView = 'overview',
|
|
26
|
+
}: GamifiedMiniAppProps) {
|
|
27
|
+
const [currentView, setCurrentView] = useState<LearningView>(initialView);
|
|
28
|
+
|
|
29
|
+
// Use internal progress if not provided externally
|
|
30
|
+
const { progress: internalProgress, completeStep: internalCompleteStep } =
|
|
31
|
+
useLearningProgress(track);
|
|
32
|
+
|
|
33
|
+
const progress = externalProgress ?? internalProgress;
|
|
34
|
+
|
|
35
|
+
const handleViewChange = useCallback(
|
|
36
|
+
(view: LearningView) => {
|
|
37
|
+
setCurrentView(view);
|
|
38
|
+
onViewChange?.(view);
|
|
39
|
+
},
|
|
40
|
+
[onViewChange]
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const handleStepComplete = useCallback(
|
|
44
|
+
(stepId: string) => {
|
|
45
|
+
if (externalOnStepComplete) {
|
|
46
|
+
externalOnStepComplete(stepId);
|
|
47
|
+
} else {
|
|
48
|
+
internalCompleteStep(stepId);
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
[externalOnStepComplete, internalCompleteStep]
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const handleStartFromOverview = useCallback(() => {
|
|
55
|
+
setCurrentView('steps');
|
|
56
|
+
onViewChange?.('steps');
|
|
57
|
+
}, [onViewChange]);
|
|
58
|
+
|
|
59
|
+
const renderView = () => {
|
|
60
|
+
const viewProps = {
|
|
61
|
+
track,
|
|
62
|
+
progress,
|
|
63
|
+
onStepComplete: handleStepComplete,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
switch (currentView) {
|
|
67
|
+
case 'overview':
|
|
68
|
+
return <Overview {...viewProps} onStart={handleStartFromOverview} />;
|
|
69
|
+
case 'steps':
|
|
70
|
+
return <Steps {...viewProps} />;
|
|
71
|
+
case 'progress':
|
|
72
|
+
return <Progress {...viewProps} />;
|
|
73
|
+
case 'timeline':
|
|
74
|
+
return <Timeline {...viewProps} />;
|
|
75
|
+
default:
|
|
76
|
+
return <Overview {...viewProps} onStart={handleStartFromOverview} />;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<div className="space-y-6">
|
|
82
|
+
{/* Navigation */}
|
|
83
|
+
<Card>
|
|
84
|
+
<CardContent className="p-4">
|
|
85
|
+
<ViewTabs currentView={currentView} onViewChange={handleViewChange} />
|
|
86
|
+
</CardContent>
|
|
87
|
+
</Card>
|
|
88
|
+
|
|
89
|
+
{/* Current View */}
|
|
90
|
+
{renderView()}
|
|
91
|
+
</div>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { cn } from '@lssm/lib.ui-kit-web/ui/utils';
|
|
4
|
+
|
|
5
|
+
interface DayCalendarProps {
|
|
6
|
+
totalDays: number;
|
|
7
|
+
currentDay: number;
|
|
8
|
+
completedDays: number[];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function DayCalendar({
|
|
12
|
+
totalDays,
|
|
13
|
+
currentDay,
|
|
14
|
+
completedDays,
|
|
15
|
+
}: DayCalendarProps) {
|
|
16
|
+
const days = Array.from({ length: totalDays }, (_, i) => i + 1);
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<div className="grid grid-cols-7 gap-2">
|
|
20
|
+
{days.map((day) => {
|
|
21
|
+
const isCompleted = completedDays.includes(day);
|
|
22
|
+
const isCurrent = day === currentDay;
|
|
23
|
+
const isLocked = day > currentDay;
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div
|
|
27
|
+
key={day}
|
|
28
|
+
className={cn(
|
|
29
|
+
'flex h-12 w-12 flex-col items-center justify-center rounded-lg border text-sm font-medium transition-all',
|
|
30
|
+
isCompleted && 'border-green-500 bg-green-500/10 text-green-500',
|
|
31
|
+
isCurrent &&
|
|
32
|
+
!isCompleted &&
|
|
33
|
+
'border-violet-500 bg-violet-500/10 text-violet-500 ring-2 ring-violet-500/50',
|
|
34
|
+
isLocked && 'border-muted bg-muted/50 text-muted-foreground',
|
|
35
|
+
!isCompleted && !isCurrent && !isLocked && 'border-border bg-card'
|
|
36
|
+
)}
|
|
37
|
+
>
|
|
38
|
+
{isCompleted ? (
|
|
39
|
+
<span className="text-lg">✓</span>
|
|
40
|
+
) : isLocked ? (
|
|
41
|
+
<span className="text-lg">🔒</span>
|
|
42
|
+
) : (
|
|
43
|
+
<>
|
|
44
|
+
<span className="text-muted-foreground text-xs">Day</span>
|
|
45
|
+
<span>{day}</span>
|
|
46
|
+
</>
|
|
47
|
+
)}
|
|
48
|
+
</div>
|
|
49
|
+
);
|
|
50
|
+
})}
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|