@lssm/example.learning-journey-ui-shared 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 +24 -0
- package/CHANGELOG.md +10 -0
- package/README.md +39 -0
- package/dist/components/index.d.mts +2 -0
- package/dist/components/index.mjs +3 -0
- package/dist/components-tyJAN4Ru.mjs +164 -0
- package/dist/hooks/index.d.mts +2 -0
- package/dist/hooks/index.mjs +3 -0
- package/dist/hooks-B-tDvppY.mjs +71 -0
- package/dist/index-D_7WU_xm.d.mts +21 -0
- package/dist/index-EWErSKip.d.mts +34 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.mjs +4 -0
- package/dist/types-BMAby_Ku.d.mts +57 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +1 -0
- package/package.json +52 -0
- package/src/components/BadgeDisplay.tsx +66 -0
- package/src/components/StreakCounter.tsx +50 -0
- package/src/components/ViewTabs.tsx +47 -0
- package/src/components/XpBar.tsx +55 -0
- package/src/components/index.ts +5 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useLearningProgress.ts +102 -0
- package/src/index.ts +18 -0
- package/src/types.ts +62 -0
- package/tsconfig.json +10 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/tsdown.config.js +14 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
$ bun build:bundle && bun build:types
|
|
2
|
+
$ tsdown
|
|
3
|
+
[34mℹ[39m tsdown [2mv0.17.0[22m powered by rolldown [2mv1.0.0-beta.53[22m
|
|
4
|
+
[34mℹ[39m config file: [4m/home/runner/work/contractspec/contractspec/packages/examples/learning-journey-ui-shared/tsdown.config.js[24m
|
|
5
|
+
[34mℹ[39m entry: [34msrc/index.ts, src/hooks/index.ts, src/components/index.ts, src/types.ts[39m
|
|
6
|
+
[34mℹ[39m target: [34mesnext[39m
|
|
7
|
+
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
8
|
+
[34mℹ[39m Build start
|
|
9
|
+
[34mℹ[39m [2mdist/[22m[1mindex.mjs[22m [2m0.25 kB[22m [2m│ gzip: 0.17 kB[22m
|
|
10
|
+
[34mℹ[39m [2mdist/[22m[1mcomponents/index.mjs[22m [2m0.17 kB[22m [2m│ gzip: 0.14 kB[22m
|
|
11
|
+
[34mℹ[39m [2mdist/[22m[1mhooks/index.mjs[22m [2m0.10 kB[22m [2m│ gzip: 0.09 kB[22m
|
|
12
|
+
[34mℹ[39m [2mdist/[22m[1mtypes.mjs[22m [2m0.01 kB[22m [2m│ gzip: 0.03 kB[22m
|
|
13
|
+
[34mℹ[39m [2mdist/[22mcomponents-tyJAN4Ru.mjs [2m4.53 kB[22m [2m│ gzip: 1.63 kB[22m
|
|
14
|
+
[34mℹ[39m [2mdist/[22mhooks-B-tDvppY.mjs [2m2.48 kB[22m [2m│ gzip: 0.87 kB[22m
|
|
15
|
+
[34mℹ[39m [2mdist/[22m[32m[1mindex.d.mts[22m[39m [2m0.65 kB[22m [2m│ gzip: 0.26 kB[22m
|
|
16
|
+
[34mℹ[39m [2mdist/[22m[32m[1mtypes.d.mts[22m[39m [2m0.38 kB[22m [2m│ gzip: 0.19 kB[22m
|
|
17
|
+
[34mℹ[39m [2mdist/[22m[32m[1mcomponents/index.d.mts[22m[39m [2m0.16 kB[22m [2m│ gzip: 0.14 kB[22m
|
|
18
|
+
[34mℹ[39m [2mdist/[22m[32m[1mhooks/index.d.mts[22m[39m [2m0.10 kB[22m [2m│ gzip: 0.09 kB[22m
|
|
19
|
+
[34mℹ[39m [2mdist/[22m[32mtypes-BMAby_Ku.d.mts[39m [2m1.70 kB[22m [2m│ gzip: 0.60 kB[22m
|
|
20
|
+
[34mℹ[39m [2mdist/[22m[32mindex-EWErSKip.d.mts[39m [2m0.95 kB[22m [2m│ gzip: 0.37 kB[22m
|
|
21
|
+
[34mℹ[39m [2mdist/[22m[32mindex-D_7WU_xm.d.mts[39m [2m0.68 kB[22m [2m│ gzip: 0.35 kB[22m
|
|
22
|
+
[34mℹ[39m 13 files, total: 12.16 kB
|
|
23
|
+
[32m✔[39m Build complete in [32m8784ms[39m
|
|
24
|
+
$ tsc --noEmit
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# @lssm/example.learning-journey-ui-shared
|
|
2
|
+
|
|
3
|
+
## 0.0.0-canary-20251212210835
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [3086383]
|
|
8
|
+
- @lssm/lib.design-system@0.0.0-canary-20251212210835
|
|
9
|
+
- @lssm/lib.ui-kit-web@0.0.0-canary-20251212210835
|
|
10
|
+
- @lssm/module.learning-journey@0.0.0-canary-20251212210835
|
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# @lssm/example.learning-journey-ui-shared
|
|
2
|
+
|
|
3
|
+
Shared UI components and hooks for learning journey mini-apps.
|
|
4
|
+
|
|
5
|
+
## Components
|
|
6
|
+
|
|
7
|
+
- **XpBar** - Progress bar showing XP earned vs total
|
|
8
|
+
- **StreakCounter** - Display streak days with fire icon
|
|
9
|
+
- **BadgeDisplay** - Grid of earned badges
|
|
10
|
+
- **ViewTabs** - Tab navigation between views
|
|
11
|
+
|
|
12
|
+
## Hooks
|
|
13
|
+
|
|
14
|
+
- **useLearningProgress** - Manage learning progress state for a track
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
import {
|
|
20
|
+
XpBar,
|
|
21
|
+
StreakCounter,
|
|
22
|
+
BadgeDisplay,
|
|
23
|
+
ViewTabs,
|
|
24
|
+
useLearningProgress,
|
|
25
|
+
} from '@lssm/example.learning-journey-ui-shared';
|
|
26
|
+
|
|
27
|
+
function MyLearningApp({ track }) {
|
|
28
|
+
const { progress, stats, completeStep } = useLearningProgress(track);
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<div>
|
|
32
|
+
<XpBar current={progress.xpEarned} max={stats.totalXp} />
|
|
33
|
+
<StreakCounter days={progress.streakDays} />
|
|
34
|
+
<BadgeDisplay badges={progress.badges} />
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { Progress } from "@lssm/lib.ui-kit-web/ui/progress";
|
|
2
|
+
import { cn } from "@lssm/lib.ui-kit-web/ui/utils";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { Button } from "@lssm/lib.design-system";
|
|
5
|
+
|
|
6
|
+
//#region src/components/XpBar.tsx
|
|
7
|
+
const sizeStyles$2 = {
|
|
8
|
+
sm: "h-2",
|
|
9
|
+
md: "h-3",
|
|
10
|
+
lg: "h-4"
|
|
11
|
+
};
|
|
12
|
+
const labelSizeStyles = {
|
|
13
|
+
sm: "text-xs",
|
|
14
|
+
md: "text-sm",
|
|
15
|
+
lg: "text-base"
|
|
16
|
+
};
|
|
17
|
+
function XpBar({ current, max, level, showLabel = true, size = "md" }) {
|
|
18
|
+
const percentage = max > 0 ? Math.min(current / max * 100, 100) : 0;
|
|
19
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
20
|
+
className: "w-full space-y-1",
|
|
21
|
+
children: [showLabel && /* @__PURE__ */ jsxs("div", {
|
|
22
|
+
className: cn("flex items-center justify-between", labelSizeStyles[size]),
|
|
23
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
24
|
+
className: "text-muted-foreground font-medium",
|
|
25
|
+
children: [level !== void 0 && /* @__PURE__ */ jsxs("span", {
|
|
26
|
+
className: "text-primary mr-1",
|
|
27
|
+
children: ["Lvl ", level]
|
|
28
|
+
}), "XP"]
|
|
29
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
30
|
+
className: "font-semibold",
|
|
31
|
+
children: [
|
|
32
|
+
current.toLocaleString(),
|
|
33
|
+
" / ",
|
|
34
|
+
max.toLocaleString()
|
|
35
|
+
]
|
|
36
|
+
})]
|
|
37
|
+
}), /* @__PURE__ */ jsx(Progress, {
|
|
38
|
+
value: percentage,
|
|
39
|
+
className: cn("bg-muted", sizeStyles$2[size])
|
|
40
|
+
})]
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/components/StreakCounter.tsx
|
|
46
|
+
const sizeStyles$1 = {
|
|
47
|
+
sm: {
|
|
48
|
+
container: "gap-1 px-2 py-1",
|
|
49
|
+
icon: "text-base",
|
|
50
|
+
text: "text-xs"
|
|
51
|
+
},
|
|
52
|
+
md: {
|
|
53
|
+
container: "gap-1.5 px-3 py-1.5",
|
|
54
|
+
icon: "text-lg",
|
|
55
|
+
text: "text-sm"
|
|
56
|
+
},
|
|
57
|
+
lg: {
|
|
58
|
+
container: "gap-2 px-4 py-2",
|
|
59
|
+
icon: "text-xl",
|
|
60
|
+
text: "text-base"
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
function StreakCounter({ days, isActive = true, size = "md" }) {
|
|
64
|
+
const styles = sizeStyles$1[size];
|
|
65
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
66
|
+
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"),
|
|
67
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
68
|
+
className: styles.icon,
|
|
69
|
+
role: "img",
|
|
70
|
+
"aria-label": "streak",
|
|
71
|
+
children: "🔥"
|
|
72
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
73
|
+
className: styles.text,
|
|
74
|
+
children: [
|
|
75
|
+
days,
|
|
76
|
+
" ",
|
|
77
|
+
days === 1 ? "day" : "days"
|
|
78
|
+
]
|
|
79
|
+
})]
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
//#endregion
|
|
84
|
+
//#region src/components/BadgeDisplay.tsx
|
|
85
|
+
const BADGE_ICONS = {
|
|
86
|
+
studio_first_30m: "🎯",
|
|
87
|
+
platform_tour: "🗺️",
|
|
88
|
+
crm_first_win: "🏆",
|
|
89
|
+
drill_master: "🧠",
|
|
90
|
+
coach_listener: "👂",
|
|
91
|
+
quest_complete: "⭐",
|
|
92
|
+
streak_7: "🔥",
|
|
93
|
+
streak_30: "💎",
|
|
94
|
+
default: "🏅"
|
|
95
|
+
};
|
|
96
|
+
const sizeStyles = {
|
|
97
|
+
sm: "h-6 w-6 text-sm",
|
|
98
|
+
md: "h-8 w-8 text-base",
|
|
99
|
+
lg: "h-10 w-10 text-lg"
|
|
100
|
+
};
|
|
101
|
+
function BadgeDisplay({ badges, maxVisible = 5, size = "md" }) {
|
|
102
|
+
const visibleBadges = badges.slice(0, maxVisible);
|
|
103
|
+
const hiddenCount = badges.length - maxVisible;
|
|
104
|
+
if (badges.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
105
|
+
className: "text-muted-foreground text-sm",
|
|
106
|
+
children: "No badges earned yet"
|
|
107
|
+
});
|
|
108
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
109
|
+
className: "flex items-center gap-1",
|
|
110
|
+
children: [visibleBadges.map((badge) => /* @__PURE__ */ jsx("div", {
|
|
111
|
+
className: cn("flex items-center justify-center rounded-full bg-gradient-to-br from-amber-400/20 to-amber-600/20", sizeStyles[size]),
|
|
112
|
+
title: badge.replace(/_/g, " "),
|
|
113
|
+
children: BADGE_ICONS[badge] ?? BADGE_ICONS.default
|
|
114
|
+
}, badge)), hiddenCount > 0 && /* @__PURE__ */ jsxs("div", {
|
|
115
|
+
className: cn("text-muted-foreground bg-muted flex items-center justify-center rounded-full", sizeStyles[size], "text-xs font-medium"),
|
|
116
|
+
children: ["+", hiddenCount]
|
|
117
|
+
})]
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region src/components/ViewTabs.tsx
|
|
123
|
+
const VIEW_LABELS = {
|
|
124
|
+
overview: {
|
|
125
|
+
label: "Overview",
|
|
126
|
+
icon: "📊"
|
|
127
|
+
},
|
|
128
|
+
steps: {
|
|
129
|
+
label: "Steps",
|
|
130
|
+
icon: "📝"
|
|
131
|
+
},
|
|
132
|
+
progress: {
|
|
133
|
+
label: "Progress",
|
|
134
|
+
icon: "📈"
|
|
135
|
+
},
|
|
136
|
+
timeline: {
|
|
137
|
+
label: "Timeline",
|
|
138
|
+
icon: "📅"
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
const DEFAULT_VIEWS = [
|
|
142
|
+
"overview",
|
|
143
|
+
"steps",
|
|
144
|
+
"progress",
|
|
145
|
+
"timeline"
|
|
146
|
+
];
|
|
147
|
+
function ViewTabs({ currentView, onViewChange, availableViews = DEFAULT_VIEWS }) {
|
|
148
|
+
return /* @__PURE__ */ jsx("div", {
|
|
149
|
+
className: "flex flex-wrap gap-2",
|
|
150
|
+
children: availableViews.map((view) => {
|
|
151
|
+
const { label, icon } = VIEW_LABELS[view];
|
|
152
|
+
return /* @__PURE__ */ jsxs(Button, {
|
|
153
|
+
variant: currentView === view ? "default" : "outline",
|
|
154
|
+
size: "sm",
|
|
155
|
+
onClick: () => onViewChange(view),
|
|
156
|
+
className: "gap-1.5",
|
|
157
|
+
children: [/* @__PURE__ */ jsx("span", { children: icon }), /* @__PURE__ */ jsx("span", { children: label })]
|
|
158
|
+
}, view);
|
|
159
|
+
})
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
//#endregion
|
|
164
|
+
export { XpBar as i, BadgeDisplay as n, StreakCounter as r, ViewTabs as t };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { useCallback, useMemo, useState } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/hooks/useLearningProgress.ts
|
|
4
|
+
/** Default progress state for a new track */
|
|
5
|
+
function createDefaultProgress(trackId) {
|
|
6
|
+
return {
|
|
7
|
+
trackId,
|
|
8
|
+
completedStepIds: [],
|
|
9
|
+
currentStepId: null,
|
|
10
|
+
xpEarned: 0,
|
|
11
|
+
streakDays: 0,
|
|
12
|
+
lastActivityDate: null,
|
|
13
|
+
badges: []
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/** Hook for managing learning progress state */
|
|
17
|
+
function useLearningProgress(track) {
|
|
18
|
+
const [progress, setProgress] = useState(() => createDefaultProgress(track.id));
|
|
19
|
+
const completeStep = useCallback((stepId) => {
|
|
20
|
+
const step = track.steps.find((s) => s.id === stepId);
|
|
21
|
+
if (!step || progress.completedStepIds.includes(stepId)) return;
|
|
22
|
+
setProgress((prev) => {
|
|
23
|
+
const newCompletedIds = [...prev.completedStepIds, stepId];
|
|
24
|
+
const xpReward = step.xpReward ?? 0;
|
|
25
|
+
const nextStep = track.steps.find((s) => !newCompletedIds.includes(s.id));
|
|
26
|
+
const isTrackComplete = newCompletedIds.length === track.steps.length;
|
|
27
|
+
const completionBonus = isTrackComplete ? track.completionRewards?.xpBonus ?? 0 : 0;
|
|
28
|
+
return {
|
|
29
|
+
...prev,
|
|
30
|
+
completedStepIds: newCompletedIds,
|
|
31
|
+
currentStepId: nextStep?.id ?? null,
|
|
32
|
+
xpEarned: prev.xpEarned + xpReward + completionBonus,
|
|
33
|
+
lastActivityDate: (/* @__PURE__ */ new Date()).toISOString(),
|
|
34
|
+
badges: isTrackComplete && track.completionRewards?.badgeKey ? [...prev.badges, track.completionRewards.badgeKey] : prev.badges
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
}, [track, progress.completedStepIds]);
|
|
38
|
+
const resetProgress = useCallback(() => {
|
|
39
|
+
setProgress(createDefaultProgress(track.id));
|
|
40
|
+
}, [track.id]);
|
|
41
|
+
const incrementStreak = useCallback(() => {
|
|
42
|
+
setProgress((prev) => ({
|
|
43
|
+
...prev,
|
|
44
|
+
streakDays: prev.streakDays + 1,
|
|
45
|
+
lastActivityDate: (/* @__PURE__ */ new Date()).toISOString()
|
|
46
|
+
}));
|
|
47
|
+
}, []);
|
|
48
|
+
return {
|
|
49
|
+
progress,
|
|
50
|
+
stats: useMemo(() => {
|
|
51
|
+
const totalSteps = track.steps.length;
|
|
52
|
+
const completedSteps = progress.completedStepIds.length;
|
|
53
|
+
const percentComplete = totalSteps > 0 ? Math.round(completedSteps / totalSteps * 100) : 0;
|
|
54
|
+
const totalXp = track.totalXp ?? track.steps.reduce((sum, s) => sum + (s.xpReward ?? 0), 0) + (track.completionRewards?.xpBonus ?? 0);
|
|
55
|
+
return {
|
|
56
|
+
totalSteps,
|
|
57
|
+
completedSteps,
|
|
58
|
+
remainingSteps: totalSteps - completedSteps,
|
|
59
|
+
percentComplete,
|
|
60
|
+
totalXp,
|
|
61
|
+
isComplete: completedSteps === totalSteps
|
|
62
|
+
};
|
|
63
|
+
}, [track, progress.completedStepIds]),
|
|
64
|
+
completeStep,
|
|
65
|
+
resetProgress,
|
|
66
|
+
incrementStreak
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
71
|
+
export { useLearningProgress as t };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { r as LearningProgressState } from "./types-BMAby_Ku.mjs";
|
|
2
|
+
import { LearningJourneyTrackSpec } from "@lssm/module.learning-journey/track-spec";
|
|
3
|
+
|
|
4
|
+
//#region src/hooks/useLearningProgress.d.ts
|
|
5
|
+
/** Hook for managing learning progress state */
|
|
6
|
+
declare function useLearningProgress(track: LearningJourneyTrackSpec): {
|
|
7
|
+
progress: LearningProgressState;
|
|
8
|
+
stats: {
|
|
9
|
+
totalSteps: number;
|
|
10
|
+
completedSteps: number;
|
|
11
|
+
remainingSteps: number;
|
|
12
|
+
percentComplete: number;
|
|
13
|
+
totalXp: number;
|
|
14
|
+
isComplete: boolean;
|
|
15
|
+
};
|
|
16
|
+
completeStep: (stepId: string) => void;
|
|
17
|
+
resetProgress: () => void;
|
|
18
|
+
incrementStreak: () => void;
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
export { useLearningProgress as t };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { c as XpBarProps, o as StreakCounterProps, s as ViewTabsProps, t as BadgeDisplayProps } from "./types-BMAby_Ku.mjs";
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/components/XpBar.d.ts
|
|
5
|
+
declare function XpBar({
|
|
6
|
+
current,
|
|
7
|
+
max,
|
|
8
|
+
level,
|
|
9
|
+
showLabel,
|
|
10
|
+
size
|
|
11
|
+
}: XpBarProps): react_jsx_runtime0.JSX.Element;
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/components/StreakCounter.d.ts
|
|
14
|
+
declare function StreakCounter({
|
|
15
|
+
days,
|
|
16
|
+
isActive,
|
|
17
|
+
size
|
|
18
|
+
}: StreakCounterProps): react_jsx_runtime0.JSX.Element;
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/components/BadgeDisplay.d.ts
|
|
21
|
+
declare function BadgeDisplay({
|
|
22
|
+
badges,
|
|
23
|
+
maxVisible,
|
|
24
|
+
size
|
|
25
|
+
}: BadgeDisplayProps): react_jsx_runtime0.JSX.Element;
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/components/ViewTabs.d.ts
|
|
28
|
+
declare function ViewTabs({
|
|
29
|
+
currentView,
|
|
30
|
+
onViewChange,
|
|
31
|
+
availableViews
|
|
32
|
+
}: ViewTabsProps): react_jsx_runtime0.JSX.Element;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { XpBar as i, BadgeDisplay as n, StreakCounter as r, ViewTabs as t };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { a as LearningViewProps, c as XpBarProps, i as LearningView, n as LearningMiniAppProps, o as StreakCounterProps, r as LearningProgressState, s as ViewTabsProps, t as BadgeDisplayProps } from "./types-BMAby_Ku.mjs";
|
|
2
|
+
import { i as XpBar, n as BadgeDisplay, r as StreakCounter, t as ViewTabs } from "./index-EWErSKip.mjs";
|
|
3
|
+
import { t as useLearningProgress } from "./index-D_7WU_xm.mjs";
|
|
4
|
+
export { BadgeDisplay, type BadgeDisplayProps, type LearningMiniAppProps, type LearningProgressState, type LearningView, type LearningViewProps, StreakCounter, type StreakCounterProps, ViewTabs, type ViewTabsProps, XpBar, type XpBarProps, useLearningProgress };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { LearningJourneyTrackSpec } from "@lssm/module.learning-journey/track-spec";
|
|
2
|
+
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
/** View types for learning mini-apps */
|
|
5
|
+
type LearningView = 'overview' | 'steps' | 'progress' | 'timeline';
|
|
6
|
+
/** Progress state for a learning track */
|
|
7
|
+
interface LearningProgressState {
|
|
8
|
+
trackId: string;
|
|
9
|
+
completedStepIds: string[];
|
|
10
|
+
currentStepId: string | null;
|
|
11
|
+
xpEarned: number;
|
|
12
|
+
streakDays: number;
|
|
13
|
+
lastActivityDate: string | null;
|
|
14
|
+
badges: string[];
|
|
15
|
+
}
|
|
16
|
+
/** Props for mini-app components */
|
|
17
|
+
interface LearningMiniAppProps {
|
|
18
|
+
track: LearningJourneyTrackSpec;
|
|
19
|
+
progress: LearningProgressState;
|
|
20
|
+
onStepComplete?: (stepId: string) => void;
|
|
21
|
+
onViewChange?: (view: LearningView) => void;
|
|
22
|
+
initialView?: LearningView;
|
|
23
|
+
}
|
|
24
|
+
/** Props for view components */
|
|
25
|
+
interface LearningViewProps {
|
|
26
|
+
track: LearningJourneyTrackSpec;
|
|
27
|
+
progress: LearningProgressState;
|
|
28
|
+
onStepComplete?: (stepId: string) => void;
|
|
29
|
+
}
|
|
30
|
+
/** XP bar props */
|
|
31
|
+
interface XpBarProps {
|
|
32
|
+
current: number;
|
|
33
|
+
max: number;
|
|
34
|
+
level?: number;
|
|
35
|
+
showLabel?: boolean;
|
|
36
|
+
size?: 'sm' | 'md' | 'lg';
|
|
37
|
+
}
|
|
38
|
+
/** Streak counter props */
|
|
39
|
+
interface StreakCounterProps {
|
|
40
|
+
days: number;
|
|
41
|
+
isActive?: boolean;
|
|
42
|
+
size?: 'sm' | 'md' | 'lg';
|
|
43
|
+
}
|
|
44
|
+
/** Badge display props */
|
|
45
|
+
interface BadgeDisplayProps {
|
|
46
|
+
badges: string[];
|
|
47
|
+
maxVisible?: number;
|
|
48
|
+
size?: 'sm' | 'md' | 'lg';
|
|
49
|
+
}
|
|
50
|
+
/** View tabs props */
|
|
51
|
+
interface ViewTabsProps {
|
|
52
|
+
currentView: LearningView;
|
|
53
|
+
onViewChange: (view: LearningView) => void;
|
|
54
|
+
availableViews?: LearningView[];
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
export { LearningViewProps as a, XpBarProps as c, LearningView as i, LearningMiniAppProps as n, StreakCounterProps as o, LearningProgressState as r, ViewTabsProps as s, BadgeDisplayProps as t };
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as LearningViewProps, c as XpBarProps, i as LearningView, n as LearningMiniAppProps, o as StreakCounterProps, r as LearningProgressState, s as ViewTabsProps, t as BadgeDisplayProps } from "./types-BMAby_Ku.mjs";
|
|
2
|
+
export { BadgeDisplayProps, LearningMiniAppProps, LearningProgressState, LearningView, LearningViewProps, StreakCounterProps, ViewTabsProps, XpBarProps };
|
package/dist/types.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lssm/example.learning-journey-ui-shared",
|
|
3
|
+
"version": "0.0.0-canary-20251212210835",
|
|
4
|
+
"description": "Shared UI components and hooks for learning journey mini-apps.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./src/index.ts",
|
|
10
|
+
"./hooks": "./src/hooks/index.ts",
|
|
11
|
+
"./components": "./src/components/index.ts",
|
|
12
|
+
"./types": "./src/types.ts",
|
|
13
|
+
"./*": "./*"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "bun build:bundle && bun build:types",
|
|
17
|
+
"build:bundle": "tsdown",
|
|
18
|
+
"build:types": "tsc --noEmit",
|
|
19
|
+
"dev": "bun build:bundle --watch",
|
|
20
|
+
"clean": "rimraf dist .turbo",
|
|
21
|
+
"lint": "bun lint:fix",
|
|
22
|
+
"lint:fix": "eslint src --fix",
|
|
23
|
+
"lint:check": "eslint src",
|
|
24
|
+
"test": "bun test"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@lssm/module.learning-journey": "workspace:*",
|
|
28
|
+
"@lssm/lib.design-system": "workspace:*",
|
|
29
|
+
"@lssm/lib.ui-kit-web": "workspace:*",
|
|
30
|
+
"react": "^19.1.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@lssm/tool.tsdown": "workspace:*",
|
|
34
|
+
"@lssm/tool.typescript": "workspace:*",
|
|
35
|
+
"@types/react": "^19.1.6",
|
|
36
|
+
"tsdown": "^0.17.0",
|
|
37
|
+
"typescript": "^5.9.3"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
41
|
+
},
|
|
42
|
+
"module": "./dist/index.js",
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"exports": {
|
|
45
|
+
".": "./dist/index.js",
|
|
46
|
+
"./hooks": "./dist/hooks/index.js",
|
|
47
|
+
"./components": "./dist/components/index.js",
|
|
48
|
+
"./types": "./dist/types.js",
|
|
49
|
+
"./*": "./*"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { cn } from '@lssm/lib.ui-kit-web/ui/utils';
|
|
4
|
+
import type { BadgeDisplayProps } from '../types';
|
|
5
|
+
|
|
6
|
+
const BADGE_ICONS: Record<string, string> = {
|
|
7
|
+
studio_first_30m: '🎯',
|
|
8
|
+
platform_tour: '🗺️',
|
|
9
|
+
crm_first_win: '🏆',
|
|
10
|
+
drill_master: '🧠',
|
|
11
|
+
coach_listener: '👂',
|
|
12
|
+
quest_complete: '⭐',
|
|
13
|
+
streak_7: '🔥',
|
|
14
|
+
streak_30: '💎',
|
|
15
|
+
default: '🏅',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const sizeStyles = {
|
|
19
|
+
sm: 'h-6 w-6 text-sm',
|
|
20
|
+
md: 'h-8 w-8 text-base',
|
|
21
|
+
lg: 'h-10 w-10 text-lg',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export function BadgeDisplay({
|
|
25
|
+
badges,
|
|
26
|
+
maxVisible = 5,
|
|
27
|
+
size = 'md',
|
|
28
|
+
}: BadgeDisplayProps) {
|
|
29
|
+
const visibleBadges = badges.slice(0, maxVisible);
|
|
30
|
+
const hiddenCount = badges.length - maxVisible;
|
|
31
|
+
|
|
32
|
+
if (badges.length === 0) {
|
|
33
|
+
return (
|
|
34
|
+
<div className="text-muted-foreground text-sm">No badges earned yet</div>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<div className="flex items-center gap-1">
|
|
40
|
+
{visibleBadges.map((badge) => (
|
|
41
|
+
<div
|
|
42
|
+
key={badge}
|
|
43
|
+
className={cn(
|
|
44
|
+
'flex items-center justify-center rounded-full bg-gradient-to-br from-amber-400/20 to-amber-600/20',
|
|
45
|
+
sizeStyles[size]
|
|
46
|
+
)}
|
|
47
|
+
title={badge.replace(/_/g, ' ')}
|
|
48
|
+
>
|
|
49
|
+
{BADGE_ICONS[badge] ?? BADGE_ICONS.default}
|
|
50
|
+
</div>
|
|
51
|
+
))}
|
|
52
|
+
{hiddenCount > 0 && (
|
|
53
|
+
<div
|
|
54
|
+
className={cn(
|
|
55
|
+
'text-muted-foreground bg-muted flex items-center justify-center rounded-full',
|
|
56
|
+
sizeStyles[size],
|
|
57
|
+
'text-xs font-medium'
|
|
58
|
+
)}
|
|
59
|
+
>
|
|
60
|
+
+{hiddenCount}
|
|
61
|
+
</div>
|
|
62
|
+
)}
|
|
63
|
+
</div>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { cn } from '@lssm/lib.ui-kit-web/ui/utils';
|
|
4
|
+
import type { StreakCounterProps } from '../types';
|
|
5
|
+
|
|
6
|
+
const sizeStyles = {
|
|
7
|
+
sm: {
|
|
8
|
+
container: 'gap-1 px-2 py-1',
|
|
9
|
+
icon: 'text-base',
|
|
10
|
+
text: 'text-xs',
|
|
11
|
+
},
|
|
12
|
+
md: {
|
|
13
|
+
container: 'gap-1.5 px-3 py-1.5',
|
|
14
|
+
icon: 'text-lg',
|
|
15
|
+
text: 'text-sm',
|
|
16
|
+
},
|
|
17
|
+
lg: {
|
|
18
|
+
container: 'gap-2 px-4 py-2',
|
|
19
|
+
icon: 'text-xl',
|
|
20
|
+
text: 'text-base',
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export function StreakCounter({
|
|
25
|
+
days,
|
|
26
|
+
isActive = true,
|
|
27
|
+
size = 'md',
|
|
28
|
+
}: StreakCounterProps) {
|
|
29
|
+
const styles = sizeStyles[size];
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<div
|
|
33
|
+
className={cn(
|
|
34
|
+
'inline-flex items-center rounded-full font-semibold',
|
|
35
|
+
styles.container,
|
|
36
|
+
isActive
|
|
37
|
+
? 'bg-orange-500/10 text-orange-500'
|
|
38
|
+
: 'bg-muted text-muted-foreground'
|
|
39
|
+
)}
|
|
40
|
+
>
|
|
41
|
+
<span className={styles.icon} role="img" aria-label="streak">
|
|
42
|
+
🔥
|
|
43
|
+
</span>
|
|
44
|
+
<span className={styles.text}>
|
|
45
|
+
{days} {days === 1 ? 'day' : 'days'}
|
|
46
|
+
</span>
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Button } from '@lssm/lib.design-system';
|
|
4
|
+
import type { ViewTabsProps, LearningView } from '../types';
|
|
5
|
+
|
|
6
|
+
const VIEW_LABELS: Record<LearningView, { label: string; icon: string }> = {
|
|
7
|
+
overview: { label: 'Overview', icon: '📊' },
|
|
8
|
+
steps: { label: 'Steps', icon: '📝' },
|
|
9
|
+
progress: { label: 'Progress', icon: '📈' },
|
|
10
|
+
timeline: { label: 'Timeline', icon: '📅' },
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const DEFAULT_VIEWS: LearningView[] = [
|
|
14
|
+
'overview',
|
|
15
|
+
'steps',
|
|
16
|
+
'progress',
|
|
17
|
+
'timeline',
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
export function ViewTabs({
|
|
21
|
+
currentView,
|
|
22
|
+
onViewChange,
|
|
23
|
+
availableViews = DEFAULT_VIEWS,
|
|
24
|
+
}: ViewTabsProps) {
|
|
25
|
+
return (
|
|
26
|
+
<div className="flex flex-wrap gap-2">
|
|
27
|
+
{availableViews.map((view) => {
|
|
28
|
+
const { label, icon } = VIEW_LABELS[view];
|
|
29
|
+
const isActive = currentView === view;
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<Button
|
|
33
|
+
key={view}
|
|
34
|
+
variant={isActive ? 'default' : 'outline'}
|
|
35
|
+
size="sm"
|
|
36
|
+
onClick={() => onViewChange(view)}
|
|
37
|
+
className="gap-1.5"
|
|
38
|
+
>
|
|
39
|
+
<span>{icon}</span>
|
|
40
|
+
<span>{label}</span>
|
|
41
|
+
</Button>
|
|
42
|
+
);
|
|
43
|
+
})}
|
|
44
|
+
</div>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|