@contractspec/example.learning-journey-ui-coaching 0.0.0-canary-20260113170453

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.
Files changed (71) hide show
  1. package/.turbo/turbo-build$colon$bundle.log +57 -0
  2. package/.turbo/turbo-build.log +58 -0
  3. package/CHANGELOG.md +466 -0
  4. package/LICENSE +21 -0
  5. package/README.md +32 -0
  6. package/dist/CoachingMiniApp.d.ts +17 -0
  7. package/dist/CoachingMiniApp.d.ts.map +1 -0
  8. package/dist/CoachingMiniApp.js +63 -0
  9. package/dist/CoachingMiniApp.js.map +1 -0
  10. package/dist/components/EngagementMeter.d.ts +18 -0
  11. package/dist/components/EngagementMeter.d.ts.map +1 -0
  12. package/dist/components/EngagementMeter.js +108 -0
  13. package/dist/components/EngagementMeter.js.map +1 -0
  14. package/dist/components/TipCard.d.ts +21 -0
  15. package/dist/components/TipCard.d.ts.map +1 -0
  16. package/dist/components/TipCard.js +76 -0
  17. package/dist/components/TipCard.js.map +1 -0
  18. package/dist/components/TipFeed.d.ts +18 -0
  19. package/dist/components/TipFeed.d.ts.map +1 -0
  20. package/dist/components/TipFeed.js +66 -0
  21. package/dist/components/TipFeed.js.map +1 -0
  22. package/dist/components/index.d.ts +4 -0
  23. package/dist/components/index.js +5 -0
  24. package/dist/docs/index.d.ts +1 -0
  25. package/dist/docs/index.js +1 -0
  26. package/dist/docs/learning-journey-ui-coaching.docblock.d.ts +1 -0
  27. package/dist/docs/learning-journey-ui-coaching.docblock.js +20 -0
  28. package/dist/docs/learning-journey-ui-coaching.docblock.js.map +1 -0
  29. package/dist/example.d.ts +7 -0
  30. package/dist/example.d.ts.map +1 -0
  31. package/dist/example.js +42 -0
  32. package/dist/example.js.map +1 -0
  33. package/dist/index.d.ts +12 -0
  34. package/dist/index.js +14 -0
  35. package/dist/views/Overview.d.ts +16 -0
  36. package/dist/views/Overview.d.ts.map +1 -0
  37. package/dist/views/Overview.js +151 -0
  38. package/dist/views/Overview.js.map +1 -0
  39. package/dist/views/Progress.d.ts +11 -0
  40. package/dist/views/Progress.d.ts.map +1 -0
  41. package/dist/views/Progress.js +115 -0
  42. package/dist/views/Progress.js.map +1 -0
  43. package/dist/views/Steps.d.ts +12 -0
  44. package/dist/views/Steps.d.ts.map +1 -0
  45. package/dist/views/Steps.js +69 -0
  46. package/dist/views/Steps.js.map +1 -0
  47. package/dist/views/Timeline.d.ts +11 -0
  48. package/dist/views/Timeline.d.ts.map +1 -0
  49. package/dist/views/Timeline.js +113 -0
  50. package/dist/views/Timeline.js.map +1 -0
  51. package/dist/views/index.d.ts +5 -0
  52. package/dist/views/index.js +6 -0
  53. package/example.ts +1 -0
  54. package/package.json +76 -0
  55. package/src/CoachingMiniApp.tsx +93 -0
  56. package/src/components/EngagementMeter.tsx +93 -0
  57. package/src/components/TipCard.tsx +101 -0
  58. package/src/components/TipFeed.tsx +101 -0
  59. package/src/components/index.ts +3 -0
  60. package/src/docs/index.ts +1 -0
  61. package/src/docs/learning-journey-ui-coaching.docblock.ts +17 -0
  62. package/src/example.ts +31 -0
  63. package/src/index.ts +10 -0
  64. package/src/views/Overview.tsx +157 -0
  65. package/src/views/Progress.tsx +164 -0
  66. package/src/views/Steps.tsx +63 -0
  67. package/src/views/Timeline.tsx +114 -0
  68. package/src/views/index.ts +4 -0
  69. package/tsconfig.json +10 -0
  70. package/tsconfig.tsbuildinfo +1 -0
  71. package/tsdown.config.js +17 -0
