@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.
@@ -0,0 +1,198 @@
1
+ 'use client';
2
+
3
+ import {
4
+ Card,
5
+ CardContent,
6
+ CardHeader,
7
+ CardTitle,
8
+ } from '@lssm/lib.ui-kit-web/ui/card';
9
+ import { DayCalendar } from '../components/DayCalendar';
10
+ import type { LearningViewProps } from '@lssm/example.learning-journey-ui-shared';
11
+
12
+ export function Timeline({ track, progress }: LearningViewProps) {
13
+ // Check if this is a quest with day unlocks
14
+ const hasQuestDays = track.steps.some(
15
+ (s) => s.availability?.unlockOnDay !== undefined
16
+ );
17
+
18
+ if (hasQuestDays) {
19
+ // Quest-style calendar view
20
+ const totalDays = Math.max(
21
+ ...track.steps.map((s) => s.availability?.unlockOnDay ?? 1),
22
+ 7
23
+ );
24
+
25
+ const completedDays = track.steps
26
+ .filter((s) => progress.completedStepIds.includes(s.id))
27
+ .map((s) => s.availability?.unlockOnDay ?? 1);
28
+
29
+ // Current day is the first incomplete day
30
+ const currentDay =
31
+ track.steps.find((s) => !progress.completedStepIds.includes(s.id))
32
+ ?.availability?.unlockOnDay ?? 1;
33
+
34
+ return (
35
+ <div className="space-y-6">
36
+ {/* Header */}
37
+ <div className="text-center">
38
+ <h2 className="text-xl font-bold">{track.name}</h2>
39
+ <p className="text-muted-foreground">
40
+ Complete each day's challenge to progress
41
+ </p>
42
+ </div>
43
+
44
+ {/* Calendar Grid */}
45
+ <Card>
46
+ <CardHeader>
47
+ <CardTitle className="flex items-center gap-2">
48
+ <span>📅</span>
49
+ <span>Your Journey</span>
50
+ </CardTitle>
51
+ </CardHeader>
52
+ <CardContent className="flex justify-center">
53
+ <DayCalendar
54
+ totalDays={totalDays}
55
+ currentDay={currentDay}
56
+ completedDays={completedDays}
57
+ />
58
+ </CardContent>
59
+ </Card>
60
+
61
+ {/* Daily Steps */}
62
+ <Card>
63
+ <CardHeader>
64
+ <CardTitle className="flex items-center gap-2">
65
+ <span>📝</span>
66
+ <span>Daily Challenges</span>
67
+ </CardTitle>
68
+ </CardHeader>
69
+ <CardContent>
70
+ <div className="space-y-3">
71
+ {track.steps.map((step) => {
72
+ const day = step.availability?.unlockOnDay ?? 1;
73
+ const isCompleted = progress.completedStepIds.includes(step.id);
74
+ const isLocked = day > currentDay;
75
+
76
+ return (
77
+ <div
78
+ key={step.id}
79
+ className={`flex items-start gap-4 rounded-lg border p-4 ${
80
+ isLocked ? 'opacity-50' : ''
81
+ }`}
82
+ >
83
+ <div className="bg-muted flex h-10 w-10 shrink-0 items-center justify-center rounded-lg font-semibold">
84
+ {isCompleted ? '✓' : isLocked ? '🔒' : day}
85
+ </div>
86
+ <div className="flex-1">
87
+ <h4 className="font-semibold">{step.title}</h4>
88
+ <p className="text-muted-foreground text-sm">
89
+ {step.description}
90
+ </p>
91
+ </div>
92
+ {step.xpReward && (
93
+ <span
94
+ className={`text-sm font-medium ${
95
+ isCompleted
96
+ ? 'text-green-500'
97
+ : 'text-muted-foreground'
98
+ }`}
99
+ >
100
+ +{step.xpReward} XP
101
+ </span>
102
+ )}
103
+ </div>
104
+ );
105
+ })}
106
+ </div>
107
+ </CardContent>
108
+ </Card>
109
+ </div>
110
+ );
111
+ }
112
+
113
+ // Drill-style timeline (step order)
114
+ return (
115
+ <div className="space-y-6">
116
+ {/* Header */}
117
+ <div className="text-center">
118
+ <h2 className="text-xl font-bold">Learning Path</h2>
119
+ <p className="text-muted-foreground">
120
+ Follow the steps to master this skill
121
+ </p>
122
+ </div>
123
+
124
+ {/* Timeline */}
125
+ <Card>
126
+ <CardContent className="p-6">
127
+ <div className="relative">
128
+ {/* Vertical line */}
129
+ <div className="bg-border absolute top-0 left-5 h-full w-0.5" />
130
+
131
+ {/* Steps */}
132
+ <div className="space-y-6">
133
+ {track.steps.map((step, index) => {
134
+ const isCompleted = progress.completedStepIds.includes(step.id);
135
+ const isCurrent =
136
+ !isCompleted &&
137
+ track.steps
138
+ .slice(0, index)
139
+ .every((s) => progress.completedStepIds.includes(s.id));
140
+
141
+ return (
142
+ <div key={step.id} className="relative flex gap-4 pl-2">
143
+ {/* Node */}
144
+ <div
145
+ className={`relative z-10 flex h-8 w-8 shrink-0 items-center justify-center rounded-full border-2 ${
146
+ isCompleted
147
+ ? 'border-green-500 bg-green-500 text-white'
148
+ : isCurrent
149
+ ? 'border-violet-500 bg-violet-500 text-white'
150
+ : 'border-border bg-background'
151
+ }`}
152
+ >
153
+ {isCompleted ? '✓' : index + 1}
154
+ </div>
155
+
156
+ {/* Content */}
157
+ <div className="flex-1 pb-4">
158
+ <div className="flex items-start justify-between gap-2">
159
+ <div>
160
+ <h4
161
+ className={`font-semibold ${
162
+ isCompleted
163
+ ? 'text-foreground'
164
+ : isCurrent
165
+ ? 'text-violet-500'
166
+ : 'text-muted-foreground'
167
+ }`}
168
+ >
169
+ {step.title}
170
+ </h4>
171
+ <p className="text-muted-foreground mt-1 text-sm">
172
+ {step.description}
173
+ </p>
174
+ </div>
175
+ {step.xpReward && (
176
+ <span
177
+ className={`shrink-0 rounded-full px-2 py-1 text-xs font-semibold ${
178
+ isCompleted
179
+ ? 'bg-green-500/10 text-green-500'
180
+ : 'bg-muted text-muted-foreground'
181
+ }`}
182
+ >
183
+ +{step.xpReward} XP
184
+ </span>
185
+ )}
186
+ </div>
187
+ </div>
188
+ </div>
189
+ );
190
+ })}
191
+ </div>
192
+ </div>
193
+ </CardContent>
194
+ </Card>
195
+ </div>
196
+ );
197
+ }
198
+
@@ -0,0 +1,5 @@
1
+ export { Overview } from './Overview';
2
+ export { Steps } from './Steps';
3
+ export { Progress } from './Progress';
4
+ export { Timeline } from './Timeline';
5
+
package/tsconfig.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "@lssm/tool.typescript/react-library.json",
3
+ "include": ["src"],
4
+ "exclude": ["node_modules"],
5
+ "compilerOptions": {
6
+ "rootDir": "src",
7
+ "outDir": "dist"
8
+ }
9
+ }
10
+