@contractspec/example.learning-journey-ui-shared 1.56.1 → 1.58.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/.turbo/turbo-build.log +53 -49
- package/.turbo/turbo-prebuild.log +1 -0
- package/CHANGELOG.md +34 -0
- package/dist/browser/components/BadgeDisplay.js +54 -0
- package/dist/browser/components/StreakCounter.js +50 -0
- package/dist/browser/components/ViewTabs.js +46 -0
- package/dist/browser/components/XpBar.js +62 -0
- package/dist/browser/components/index.js +209 -0
- package/dist/browser/docs/index.js +21 -0
- package/dist/browser/docs/learning-journey-ui-shared.docblock.js +21 -0
- package/dist/browser/example.js +32 -0
- package/dist/browser/hooks/index.js +71 -0
- package/dist/browser/hooks/useLearningProgress.js +71 -0
- package/dist/browser/index.js +330 -0
- package/dist/browser/types.js +0 -0
- package/dist/components/BadgeDisplay.d.ts +2 -11
- package/dist/components/BadgeDisplay.d.ts.map +1 -1
- package/dist/components/BadgeDisplay.js +51 -41
- package/dist/components/StreakCounter.d.ts +2 -11
- package/dist/components/StreakCounter.d.ts.map +1 -1
- package/dist/components/StreakCounter.js +48 -43
- package/dist/components/ViewTabs.d.ts +2 -11
- package/dist/components/ViewTabs.d.ts.map +1 -1
- package/dist/components/ViewTabs.js +43 -45
- package/dist/components/XpBar.d.ts +2 -13
- package/dist/components/XpBar.d.ts.map +1 -1
- package/dist/components/XpBar.js +58 -42
- package/dist/components/index.d.ts +5 -5
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +209 -5
- package/dist/docs/index.d.ts +2 -1
- package/dist/docs/index.d.ts.map +1 -0
- package/dist/docs/index.js +22 -1
- package/dist/docs/learning-journey-ui-shared.docblock.d.ts +2 -1
- package/dist/docs/learning-journey-ui-shared.docblock.d.ts.map +1 -0
- package/dist/docs/learning-journey-ui-shared.docblock.js +20 -18
- package/dist/example.d.ts +2 -6
- package/dist/example.d.ts.map +1 -1
- package/dist/example.js +30 -39
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +72 -3
- package/dist/hooks/useLearningProgress.d.ts +15 -19
- package/dist/hooks/useLearningProgress.d.ts.map +1 -1
- package/dist/hooks/useLearningProgress.js +68 -70
- package/dist/index.d.ts +6 -9
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +331 -11
- package/dist/node/components/BadgeDisplay.js +54 -0
- package/dist/node/components/StreakCounter.js +50 -0
- package/dist/node/components/ViewTabs.js +46 -0
- package/dist/node/components/XpBar.js +62 -0
- package/dist/node/components/index.js +209 -0
- package/dist/node/docs/index.js +21 -0
- package/dist/node/docs/learning-journey-ui-shared.docblock.js +21 -0
- package/dist/node/example.js +32 -0
- package/dist/node/hooks/index.js +71 -0
- package/dist/node/hooks/useLearningProgress.js +71 -0
- package/dist/node/index.js +330 -0
- package/dist/node/types.js +0 -0
- package/dist/types.d.ts +38 -42
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -0
- package/package.json +136 -35
- package/tsdown.config.js +1 -2
- package/.turbo/turbo-build$colon$bundle.log +0 -48
- package/dist/components/BadgeDisplay.js.map +0 -1
- package/dist/components/StreakCounter.js.map +0 -1
- package/dist/components/ViewTabs.js.map +0 -1
- package/dist/components/XpBar.js.map +0 -1
- package/dist/docs/learning-journey-ui-shared.docblock.js.map +0 -1
- package/dist/example.js.map +0 -1
- package/dist/hooks/useLearningProgress.js.map +0 -1
- package/tsconfig.tsbuildinfo +0 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,331 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import "
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
// @bun
|
|
2
|
+
// src/components/BadgeDisplay.tsx
|
|
3
|
+
import { cn } from "@contractspec/lib.ui-kit-web/ui/utils";
|
|
4
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
5
|
+
"use client";
|
|
6
|
+
var BADGE_ICONS = {
|
|
7
|
+
studio_first_30m: "\uD83C\uDFAF",
|
|
8
|
+
platform_tour: "\uD83D\uDDFA\uFE0F",
|
|
9
|
+
crm_first_win: "\uD83C\uDFC6",
|
|
10
|
+
drill_master: "\uD83E\uDDE0",
|
|
11
|
+
coach_listener: "\uD83D\uDC42",
|
|
12
|
+
quest_complete: "\u2B50",
|
|
13
|
+
streak_7: "\uD83D\uDD25",
|
|
14
|
+
streak_30: "\uD83D\uDC8E",
|
|
15
|
+
default: "\uD83C\uDFC5"
|
|
16
|
+
};
|
|
17
|
+
var sizeStyles = {
|
|
18
|
+
sm: "h-6 w-6 text-sm",
|
|
19
|
+
md: "h-8 w-8 text-base",
|
|
20
|
+
lg: "h-10 w-10 text-lg"
|
|
21
|
+
};
|
|
22
|
+
function BadgeDisplay({
|
|
23
|
+
badges,
|
|
24
|
+
maxVisible = 5,
|
|
25
|
+
size = "md"
|
|
26
|
+
}) {
|
|
27
|
+
const visibleBadges = badges.slice(0, maxVisible);
|
|
28
|
+
const hiddenCount = badges.length - maxVisible;
|
|
29
|
+
if (badges.length === 0) {
|
|
30
|
+
return /* @__PURE__ */ jsxDEV("div", {
|
|
31
|
+
className: "text-muted-foreground text-sm",
|
|
32
|
+
children: "No badges earned yet"
|
|
33
|
+
}, undefined, false, undefined, this);
|
|
34
|
+
}
|
|
35
|
+
return /* @__PURE__ */ jsxDEV("div", {
|
|
36
|
+
className: "flex items-center gap-1",
|
|
37
|
+
children: [
|
|
38
|
+
visibleBadges.map((badge) => /* @__PURE__ */ jsxDEV("div", {
|
|
39
|
+
className: cn("flex items-center justify-center rounded-full bg-gradient-to-br from-amber-400/20 to-amber-600/20", sizeStyles[size]),
|
|
40
|
+
title: badge.replace(/_/g, " "),
|
|
41
|
+
children: BADGE_ICONS[badge] ?? BADGE_ICONS.default
|
|
42
|
+
}, badge, false, undefined, this)),
|
|
43
|
+
hiddenCount > 0 && /* @__PURE__ */ jsxDEV("div", {
|
|
44
|
+
className: cn("text-muted-foreground bg-muted flex items-center justify-center rounded-full", sizeStyles[size], "text-xs font-medium"),
|
|
45
|
+
children: [
|
|
46
|
+
"+",
|
|
47
|
+
hiddenCount
|
|
48
|
+
]
|
|
49
|
+
}, undefined, true, undefined, this)
|
|
50
|
+
]
|
|
51
|
+
}, undefined, true, undefined, this);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// src/components/StreakCounter.tsx
|
|
55
|
+
import { cn as cn2 } from "@contractspec/lib.ui-kit-web/ui/utils";
|
|
56
|
+
import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
|
|
57
|
+
"use client";
|
|
58
|
+
var sizeStyles2 = {
|
|
59
|
+
sm: {
|
|
60
|
+
container: "gap-1 px-2 py-1",
|
|
61
|
+
icon: "text-base",
|
|
62
|
+
text: "text-xs"
|
|
63
|
+
},
|
|
64
|
+
md: {
|
|
65
|
+
container: "gap-1.5 px-3 py-1.5",
|
|
66
|
+
icon: "text-lg",
|
|
67
|
+
text: "text-sm"
|
|
68
|
+
},
|
|
69
|
+
lg: {
|
|
70
|
+
container: "gap-2 px-4 py-2",
|
|
71
|
+
icon: "text-xl",
|
|
72
|
+
text: "text-base"
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
function StreakCounter({
|
|
76
|
+
days,
|
|
77
|
+
isActive = true,
|
|
78
|
+
size = "md"
|
|
79
|
+
}) {
|
|
80
|
+
const styles = sizeStyles2[size];
|
|
81
|
+
return /* @__PURE__ */ jsxDEV2("div", {
|
|
82
|
+
className: cn2("inline-flex items-center rounded-full font-semibold", styles.container, isActive ? "bg-orange-500/10 text-orange-500" : "bg-muted text-muted-foreground"),
|
|
83
|
+
children: [
|
|
84
|
+
/* @__PURE__ */ jsxDEV2("span", {
|
|
85
|
+
className: styles.icon,
|
|
86
|
+
role: "img",
|
|
87
|
+
"aria-label": "streak",
|
|
88
|
+
children: "\uD83D\uDD25"
|
|
89
|
+
}, undefined, false, undefined, this),
|
|
90
|
+
/* @__PURE__ */ jsxDEV2("span", {
|
|
91
|
+
className: styles.text,
|
|
92
|
+
children: [
|
|
93
|
+
days,
|
|
94
|
+
" ",
|
|
95
|
+
days === 1 ? "day" : "days"
|
|
96
|
+
]
|
|
97
|
+
}, undefined, true, undefined, this)
|
|
98
|
+
]
|
|
99
|
+
}, undefined, true, undefined, this);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// src/components/ViewTabs.tsx
|
|
103
|
+
import { Button } from "@contractspec/lib.design-system";
|
|
104
|
+
import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
|
|
105
|
+
"use client";
|
|
106
|
+
var VIEW_LABELS = {
|
|
107
|
+
overview: { label: "Overview", icon: "\uD83D\uDCCA" },
|
|
108
|
+
steps: { label: "Steps", icon: "\uD83D\uDCDD" },
|
|
109
|
+
progress: { label: "Progress", icon: "\uD83D\uDCC8" },
|
|
110
|
+
timeline: { label: "Timeline", icon: "\uD83D\uDCC5" }
|
|
111
|
+
};
|
|
112
|
+
var DEFAULT_VIEWS = [
|
|
113
|
+
"overview",
|
|
114
|
+
"steps",
|
|
115
|
+
"progress",
|
|
116
|
+
"timeline"
|
|
117
|
+
];
|
|
118
|
+
function ViewTabs({
|
|
119
|
+
currentView,
|
|
120
|
+
onViewChange,
|
|
121
|
+
availableViews = DEFAULT_VIEWS
|
|
122
|
+
}) {
|
|
123
|
+
return /* @__PURE__ */ jsxDEV3("div", {
|
|
124
|
+
className: "flex flex-wrap gap-2",
|
|
125
|
+
children: availableViews.map((view) => {
|
|
126
|
+
const { label, icon } = VIEW_LABELS[view];
|
|
127
|
+
const isActive = currentView === view;
|
|
128
|
+
return /* @__PURE__ */ jsxDEV3(Button, {
|
|
129
|
+
variant: isActive ? "default" : "outline",
|
|
130
|
+
size: "sm",
|
|
131
|
+
onClick: () => onViewChange(view),
|
|
132
|
+
className: "gap-1.5",
|
|
133
|
+
children: [
|
|
134
|
+
/* @__PURE__ */ jsxDEV3("span", {
|
|
135
|
+
children: icon
|
|
136
|
+
}, undefined, false, undefined, this),
|
|
137
|
+
/* @__PURE__ */ jsxDEV3("span", {
|
|
138
|
+
children: label
|
|
139
|
+
}, undefined, false, undefined, this)
|
|
140
|
+
]
|
|
141
|
+
}, view, true, undefined, this);
|
|
142
|
+
})
|
|
143
|
+
}, undefined, false, undefined, this);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// src/components/XpBar.tsx
|
|
147
|
+
import { Progress } from "@contractspec/lib.ui-kit-web/ui/progress";
|
|
148
|
+
import { cn as cn3 } from "@contractspec/lib.ui-kit-web/ui/utils";
|
|
149
|
+
import { jsxDEV as jsxDEV4 } from "react/jsx-dev-runtime";
|
|
150
|
+
"use client";
|
|
151
|
+
var sizeStyles3 = {
|
|
152
|
+
sm: "h-2",
|
|
153
|
+
md: "h-3",
|
|
154
|
+
lg: "h-4"
|
|
155
|
+
};
|
|
156
|
+
var labelSizeStyles = {
|
|
157
|
+
sm: "text-xs",
|
|
158
|
+
md: "text-sm",
|
|
159
|
+
lg: "text-base"
|
|
160
|
+
};
|
|
161
|
+
function XpBar({
|
|
162
|
+
current,
|
|
163
|
+
max,
|
|
164
|
+
level,
|
|
165
|
+
showLabel = true,
|
|
166
|
+
size = "md"
|
|
167
|
+
}) {
|
|
168
|
+
const percentage = max > 0 ? Math.min(current / max * 100, 100) : 0;
|
|
169
|
+
return /* @__PURE__ */ jsxDEV4("div", {
|
|
170
|
+
className: "w-full space-y-1",
|
|
171
|
+
children: [
|
|
172
|
+
showLabel && /* @__PURE__ */ jsxDEV4("div", {
|
|
173
|
+
className: cn3("flex items-center justify-between", labelSizeStyles[size]),
|
|
174
|
+
children: [
|
|
175
|
+
/* @__PURE__ */ jsxDEV4("span", {
|
|
176
|
+
className: "text-muted-foreground font-medium",
|
|
177
|
+
children: [
|
|
178
|
+
level !== undefined && /* @__PURE__ */ jsxDEV4("span", {
|
|
179
|
+
className: "text-primary mr-1",
|
|
180
|
+
children: [
|
|
181
|
+
"Lvl ",
|
|
182
|
+
level
|
|
183
|
+
]
|
|
184
|
+
}, undefined, true, undefined, this),
|
|
185
|
+
"XP"
|
|
186
|
+
]
|
|
187
|
+
}, undefined, true, undefined, this),
|
|
188
|
+
/* @__PURE__ */ jsxDEV4("span", {
|
|
189
|
+
className: "font-semibold",
|
|
190
|
+
children: [
|
|
191
|
+
current.toLocaleString(),
|
|
192
|
+
" / ",
|
|
193
|
+
max.toLocaleString()
|
|
194
|
+
]
|
|
195
|
+
}, undefined, true, undefined, this)
|
|
196
|
+
]
|
|
197
|
+
}, undefined, true, undefined, this),
|
|
198
|
+
/* @__PURE__ */ jsxDEV4(Progress, {
|
|
199
|
+
value: percentage,
|
|
200
|
+
className: cn3("bg-muted", sizeStyles3[size])
|
|
201
|
+
}, undefined, false, undefined, this)
|
|
202
|
+
]
|
|
203
|
+
}, undefined, true, undefined, this);
|
|
204
|
+
}
|
|
205
|
+
// src/docs/learning-journey-ui-shared.docblock.ts
|
|
206
|
+
import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
|
|
207
|
+
var blocks = [
|
|
208
|
+
{
|
|
209
|
+
id: "docs.examples.learning-journey-ui-shared",
|
|
210
|
+
title: "Learning Journey UI \u2014 Shared",
|
|
211
|
+
summary: "Shared UI components and hooks for learning journey mini-apps.",
|
|
212
|
+
kind: "reference",
|
|
213
|
+
visibility: "public",
|
|
214
|
+
route: "/docs/examples/learning-journey-ui-shared",
|
|
215
|
+
tags: ["learning", "ui", "shared"],
|
|
216
|
+
body: `## Includes
|
|
217
|
+
- Hooks: useLearningProgress
|
|
218
|
+
- Components: XpBar, StreakCounter, BadgeDisplay, ViewTabs
|
|
219
|
+
|
|
220
|
+
## Notes
|
|
221
|
+
- Keep components accessible (labels, focus, contrast).
|
|
222
|
+
- Prefer design-system tokens and components.`
|
|
223
|
+
}
|
|
224
|
+
];
|
|
225
|
+
registerDocBlocks(blocks);
|
|
226
|
+
// src/example.ts
|
|
227
|
+
import { defineExample } from "@contractspec/lib.contracts";
|
|
228
|
+
var example = defineExample({
|
|
229
|
+
meta: {
|
|
230
|
+
key: "learning-journey-ui-shared",
|
|
231
|
+
version: "1.0.0",
|
|
232
|
+
title: "Learning Journey UI \u2014 Shared",
|
|
233
|
+
description: "Shared UI components and hooks for learning journey mini-apps.",
|
|
234
|
+
kind: "ui",
|
|
235
|
+
visibility: "public",
|
|
236
|
+
stability: "experimental",
|
|
237
|
+
owners: ["@platform.core"],
|
|
238
|
+
tags: ["learning", "ui", "shared"]
|
|
239
|
+
},
|
|
240
|
+
docs: {
|
|
241
|
+
rootDocId: "docs.examples.learning-journey-ui-shared"
|
|
242
|
+
},
|
|
243
|
+
entrypoints: {
|
|
244
|
+
packageName: "@contractspec/example.learning-journey-ui-shared",
|
|
245
|
+
docs: "./docs"
|
|
246
|
+
},
|
|
247
|
+
surfaces: {
|
|
248
|
+
templates: true,
|
|
249
|
+
sandbox: { enabled: true, modes: ["playground", "markdown"] },
|
|
250
|
+
studio: { enabled: true, installable: true },
|
|
251
|
+
mcp: { enabled: true }
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
var example_default = example;
|
|
255
|
+
|
|
256
|
+
// src/hooks/useLearningProgress.ts
|
|
257
|
+
import { useState, useCallback, useMemo } from "react";
|
|
258
|
+
"use client";
|
|
259
|
+
function createDefaultProgress(trackId) {
|
|
260
|
+
return {
|
|
261
|
+
trackId,
|
|
262
|
+
completedStepIds: [],
|
|
263
|
+
currentStepId: null,
|
|
264
|
+
xpEarned: 0,
|
|
265
|
+
streakDays: 0,
|
|
266
|
+
lastActivityDate: null,
|
|
267
|
+
badges: []
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
function useLearningProgress(track) {
|
|
271
|
+
const [progress, setProgress] = useState(() => createDefaultProgress(track.id));
|
|
272
|
+
const completeStep = useCallback((stepId) => {
|
|
273
|
+
const step = track.steps.find((s) => s.id === stepId);
|
|
274
|
+
if (!step || progress.completedStepIds.includes(stepId))
|
|
275
|
+
return;
|
|
276
|
+
setProgress((prev) => {
|
|
277
|
+
const newCompletedIds = [...prev.completedStepIds, stepId];
|
|
278
|
+
const xpReward = step.xpReward ?? 0;
|
|
279
|
+
const nextStep = track.steps.find((s) => !newCompletedIds.includes(s.id));
|
|
280
|
+
const isTrackComplete = newCompletedIds.length === track.steps.length;
|
|
281
|
+
const completionBonus = isTrackComplete ? track.completionRewards?.xpBonus ?? 0 : 0;
|
|
282
|
+
return {
|
|
283
|
+
...prev,
|
|
284
|
+
completedStepIds: newCompletedIds,
|
|
285
|
+
currentStepId: nextStep?.id ?? null,
|
|
286
|
+
xpEarned: prev.xpEarned + xpReward + completionBonus,
|
|
287
|
+
lastActivityDate: new Date().toISOString(),
|
|
288
|
+
badges: isTrackComplete && track.completionRewards?.badgeKey ? [...prev.badges, track.completionRewards.badgeKey] : prev.badges
|
|
289
|
+
};
|
|
290
|
+
});
|
|
291
|
+
}, [track, progress.completedStepIds]);
|
|
292
|
+
const resetProgress = useCallback(() => {
|
|
293
|
+
setProgress(createDefaultProgress(track.id));
|
|
294
|
+
}, [track.id]);
|
|
295
|
+
const incrementStreak = useCallback(() => {
|
|
296
|
+
setProgress((prev) => ({
|
|
297
|
+
...prev,
|
|
298
|
+
streakDays: prev.streakDays + 1,
|
|
299
|
+
lastActivityDate: new Date().toISOString()
|
|
300
|
+
}));
|
|
301
|
+
}, []);
|
|
302
|
+
const stats = useMemo(() => {
|
|
303
|
+
const totalSteps = track.steps.length;
|
|
304
|
+
const completedSteps = progress.completedStepIds.length;
|
|
305
|
+
const percentComplete = totalSteps > 0 ? Math.round(completedSteps / totalSteps * 100) : 0;
|
|
306
|
+
const totalXp = track.totalXp ?? track.steps.reduce((sum, s) => sum + (s.xpReward ?? 0), 0) + (track.completionRewards?.xpBonus ?? 0);
|
|
307
|
+
return {
|
|
308
|
+
totalSteps,
|
|
309
|
+
completedSteps,
|
|
310
|
+
remainingSteps: totalSteps - completedSteps,
|
|
311
|
+
percentComplete,
|
|
312
|
+
totalXp,
|
|
313
|
+
isComplete: completedSteps === totalSteps
|
|
314
|
+
};
|
|
315
|
+
}, [track, progress.completedStepIds]);
|
|
316
|
+
return {
|
|
317
|
+
progress,
|
|
318
|
+
stats,
|
|
319
|
+
completeStep,
|
|
320
|
+
resetProgress,
|
|
321
|
+
incrementStreak
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
export {
|
|
325
|
+
useLearningProgress,
|
|
326
|
+
example_default as example,
|
|
327
|
+
XpBar,
|
|
328
|
+
ViewTabs,
|
|
329
|
+
StreakCounter,
|
|
330
|
+
BadgeDisplay
|
|
331
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// src/components/BadgeDisplay.tsx
|
|
2
|
+
import { cn } from "@contractspec/lib.ui-kit-web/ui/utils";
|
|
3
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
4
|
+
"use client";
|
|
5
|
+
var BADGE_ICONS = {
|
|
6
|
+
studio_first_30m: "\uD83C\uDFAF",
|
|
7
|
+
platform_tour: "\uD83D\uDDFA️",
|
|
8
|
+
crm_first_win: "\uD83C\uDFC6",
|
|
9
|
+
drill_master: "\uD83E\uDDE0",
|
|
10
|
+
coach_listener: "\uD83D\uDC42",
|
|
11
|
+
quest_complete: "⭐",
|
|
12
|
+
streak_7: "\uD83D\uDD25",
|
|
13
|
+
streak_30: "\uD83D\uDC8E",
|
|
14
|
+
default: "\uD83C\uDFC5"
|
|
15
|
+
};
|
|
16
|
+
var sizeStyles = {
|
|
17
|
+
sm: "h-6 w-6 text-sm",
|
|
18
|
+
md: "h-8 w-8 text-base",
|
|
19
|
+
lg: "h-10 w-10 text-lg"
|
|
20
|
+
};
|
|
21
|
+
function BadgeDisplay({
|
|
22
|
+
badges,
|
|
23
|
+
maxVisible = 5,
|
|
24
|
+
size = "md"
|
|
25
|
+
}) {
|
|
26
|
+
const visibleBadges = badges.slice(0, maxVisible);
|
|
27
|
+
const hiddenCount = badges.length - maxVisible;
|
|
28
|
+
if (badges.length === 0) {
|
|
29
|
+
return /* @__PURE__ */ jsxDEV("div", {
|
|
30
|
+
className: "text-muted-foreground text-sm",
|
|
31
|
+
children: "No badges earned yet"
|
|
32
|
+
}, undefined, false, undefined, this);
|
|
33
|
+
}
|
|
34
|
+
return /* @__PURE__ */ jsxDEV("div", {
|
|
35
|
+
className: "flex items-center gap-1",
|
|
36
|
+
children: [
|
|
37
|
+
visibleBadges.map((badge) => /* @__PURE__ */ jsxDEV("div", {
|
|
38
|
+
className: cn("flex items-center justify-center rounded-full bg-gradient-to-br from-amber-400/20 to-amber-600/20", sizeStyles[size]),
|
|
39
|
+
title: badge.replace(/_/g, " "),
|
|
40
|
+
children: BADGE_ICONS[badge] ?? BADGE_ICONS.default
|
|
41
|
+
}, badge, false, undefined, this)),
|
|
42
|
+
hiddenCount > 0 && /* @__PURE__ */ jsxDEV("div", {
|
|
43
|
+
className: cn("text-muted-foreground bg-muted flex items-center justify-center rounded-full", sizeStyles[size], "text-xs font-medium"),
|
|
44
|
+
children: [
|
|
45
|
+
"+",
|
|
46
|
+
hiddenCount
|
|
47
|
+
]
|
|
48
|
+
}, undefined, true, undefined, this)
|
|
49
|
+
]
|
|
50
|
+
}, undefined, true, undefined, this);
|
|
51
|
+
}
|
|
52
|
+
export {
|
|
53
|
+
BadgeDisplay
|
|
54
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// src/components/StreakCounter.tsx
|
|
2
|
+
import { cn } from "@contractspec/lib.ui-kit-web/ui/utils";
|
|
3
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
4
|
+
"use client";
|
|
5
|
+
var sizeStyles = {
|
|
6
|
+
sm: {
|
|
7
|
+
container: "gap-1 px-2 py-1",
|
|
8
|
+
icon: "text-base",
|
|
9
|
+
text: "text-xs"
|
|
10
|
+
},
|
|
11
|
+
md: {
|
|
12
|
+
container: "gap-1.5 px-3 py-1.5",
|
|
13
|
+
icon: "text-lg",
|
|
14
|
+
text: "text-sm"
|
|
15
|
+
},
|
|
16
|
+
lg: {
|
|
17
|
+
container: "gap-2 px-4 py-2",
|
|
18
|
+
icon: "text-xl",
|
|
19
|
+
text: "text-base"
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
function StreakCounter({
|
|
23
|
+
days,
|
|
24
|
+
isActive = true,
|
|
25
|
+
size = "md"
|
|
26
|
+
}) {
|
|
27
|
+
const styles = sizeStyles[size];
|
|
28
|
+
return /* @__PURE__ */ jsxDEV("div", {
|
|
29
|
+
className: cn("inline-flex items-center rounded-full font-semibold", styles.container, isActive ? "bg-orange-500/10 text-orange-500" : "bg-muted text-muted-foreground"),
|
|
30
|
+
children: [
|
|
31
|
+
/* @__PURE__ */ jsxDEV("span", {
|
|
32
|
+
className: styles.icon,
|
|
33
|
+
role: "img",
|
|
34
|
+
"aria-label": "streak",
|
|
35
|
+
children: "\uD83D\uDD25"
|
|
36
|
+
}, undefined, false, undefined, this),
|
|
37
|
+
/* @__PURE__ */ jsxDEV("span", {
|
|
38
|
+
className: styles.text,
|
|
39
|
+
children: [
|
|
40
|
+
days,
|
|
41
|
+
" ",
|
|
42
|
+
days === 1 ? "day" : "days"
|
|
43
|
+
]
|
|
44
|
+
}, undefined, true, undefined, this)
|
|
45
|
+
]
|
|
46
|
+
}, undefined, true, undefined, this);
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
StreakCounter
|
|
50
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// src/components/ViewTabs.tsx
|
|
2
|
+
import { Button } from "@contractspec/lib.design-system";
|
|
3
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
4
|
+
"use client";
|
|
5
|
+
var VIEW_LABELS = {
|
|
6
|
+
overview: { label: "Overview", icon: "\uD83D\uDCCA" },
|
|
7
|
+
steps: { label: "Steps", icon: "\uD83D\uDCDD" },
|
|
8
|
+
progress: { label: "Progress", icon: "\uD83D\uDCC8" },
|
|
9
|
+
timeline: { label: "Timeline", icon: "\uD83D\uDCC5" }
|
|
10
|
+
};
|
|
11
|
+
var DEFAULT_VIEWS = [
|
|
12
|
+
"overview",
|
|
13
|
+
"steps",
|
|
14
|
+
"progress",
|
|
15
|
+
"timeline"
|
|
16
|
+
];
|
|
17
|
+
function ViewTabs({
|
|
18
|
+
currentView,
|
|
19
|
+
onViewChange,
|
|
20
|
+
availableViews = DEFAULT_VIEWS
|
|
21
|
+
}) {
|
|
22
|
+
return /* @__PURE__ */ jsxDEV("div", {
|
|
23
|
+
className: "flex flex-wrap gap-2",
|
|
24
|
+
children: availableViews.map((view) => {
|
|
25
|
+
const { label, icon } = VIEW_LABELS[view];
|
|
26
|
+
const isActive = currentView === view;
|
|
27
|
+
return /* @__PURE__ */ jsxDEV(Button, {
|
|
28
|
+
variant: isActive ? "default" : "outline",
|
|
29
|
+
size: "sm",
|
|
30
|
+
onClick: () => onViewChange(view),
|
|
31
|
+
className: "gap-1.5",
|
|
32
|
+
children: [
|
|
33
|
+
/* @__PURE__ */ jsxDEV("span", {
|
|
34
|
+
children: icon
|
|
35
|
+
}, undefined, false, undefined, this),
|
|
36
|
+
/* @__PURE__ */ jsxDEV("span", {
|
|
37
|
+
children: label
|
|
38
|
+
}, undefined, false, undefined, this)
|
|
39
|
+
]
|
|
40
|
+
}, view, true, undefined, this);
|
|
41
|
+
})
|
|
42
|
+
}, undefined, false, undefined, this);
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
ViewTabs
|
|
46
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// src/components/XpBar.tsx
|
|
2
|
+
import { Progress } from "@contractspec/lib.ui-kit-web/ui/progress";
|
|
3
|
+
import { cn } from "@contractspec/lib.ui-kit-web/ui/utils";
|
|
4
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
5
|
+
"use client";
|
|
6
|
+
var sizeStyles = {
|
|
7
|
+
sm: "h-2",
|
|
8
|
+
md: "h-3",
|
|
9
|
+
lg: "h-4"
|
|
10
|
+
};
|
|
11
|
+
var labelSizeStyles = {
|
|
12
|
+
sm: "text-xs",
|
|
13
|
+
md: "text-sm",
|
|
14
|
+
lg: "text-base"
|
|
15
|
+
};
|
|
16
|
+
function XpBar({
|
|
17
|
+
current,
|
|
18
|
+
max,
|
|
19
|
+
level,
|
|
20
|
+
showLabel = true,
|
|
21
|
+
size = "md"
|
|
22
|
+
}) {
|
|
23
|
+
const percentage = max > 0 ? Math.min(current / max * 100, 100) : 0;
|
|
24
|
+
return /* @__PURE__ */ jsxDEV("div", {
|
|
25
|
+
className: "w-full space-y-1",
|
|
26
|
+
children: [
|
|
27
|
+
showLabel && /* @__PURE__ */ jsxDEV("div", {
|
|
28
|
+
className: cn("flex items-center justify-between", labelSizeStyles[size]),
|
|
29
|
+
children: [
|
|
30
|
+
/* @__PURE__ */ jsxDEV("span", {
|
|
31
|
+
className: "text-muted-foreground font-medium",
|
|
32
|
+
children: [
|
|
33
|
+
level !== undefined && /* @__PURE__ */ jsxDEV("span", {
|
|
34
|
+
className: "text-primary mr-1",
|
|
35
|
+
children: [
|
|
36
|
+
"Lvl ",
|
|
37
|
+
level
|
|
38
|
+
]
|
|
39
|
+
}, undefined, true, undefined, this),
|
|
40
|
+
"XP"
|
|
41
|
+
]
|
|
42
|
+
}, undefined, true, undefined, this),
|
|
43
|
+
/* @__PURE__ */ jsxDEV("span", {
|
|
44
|
+
className: "font-semibold",
|
|
45
|
+
children: [
|
|
46
|
+
current.toLocaleString(),
|
|
47
|
+
" / ",
|
|
48
|
+
max.toLocaleString()
|
|
49
|
+
]
|
|
50
|
+
}, undefined, true, undefined, this)
|
|
51
|
+
]
|
|
52
|
+
}, undefined, true, undefined, this),
|
|
53
|
+
/* @__PURE__ */ jsxDEV(Progress, {
|
|
54
|
+
value: percentage,
|
|
55
|
+
className: cn("bg-muted", sizeStyles[size])
|
|
56
|
+
}, undefined, false, undefined, this)
|
|
57
|
+
]
|
|
58
|
+
}, undefined, true, undefined, this);
|
|
59
|
+
}
|
|
60
|
+
export {
|
|
61
|
+
XpBar
|
|
62
|
+
};
|