@@ -0,0 +1,157 @@
1
+ 'use client';
2
+
3
+ import { Button } from '@contractspec/lib.design-system';
4
+ import {
5
+ Card,
6
+ CardContent,
7
+ CardHeader,
8
+ CardTitle,
9
+ } from '@contractspec/lib.ui-kit-web/ui/card';
10
+ import {
11
+ XpBar,
12
+ StreakCounter,
13
+ } from '@contractspec/example.learning-journey-ui-shared';
14
+ import { TipCard } from '../components/TipCard';
15
+ import type { LearningViewProps } from '@contractspec/example.learning-journey-ui-shared';
16
+
17
+ interface CoachingOverviewProps extends LearningViewProps {
18
+ onStart?: () => void;
19
+ }
20
+
21
+ export function Overview({
22
+ track,
23
+ progress,
24
+ onStepComplete,
25
+ onStart,
26
+ }: CoachingOverviewProps) {
27
+ const totalXp =
28
+ track.totalXp ?? track.steps.reduce((sum, s) => sum + (s.xpReward ?? 0), 0);
29
+
30
+ const completedSteps = progress.completedStepIds.length;
31
+ const totalSteps = track.steps.length;
32
+ const pendingSteps = totalSteps - completedSteps;
33
+
34
+ // Get active tips (incomplete ones)
35
+ const activeTips = track.steps
36
+ .filter((s) => !progress.completedStepIds.includes(s.id))
37
+ .slice(0, 3);
38
+
39
+ return (
40
+ <div className="space-y-6">
41
+ {/* Header Card */}
42
+ <Card className="overflow-hidden bg-gradient-to-br from-amber-500/10 via-orange-500/10 to-red-500/10">
43
+ <CardContent className="p-6">
44
+ <div className="flex flex-col items-center gap-4 text-center md:flex-row md:text-left">
45
+ <div className="flex h-16 w-16 items-center justify-center rounded-2xl bg-gradient-to-br from-amber-500 to-orange-600 text-3xl shadow-lg">
46
+ 💡
47
+ </div>
48
+ <div className="flex-1">
49
+ <h1 className="text-2xl font-bold">{track.name}</h1>
50
+ <p className="text-muted-foreground mt-1">{track.description}</p>
51
+ </div>
52
+ <div className="flex items-center gap-4">
53
+ <StreakCounter days={progress.streakDays} size="lg" />
54
+ </div>
55
+ </div>
56
+ </CardContent>
57
+ </Card>
58
+
59
+ {/* Quick Stats */}
60
+ <div className="grid gap-4 md:grid-cols-3">
61
+ <Card>
62
+ <CardHeader className="pb-2">
63
+ <CardTitle className="text-muted-foreground text-sm font-medium">
64
+ Active Tips
65
+ </CardTitle>
66
+ </CardHeader>
67
+ <CardContent>
68
+ <div className="text-3xl font-bold text-amber-500">
69
+ {pendingSteps}
70
+ </div>
71
+ <p className="text-muted-foreground text-sm">tips for you today</p>
72
+ </CardContent>
73
+ </Card>
74
+
75
+ <Card>
76
+ <CardHeader className="pb-2">
77
+ <CardTitle className="text-muted-foreground text-sm font-medium">
78
+ Tips Actioned
79
+ </CardTitle>
80
+ </CardHeader>
81
+ <CardContent>
82
+ <div className="text-3xl font-bold text-green-500">
83
+ {completedSteps}
84
+ </div>
85
+ <p className="text-muted-foreground text-sm">
86
+ out of {totalSteps} total
87
+ </p>
88
+ </CardContent>
89
+ </Card>
90
+
91
+ <Card>
92
+ <CardHeader className="pb-2">
93
+ <CardTitle className="text-muted-foreground text-sm font-medium">
94
+ XP Earned
95
+ </CardTitle>
96
+ </CardHeader>
97
+ <CardContent>
98
+ <div className="text-3xl font-bold text-orange-500">
99
+ {progress.xpEarned}
100
+ </div>
101
+ <XpBar
102
+ current={progress.xpEarned}
103
+ max={totalXp}
104
+ showLabel={false}
105
+ size="sm"
106
+ />
107
+ </CardContent>
108
+ </Card>
109
+ </div>
110
+
111
+ {/* Active Tips Preview */}
112
+ {activeTips.length > 0 && (
113
+ <Card>
114
+ <CardHeader className="flex flex-row items-center justify-between">
115
+ <CardTitle className="flex items-center gap-2">
116
+ <span>💡</span>
117
+ <span>Tips for You</span>
118
+ </CardTitle>
119
+ {activeTips.length < pendingSteps && (
120
+ <Button variant="outline" size="sm" onClick={onStart}>
121
+ View All ({pendingSteps})
122
+ </Button>
123
+ )}
124
+ </CardHeader>
125
+ <CardContent className="space-y-3">
126
+ {activeTips.map((step) => (
127
+ <TipCard
128
+ key={step.id}
129
+ step={step}
130
+ isCompleted={false}
131
+ isCurrent={step.id === activeTips[0]?.id}
132
+ onComplete={() => onStepComplete?.(step.id)}
133
+ />
134
+ ))}
135
+ </CardContent>
136
+ </Card>
137
+ )}
138
+
139
+ {/* All Complete */}
140
+ {pendingSteps === 0 && (
141
+ <Card className="border-green-500/50 bg-green-500/5">
142
+ <CardContent className="flex items-center gap-4 p-6">
143
+ <div className="text-4xl">🎉</div>
144
+ <div>
145
+ <h3 className="text-lg font-semibold text-green-500">
146
+ All Tips Actioned!
147
+ </h3>
148
+ <p className="text-muted-foreground">
149
+ Great job! You've addressed all {totalSteps} coaching tips.
150
+ </p>
151
+ </div>
152
+ </CardContent>
153
+ </Card>
154
+ )}
155
+ </div>
156
+ );
157
+ }
@@ -0,0 +1,164 @@
1
+ 'use client';
2
+
3
+ import {
4
+ Card,
5
+ CardContent,
6
+ CardHeader,
7
+ CardTitle,
8
+ } from '@contractspec/lib.ui-kit-web/ui/card';
9
+ import {
10
+ XpBar,
11
+ BadgeDisplay,
12
+ StreakCounter,
13
+ } from '@contractspec/example.learning-journey-ui-shared';
14
+ import { EngagementMeter } from '../components/EngagementMeter';
15
+ import type { LearningViewProps } from '@contractspec/example.learning-journey-ui-shared';
16
+
17
+ export function ProgressView({ track, progress }: LearningViewProps) {
18
+ const totalXp =
19
+ track.totalXp ?? track.steps.reduce((sum, s) => sum + (s.xpReward ?? 0), 0);
20
+
21
+ const completedSteps = progress.completedStepIds.length;
22
+ const totalSteps = track.steps.length;
23
+ const pendingSteps = totalSteps - completedSteps;
24
+
25
+ // For demo: split completed into "actioned" and "acknowledged"
26
+ // In real app, this would come from progress data
27
+ const actioned = Math.floor(completedSteps * 0.7);
28
+ const acknowledged = completedSteps - actioned;
29
+
30
+ return (
31
+ <div className="space-y-6">
32
+ {/* Engagement Overview */}
33
+ <Card>
34
+ <CardHeader>
35
+ <CardTitle className="flex items-center gap-2">
36
+ <span>📊</span>
37
+ <span>Engagement Overview</span>
38
+ </CardTitle>
39
+ </CardHeader>
40
+ <CardContent>
41
+ <EngagementMeter
42
+ actioned={actioned}
43
+ acknowledged={acknowledged}
44
+ pending={pendingSteps}
45
+ streak={progress.streakDays}
46
+ />
47
+ </CardContent>
48
+ </Card>
49
+
50
+ {/* Stats Grid */}
51
+ <div className="grid gap-4 md:grid-cols-2">
52
+ <Card>
53
+ <CardHeader className="pb-2">
54
+ <CardTitle className="text-muted-foreground text-sm font-medium">
55
+ XP Earned
56
+ </CardTitle>
57
+ </CardHeader>
58
+ <CardContent className="space-y-3">
59
+ <div className="flex items-baseline gap-2">
60
+ <span className="text-3xl font-bold text-orange-500">
61
+ {progress.xpEarned}
62
+ </span>
63
+ <span className="text-muted-foreground">/ {totalXp} XP</span>
64
+ </div>
65
+ <XpBar
66
+ current={progress.xpEarned}
67
+ max={totalXp}
68
+ showLabel={false}
69
+ size="lg"
70
+ />
71
+ </CardContent>
72
+ </Card>
73
+
74
+ <Card>
75
+ <CardHeader className="pb-2">
76
+ <CardTitle className="text-muted-foreground text-sm font-medium">
77
+ Engagement Streak
78
+ </CardTitle>
79
+ </CardHeader>
80
+ <CardContent>
81
+ <div className="flex items-center gap-4">
82
+ <StreakCounter days={progress.streakDays} size="lg" />
83
+ <div className="text-muted-foreground text-sm">
84
+ {progress.streakDays > 0
85
+ ? 'Keep going!'
86
+ : 'Start your streak today!'}
87
+ </div>
88
+ </div>
89
+ </CardContent>
90
+ </Card>
91
+ </div>
92
+
93
+ {/* Achievements */}
94
+ <Card>
95
+ <CardHeader>
96
+ <CardTitle className="flex items-center gap-2">
97
+ <span>🏅</span>
98
+ <span>Achievements</span>
99
+ </CardTitle>
100
+ </CardHeader>
101
+ <CardContent>
102
+ <BadgeDisplay badges={progress.badges} size="lg" maxVisible={10} />
103
+ {progress.badges.length === 0 && (
104
+ <p className="text-muted-foreground text-sm">
105
+ Action tips to unlock achievements!
106
+ </p>
107
+ )}
108
+ </CardContent>
109
+ </Card>
110
+
111
+ {/* Tip Breakdown */}
112
+ <Card>
113
+ <CardHeader>
114
+ <CardTitle className="flex items-center gap-2">
115
+ <span>💡</span>
116
+ <span>Tip Status</span>
117
+ </CardTitle>
118
+ </CardHeader>
119
+ <CardContent>
120
+ <div className="space-y-3">
121
+ {track.steps.map((step) => {
122
+ const isCompleted = progress.completedStepIds.includes(step.id);
123
+
124
+ return (
125
+ <div
126
+ key={step.id}
127
+ className="flex items-center justify-between rounded-lg border p-3"
128
+ >
129
+ <div className="flex items-center gap-3">
130
+ <span
131
+ className={
132
+ isCompleted ? 'text-green-500' : 'text-amber-500'
133
+ }
134
+ >
135
+ {isCompleted ? '✓' : '○'}
136
+ </span>
137
+ <span
138
+ className={
139
+ isCompleted
140
+ ? 'text-muted-foreground'
141
+ : 'text-foreground'
142
+ }
143
+ >
144
+ {step.title}
145
+ </span>
146
+ </div>
147
+ <span
148
+ className={`text-sm ${
149
+ isCompleted ? 'text-green-500' : 'text-muted-foreground'
150
+ }`}
151
+ >
152
+ {isCompleted ? 'Actioned' : 'Pending'}
153
+ </span>
154
+ </div>
155
+ );
156
+ })}
157
+ </div>
158
+ </CardContent>
159
+ </Card>
160
+ </div>
161
+ );
162
+ }
163
+
164
+ export { ProgressView as Progress };
@@ -0,0 +1,63 @@
1
+ 'use client';
2
+
3
+ import { TipCard } from '../components/TipCard';
4
+ import type { LearningViewProps } from '@contractspec/example.learning-journey-ui-shared';
5
+
6
+ export function Steps({ track, progress, onStepComplete }: LearningViewProps) {
7
+ const completedSteps = progress.completedStepIds.length;
8
+ const totalSteps = track.steps.length;
9
+
10
+ // Sort: pending first, then completed
11
+ const sortedSteps = [...track.steps].sort((a, b) => {
12
+ const aCompleted = progress.completedStepIds.includes(a.id);
13
+ const bCompleted = progress.completedStepIds.includes(b.id);
14
+ if (aCompleted === bCompleted) return 0;
15
+ return aCompleted ? 1 : -1;
16
+ });
17
+
18
+ const currentStepId = track.steps.find(
19
+ (s) => !progress.completedStepIds.includes(s.id)
20
+ )?.id;
21
+
22
+ return (
23
+ <div className="space-y-6">
24
+ {/* Header */}
25
+ <div className="text-center">
26
+ <h2 className="text-xl font-bold">Coaching Tips</h2>
27
+ <p className="text-muted-foreground">
28
+ Review and take action on personalized tips
29
+ </p>
30
+ <p className="text-muted-foreground mt-2 text-sm">
31
+ {completedSteps} of {totalSteps} tips actioned
32
+ </p>
33
+ </div>
34
+
35
+ {/* Tips Stack */}
36
+ <div className="space-y-3">
37
+ {sortedSteps.map((step) => {
38
+ const isCompleted = progress.completedStepIds.includes(step.id);
39
+ const isCurrent = step.id === currentStepId;
40
+
41
+ return (
42
+ <TipCard
43
+ key={step.id}
44
+ step={step}
45
+ isCompleted={isCompleted}
46
+ isCurrent={isCurrent}
47
+ onComplete={() => onStepComplete?.(step.id)}
48
+ onDismiss={() => onStepComplete?.(step.id)} // Dismiss also completes
49
+ />
50
+ );
51
+ })}
52
+ </div>
53
+
54
+ {/* All done */}
55
+ {completedSteps === totalSteps && (
56
+ <div className="text-muted-foreground text-center">
57
+ <span className="text-2xl">✨</span>
58
+ <p className="mt-2">All tips have been addressed!</p>
59
+ </div>
60
+ )}
61
+ </div>
62
+ );
63
+ }
@@ -0,0 +1,114 @@
1
+ 'use client';
2
+
3
+ import {
4
+ Card,
5
+ CardContent,
6
+ CardHeader,
7
+ CardTitle,
8
+ } from '@contractspec/lib.ui-kit-web/ui/card';
9
+ import { TipFeed } from '../components/TipFeed';
10
+ import type { LearningViewProps } from '@contractspec/example.learning-journey-ui-shared';
11
+
12
+ export function Timeline({ track, progress }: LearningViewProps) {
13
+ // Create feed items sorted by completion status (completed first for "recent activity")
14
+ const feedItems = track.steps
15
+ .map((step) => ({
16
+ step,
17
+ isCompleted: progress.completedStepIds.includes(step.id),
18
+ completedAt: progress.completedStepIds.includes(step.id)
19
+ ? 'Recently'
20
+ : undefined,
21
+ }))
22
+ .sort((a, b) => {
23
+ // Completed items first (as recent activity)
24
+ if (a.isCompleted && !b.isCompleted) return -1;
25
+ if (!a.isCompleted && b.isCompleted) return 1;
26
+ return 0;
27
+ });
28
+
29
+ const completedCount = feedItems.filter((f) => f.isCompleted).length;
30
+ const pendingCount = feedItems.length - completedCount;
31
+
32
+ return (
33
+ <div className="space-y-6">
34
+ {/* Header */}
35
+ <div className="text-center">
36
+ <h2 className="text-xl font-bold">Activity Timeline</h2>
37
+ <p className="text-muted-foreground">
38
+ Your coaching journey and tip history
39
+ </p>
40
+ </div>
41
+
42
+ {/* Summary */}
43
+ <div className="grid grid-cols-2 gap-4">
44
+ <Card>
45
+ <CardContent className="p-4 text-center">
46
+ <div className="text-2xl font-bold text-green-500">
47
+ {completedCount}
48
+ </div>
49
+ <div className="text-muted-foreground text-sm">Tips Actioned</div>
50
+ </CardContent>
51
+ </Card>
52
+ <Card>
53
+ <CardContent className="p-4 text-center">
54
+ <div className="text-2xl font-bold text-amber-500">
55
+ {pendingCount}
56
+ </div>
57
+ <div className="text-muted-foreground text-sm">Tips Pending</div>
58
+ </CardContent>
59
+ </Card>
60
+ </div>
61
+
62
+ {/* Activity Feed */}
63
+ <Card>
64
+ <CardHeader>
65
+ <CardTitle className="flex items-center gap-2">
66
+ <span>📝</span>
67
+ <span>Coaching Feed</span>
68
+ </CardTitle>
69
+ </CardHeader>
70
+ <CardContent>
71
+ <TipFeed items={feedItems} />
72
+ </CardContent>
73
+ </Card>
74
+
75
+ {/* Journey Stats */}
76
+ <Card>
77
+ <CardHeader>
78
+ <CardTitle className="flex items-center gap-2">
79
+ <span>📈</span>
80
+ <span>Journey Stats</span>
81
+ </CardTitle>
82
+ </CardHeader>
83
+ <CardContent>
84
+ <div className="space-y-4">
85
+ <div className="flex items-center justify-between">
86
+ <span className="text-muted-foreground">Total Tips</span>
87
+ <span className="font-semibold">{track.steps.length}</span>
88
+ </div>
89
+ <div className="flex items-center justify-between">
90
+ <span className="text-muted-foreground">Completed</span>
91
+ <span className="font-semibold text-green-500">
92
+ {completedCount}
93
+ </span>
94
+ </div>
95
+ <div className="flex items-center justify-between">
96
+ <span className="text-muted-foreground">XP Earned</span>
97
+ <span className="font-semibold text-orange-500">
98
+ {progress.xpEarned}
99
+ </span>
100
+ </div>
101
+ <div className="flex items-center justify-between">
102
+ <span className="text-muted-foreground">Current Streak</span>
103
+ <span className="font-semibold">
104
+ {progress.streakDays > 0
105
+ ? `🔥 ${progress.streakDays} days`
106
+ : 'Start today!'}
107
+ </span>
108
+ </div>
109
+ </div>
110
+ </CardContent>
111
+ </Card>
112
+ </div>
113
+ );
114
+ }
@@ -0,0 +1,4 @@
1
+ export { Overview } from './Overview';
2
+ export { Steps } from './Steps';
3
+ export { Progress } from './Progress';
4
+ export { Timeline } from './Timeline';
package/tsconfig.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "@contractspec/tool.typescript/react-library.json",
3
+ "include": ["src"],
4
+ "exclude": ["node_modules"],
5
+ "compilerOptions": {
6
+ "rootDir": "src",
7
+ "outDir": "dist"
8
+ }
9
+ }
10
+