@contractspec/example.learning-journey-ui-coaching 1.44.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$colon$bundle.log +57 -0
- package/.turbo/turbo-build.log +58 -0
- package/CHANGELOG.md +262 -0
- package/LICENSE +21 -0
- package/README.md +32 -0
- package/dist/CoachingMiniApp.d.ts +17 -0
- package/dist/CoachingMiniApp.d.ts.map +1 -0
- package/dist/CoachingMiniApp.js +63 -0
- package/dist/CoachingMiniApp.js.map +1 -0
- package/dist/components/EngagementMeter.d.ts +18 -0
- package/dist/components/EngagementMeter.d.ts.map +1 -0
- package/dist/components/EngagementMeter.js +108 -0
- package/dist/components/EngagementMeter.js.map +1 -0
- package/dist/components/TipCard.d.ts +21 -0
- package/dist/components/TipCard.d.ts.map +1 -0
- package/dist/components/TipCard.js +76 -0
- package/dist/components/TipCard.js.map +1 -0
- package/dist/components/TipFeed.d.ts +18 -0
- package/dist/components/TipFeed.d.ts.map +1 -0
- package/dist/components/TipFeed.js +66 -0
- package/dist/components/TipFeed.js.map +1 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.js +5 -0
- package/dist/docs/index.d.ts +1 -0
- package/dist/docs/index.js +1 -0
- package/dist/docs/learning-journey-ui-coaching.docblock.d.ts +1 -0
- package/dist/docs/learning-journey-ui-coaching.docblock.js +20 -0
- package/dist/docs/learning-journey-ui-coaching.docblock.js.map +1 -0
- package/dist/example.d.ts +33 -0
- package/dist/example.d.ts.map +1 -0
- package/dist/example.js +35 -0
- package/dist/example.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +14 -0
- package/dist/views/Overview.d.ts +16 -0
- package/dist/views/Overview.d.ts.map +1 -0
- package/dist/views/Overview.js +151 -0
- package/dist/views/Overview.js.map +1 -0
- package/dist/views/Progress.d.ts +11 -0
- package/dist/views/Progress.d.ts.map +1 -0
- package/dist/views/Progress.js +115 -0
- package/dist/views/Progress.js.map +1 -0
- package/dist/views/Steps.d.ts +12 -0
- package/dist/views/Steps.d.ts.map +1 -0
- package/dist/views/Steps.js +69 -0
- package/dist/views/Steps.js.map +1 -0
- package/dist/views/Timeline.d.ts +11 -0
- package/dist/views/Timeline.d.ts.map +1 -0
- package/dist/views/Timeline.js +113 -0
- package/dist/views/Timeline.js.map +1 -0
- package/dist/views/index.d.ts +5 -0
- package/dist/views/index.js +6 -0
- package/example.ts +1 -0
- package/package.json +79 -0
- package/src/CoachingMiniApp.tsx +93 -0
- package/src/components/EngagementMeter.tsx +93 -0
- package/src/components/TipCard.tsx +101 -0
- package/src/components/TipFeed.tsx +101 -0
- package/src/components/index.ts +3 -0
- package/src/docs/index.ts +1 -0
- package/src/docs/learning-journey-ui-coaching.docblock.ts +17 -0
- package/src/example.ts +24 -0
- package/src/index.ts +10 -0
- package/src/views/Overview.tsx +157 -0
- package/src/views/Progress.tsx +164 -0
- package/src/views/Steps.tsx +63 -0
- package/src/views/Timeline.tsx +114 -0
- package/src/views/index.ts +4 -0
- package/tsconfig.json +10 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/tsdown.config.js +17 -0
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@contractspec/example.learning-journey-ui-coaching",
|
|
3
|
+
"version": "1.44.0",
|
|
4
|
+
"description": "Contextual coaching UI with tip cards and engagement tracking.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./dist/index.js",
|
|
10
|
+
"./CoachingMiniApp": "./dist/CoachingMiniApp.js",
|
|
11
|
+
"./components": "./dist/components/index.js",
|
|
12
|
+
"./components/EngagementMeter": "./dist/components/EngagementMeter.js",
|
|
13
|
+
"./components/TipCard": "./dist/components/TipCard.js",
|
|
14
|
+
"./components/TipFeed": "./dist/components/TipFeed.js",
|
|
15
|
+
"./docs": "./dist/docs/index.js",
|
|
16
|
+
"./docs/learning-journey-ui-coaching.docblock": "./dist/docs/learning-journey-ui-coaching.docblock.js",
|
|
17
|
+
"./example": "./dist/example.js",
|
|
18
|
+
"./views": "./dist/views/index.js",
|
|
19
|
+
"./views/Overview": "./dist/views/Overview.js",
|
|
20
|
+
"./views/Progress": "./dist/views/Progress.js",
|
|
21
|
+
"./views/Steps": "./dist/views/Steps.js",
|
|
22
|
+
"./views/Timeline": "./dist/views/Timeline.js",
|
|
23
|
+
"./*": "./*"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
|
|
27
|
+
"publish:pkg:canary": "bun publish:pkg --tag canary",
|
|
28
|
+
"build": "bun build:types && bun build:bundle",
|
|
29
|
+
"build:bundle": "tsdown",
|
|
30
|
+
"build:types": "tsc --noEmit",
|
|
31
|
+
"dev": "bun build:bundle --watch",
|
|
32
|
+
"clean": "rimraf dist .turbo",
|
|
33
|
+
"lint": "bun lint:fix",
|
|
34
|
+
"lint:fix": "eslint src --fix",
|
|
35
|
+
"lint:check": "eslint src",
|
|
36
|
+
"test": "bun test"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@contractspec/lib.schema": "1.44.0",
|
|
40
|
+
"@contractspec/lib.contracts": "1.44.0",
|
|
41
|
+
"@contractspec/example.learning-journey-ui-shared": "1.44.0",
|
|
42
|
+
"@contractspec/example.learning-journey-ambient-coach": "1.44.0",
|
|
43
|
+
"@contractspec/example.learning-journey-crm-onboarding": "1.44.0",
|
|
44
|
+
"@contractspec/module.learning-journey": "1.44.0",
|
|
45
|
+
"@contractspec/lib.design-system": "1.44.0",
|
|
46
|
+
"@contractspec/lib.ui-kit-web": "1.44.0",
|
|
47
|
+
"react": "19.2.3"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@contractspec/tool.tsdown": "1.44.0",
|
|
51
|
+
"@contractspec/tool.typescript": "1.44.0",
|
|
52
|
+
"@types/react": "^19.1.6",
|
|
53
|
+
"tsdown": "^0.18.3",
|
|
54
|
+
"typescript": "^5.9.3"
|
|
55
|
+
},
|
|
56
|
+
"peerDependencies": {
|
|
57
|
+
"react": "^19.2.3"
|
|
58
|
+
},
|
|
59
|
+
"module": "./dist/index.js",
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"exports": {
|
|
62
|
+
".": "./dist/index.js",
|
|
63
|
+
"./example": "./dist/example.js",
|
|
64
|
+
"./docs": "./dist/docs/index.js",
|
|
65
|
+
"./views": "./dist/views/index.js",
|
|
66
|
+
"./components": "./dist/components/index.js",
|
|
67
|
+
"./*": "./*"
|
|
68
|
+
},
|
|
69
|
+
"registry": "https://registry.npmjs.org/",
|
|
70
|
+
"access": "public"
|
|
71
|
+
},
|
|
72
|
+
"license": "MIT",
|
|
73
|
+
"repository": {
|
|
74
|
+
"type": "git",
|
|
75
|
+
"url": "https://github.com/lssm-tech/contractspec.git",
|
|
76
|
+
"directory": "packages/examples/learning-journey-ui-coaching"
|
|
77
|
+
},
|
|
78
|
+
"homepage": "https://contractspec.io"
|
|
79
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useState, useCallback } from 'react';
|
|
4
|
+
import { Card, CardContent } from '@contractspec/lib.ui-kit-web/ui/card';
|
|
5
|
+
import {
|
|
6
|
+
ViewTabs,
|
|
7
|
+
useLearningProgress,
|
|
8
|
+
type LearningView,
|
|
9
|
+
type LearningMiniAppProps,
|
|
10
|
+
} from '@contractspec/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 CoachingMiniAppProps = Omit<LearningMiniAppProps, 'progress'> & {
|
|
17
|
+
progress?: LearningMiniAppProps['progress'];
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export function CoachingMiniApp({
|
|
21
|
+
track,
|
|
22
|
+
progress: externalProgress,
|
|
23
|
+
onStepComplete: externalOnStepComplete,
|
|
24
|
+
onViewChange,
|
|
25
|
+
initialView = 'overview',
|
|
26
|
+
}: CoachingMiniAppProps) {
|
|
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
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
interface EngagementMeterProps {
|
|
4
|
+
acknowledged: number;
|
|
5
|
+
actioned: number;
|
|
6
|
+
pending: number;
|
|
7
|
+
streak?: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function EngagementMeter({
|
|
11
|
+
acknowledged,
|
|
12
|
+
actioned,
|
|
13
|
+
pending,
|
|
14
|
+
streak = 0,
|
|
15
|
+
}: EngagementMeterProps) {
|
|
16
|
+
const total = acknowledged + actioned + pending;
|
|
17
|
+
const actionedPercent = total > 0 ? (actioned / total) * 100 : 0;
|
|
18
|
+
const acknowledgedPercent = total > 0 ? (acknowledged / total) * 100 : 0;
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<div className="space-y-4">
|
|
22
|
+
{/* Donut chart */}
|
|
23
|
+
<div className="flex items-center justify-center">
|
|
24
|
+
<div className="relative h-32 w-32">
|
|
25
|
+
<svg className="h-full w-full -rotate-90" viewBox="0 0 100 100">
|
|
26
|
+
{/* Background */}
|
|
27
|
+
<circle
|
|
28
|
+
cx="50"
|
|
29
|
+
cy="50"
|
|
30
|
+
r="40"
|
|
31
|
+
fill="none"
|
|
32
|
+
strokeWidth="12"
|
|
33
|
+
className="stroke-muted"
|
|
34
|
+
/>
|
|
35
|
+
{/* Actioned (green) */}
|
|
36
|
+
<circle
|
|
37
|
+
cx="50"
|
|
38
|
+
cy="50"
|
|
39
|
+
r="40"
|
|
40
|
+
fill="none"
|
|
41
|
+
strokeWidth="12"
|
|
42
|
+
strokeLinecap="round"
|
|
43
|
+
strokeDasharray={`${actionedPercent * 2.51} 251`}
|
|
44
|
+
className="stroke-green-500 transition-all duration-500"
|
|
45
|
+
/>
|
|
46
|
+
{/* Acknowledged (amber) - offset by actioned */}
|
|
47
|
+
<circle
|
|
48
|
+
cx="50"
|
|
49
|
+
cy="50"
|
|
50
|
+
r="40"
|
|
51
|
+
fill="none"
|
|
52
|
+
strokeWidth="12"
|
|
53
|
+
strokeLinecap="round"
|
|
54
|
+
strokeDasharray={`${acknowledgedPercent * 2.51} 251`}
|
|
55
|
+
strokeDashoffset={`${-actionedPercent * 2.51}`}
|
|
56
|
+
className="stroke-amber-500 transition-all duration-500"
|
|
57
|
+
/>
|
|
58
|
+
</svg>
|
|
59
|
+
<div className="absolute inset-0 flex flex-col items-center justify-center">
|
|
60
|
+
<span className="text-2xl font-bold">{total}</span>
|
|
61
|
+
<span className="text-muted-foreground text-xs">tips</span>
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
{/* Legend */}
|
|
67
|
+
<div className="flex justify-center gap-4 text-sm">
|
|
68
|
+
<div className="flex items-center gap-1.5">
|
|
69
|
+
<div className="h-3 w-3 rounded-full bg-green-500" />
|
|
70
|
+
<span>Actioned ({actioned})</span>
|
|
71
|
+
</div>
|
|
72
|
+
<div className="flex items-center gap-1.5">
|
|
73
|
+
<div className="h-3 w-3 rounded-full bg-amber-500" />
|
|
74
|
+
<span>Acknowledged ({acknowledged})</span>
|
|
75
|
+
</div>
|
|
76
|
+
<div className="flex items-center gap-1.5">
|
|
77
|
+
<div className="bg-muted h-3 w-3 rounded-full" />
|
|
78
|
+
<span>Pending ({pending})</span>
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
|
|
82
|
+
{/* Streak */}
|
|
83
|
+
{streak > 0 && (
|
|
84
|
+
<div className="flex items-center justify-center gap-2 rounded-lg bg-orange-500/10 px-4 py-2">
|
|
85
|
+
<span className="text-xl">🔥</span>
|
|
86
|
+
<span className="font-semibold text-orange-500">
|
|
87
|
+
{streak} day engagement streak!
|
|
88
|
+
</span>
|
|
89
|
+
</div>
|
|
90
|
+
)}
|
|
91
|
+
</div>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Button } from '@contractspec/lib.design-system';
|
|
4
|
+
import { Card, CardContent } from '@contractspec/lib.ui-kit-web/ui/card';
|
|
5
|
+
import { cn } from '@contractspec/lib.ui-kit-web/ui/utils';
|
|
6
|
+
import type { LearningJourneyStepSpec } from '@contractspec/module.learning-journey/track-spec';
|
|
7
|
+
|
|
8
|
+
interface TipCardProps {
|
|
9
|
+
step: LearningJourneyStepSpec;
|
|
10
|
+
isCompleted: boolean;
|
|
11
|
+
isCurrent: boolean;
|
|
12
|
+
onComplete?: () => void;
|
|
13
|
+
onDismiss?: () => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const TIP_ICONS: Record<string, string> = {
|
|
17
|
+
cash_buffer_too_high: '💰',
|
|
18
|
+
no_savings_goal: '🎯',
|
|
19
|
+
irregular_savings: '📅',
|
|
20
|
+
noise_late_evening: '🔇',
|
|
21
|
+
guest_frequency_high: '👥',
|
|
22
|
+
shared_space_conflicts: '🏠',
|
|
23
|
+
default: '💡',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export function TipCard({
|
|
27
|
+
step,
|
|
28
|
+
isCompleted,
|
|
29
|
+
isCurrent,
|
|
30
|
+
onComplete,
|
|
31
|
+
onDismiss,
|
|
32
|
+
}: TipCardProps) {
|
|
33
|
+
const tipId = (step.metadata?.tipId as string) ?? 'default';
|
|
34
|
+
const icon = TIP_ICONS[tipId] ?? TIP_ICONS.default;
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<Card
|
|
38
|
+
className={cn(
|
|
39
|
+
'transition-all',
|
|
40
|
+
isCompleted && 'opacity-60',
|
|
41
|
+
isCurrent && 'ring-2 ring-amber-500'
|
|
42
|
+
)}
|
|
43
|
+
>
|
|
44
|
+
<CardContent className="p-4">
|
|
45
|
+
<div className="flex gap-4">
|
|
46
|
+
{/* Icon */}
|
|
47
|
+
<div
|
|
48
|
+
className={cn(
|
|
49
|
+
'flex h-12 w-12 shrink-0 items-center justify-center rounded-xl text-2xl',
|
|
50
|
+
isCompleted
|
|
51
|
+
? 'bg-green-500/10'
|
|
52
|
+
: isCurrent
|
|
53
|
+
? 'bg-amber-500/10'
|
|
54
|
+
: 'bg-muted'
|
|
55
|
+
)}
|
|
56
|
+
>
|
|
57
|
+
{isCompleted ? '✓' : icon}
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
{/* Content */}
|
|
61
|
+
<div className="min-w-0 flex-1">
|
|
62
|
+
<div className="flex items-start justify-between gap-2">
|
|
63
|
+
<h4 className="font-semibold">{step.title}</h4>
|
|
64
|
+
{step.xpReward && (
|
|
65
|
+
<span
|
|
66
|
+
className={cn(
|
|
67
|
+
'shrink-0 rounded-full px-2 py-0.5 text-xs font-semibold',
|
|
68
|
+
isCompleted
|
|
69
|
+
? 'bg-green-500/10 text-green-500'
|
|
70
|
+
: 'bg-amber-500/10 text-amber-500'
|
|
71
|
+
)}
|
|
72
|
+
>
|
|
73
|
+
+{step.xpReward} XP
|
|
74
|
+
</span>
|
|
75
|
+
)}
|
|
76
|
+
</div>
|
|
77
|
+
<p className="text-muted-foreground mt-1 text-sm">
|
|
78
|
+
{step.description}
|
|
79
|
+
</p>
|
|
80
|
+
|
|
81
|
+
{/* Actions */}
|
|
82
|
+
{!isCompleted && (
|
|
83
|
+
<div className="mt-3 flex flex-wrap gap-2">
|
|
84
|
+
<Button size="sm" onClick={onComplete}>
|
|
85
|
+
Take Action
|
|
86
|
+
</Button>
|
|
87
|
+
<Button variant="outline" size="sm" onClick={onDismiss}>
|
|
88
|
+
Dismiss
|
|
89
|
+
</Button>
|
|
90
|
+
</div>
|
|
91
|
+
)}
|
|
92
|
+
|
|
93
|
+
{isCompleted && (
|
|
94
|
+
<p className="mt-2 text-sm text-green-500">✓ Tip acknowledged</p>
|
|
95
|
+
)}
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
</CardContent>
|
|
99
|
+
</Card>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { cn } from '@contractspec/lib.ui-kit-web/ui/utils';
|
|
4
|
+
import type { LearningJourneyStepSpec } from '@contractspec/module.learning-journey/track-spec';
|
|
5
|
+
|
|
6
|
+
interface TipFeedItem {
|
|
7
|
+
step: LearningJourneyStepSpec;
|
|
8
|
+
isCompleted: boolean;
|
|
9
|
+
completedAt?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface TipFeedProps {
|
|
13
|
+
items: TipFeedItem[];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const TIP_ICONS: Record<string, string> = {
|
|
17
|
+
cash_buffer_too_high: '💰',
|
|
18
|
+
no_savings_goal: '🎯',
|
|
19
|
+
irregular_savings: '📅',
|
|
20
|
+
noise_late_evening: '🔇',
|
|
21
|
+
guest_frequency_high: '👥',
|
|
22
|
+
shared_space_conflicts: '🏠',
|
|
23
|
+
default: '💡',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export function TipFeed({ items }: TipFeedProps) {
|
|
27
|
+
if (items.length === 0) {
|
|
28
|
+
return (
|
|
29
|
+
<div className="text-muted-foreground py-8 text-center">
|
|
30
|
+
No tips yet. Start engaging with coaching tips!
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<div className="relative">
|
|
37
|
+
{/* Timeline line */}
|
|
38
|
+
<div className="bg-border absolute top-0 left-4 h-full w-0.5" />
|
|
39
|
+
|
|
40
|
+
{/* Feed items */}
|
|
41
|
+
<div className="space-y-4">
|
|
42
|
+
{items.map((item) => {
|
|
43
|
+
const tipId = (item.step.metadata?.tipId as string) ?? 'default';
|
|
44
|
+
const icon = TIP_ICONS[tipId] ?? TIP_ICONS.default;
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<div key={item.step.id} className="relative flex gap-4 pl-2">
|
|
48
|
+
{/* Node */}
|
|
49
|
+
<div
|
|
50
|
+
className={cn(
|
|
51
|
+
'relative z-10 flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-sm',
|
|
52
|
+
item.isCompleted
|
|
53
|
+
? 'bg-green-500 text-white'
|
|
54
|
+
: 'bg-muted text-muted-foreground'
|
|
55
|
+
)}
|
|
56
|
+
>
|
|
57
|
+
{item.isCompleted ? '✓' : icon}
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
{/* Content */}
|
|
61
|
+
<div className="bg-card flex-1 rounded-lg border p-3">
|
|
62
|
+
<div className="flex items-start justify-between gap-2">
|
|
63
|
+
<div>
|
|
64
|
+
<p className="font-medium">{item.step.title}</p>
|
|
65
|
+
<p className="text-muted-foreground mt-0.5 text-sm">
|
|
66
|
+
{item.step.description}
|
|
67
|
+
</p>
|
|
68
|
+
</div>
|
|
69
|
+
{item.step.xpReward && (
|
|
70
|
+
<span
|
|
71
|
+
className={cn(
|
|
72
|
+
'shrink-0 text-xs font-medium',
|
|
73
|
+
item.isCompleted
|
|
74
|
+
? 'text-green-500'
|
|
75
|
+
: 'text-muted-foreground'
|
|
76
|
+
)}
|
|
77
|
+
>
|
|
78
|
+
+{item.step.xpReward} XP
|
|
79
|
+
</span>
|
|
80
|
+
)}
|
|
81
|
+
</div>
|
|
82
|
+
|
|
83
|
+
{/* Timestamp */}
|
|
84
|
+
<div className="text-muted-foreground mt-2 flex items-center gap-2 text-xs">
|
|
85
|
+
{item.isCompleted ? (
|
|
86
|
+
<span className="text-green-500">
|
|
87
|
+
✓ Completed
|
|
88
|
+
{item.completedAt && ` • ${item.completedAt}`}
|
|
89
|
+
</span>
|
|
90
|
+
) : (
|
|
91
|
+
<span>Pending action</span>
|
|
92
|
+
)}
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
);
|
|
97
|
+
})}
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './learning-journey-ui-coaching.docblock';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { DocBlock } from '@contractspec/lib.contracts/docs';
|
|
2
|
+
import { registerDocBlocks } from '@contractspec/lib.contracts/docs';
|
|
3
|
+
|
|
4
|
+
const blocks: DocBlock[] = [
|
|
5
|
+
{
|
|
6
|
+
id: 'docs.examples.learning-journey-ui-coaching',
|
|
7
|
+
title: 'Learning Journey UI — Coaching',
|
|
8
|
+
summary: 'UI mini-app components for coaching: tips, engagement, progress.',
|
|
9
|
+
kind: 'reference',
|
|
10
|
+
visibility: 'public',
|
|
11
|
+
route: '/docs/examples/learning-journey-ui-coaching',
|
|
12
|
+
tags: ['learning', 'ui', 'coaching'],
|
|
13
|
+
body: `## Includes\n- Coaching mini-app shell\n- Views: overview, steps, progress, timeline\n- Components: tip card, engagement meter, tip feed\n\n## Notes\n- Compose using design system components.\n- Keep accessibility and mobile-friendly tap targets.`,
|
|
14
|
+
},
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
registerDocBlocks(blocks);
|
package/src/example.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const example = {
|
|
2
|
+
id: 'learning-journey-ui-coaching',
|
|
3
|
+
title: 'Learning Journey UI — Coaching',
|
|
4
|
+
summary:
|
|
5
|
+
'UI mini-app for coaching patterns: tips, engagement meter, progress.',
|
|
6
|
+
tags: ['learning', 'ui', 'coaching'],
|
|
7
|
+
kind: 'ui',
|
|
8
|
+
visibility: 'public',
|
|
9
|
+
docs: {
|
|
10
|
+
rootDocId: 'docs.examples.learning-journey-ui-coaching',
|
|
11
|
+
},
|
|
12
|
+
entrypoints: {
|
|
13
|
+
packageName: '@contractspec/example.learning-journey-ui-coaching',
|
|
14
|
+
docs: './docs',
|
|
15
|
+
},
|
|
16
|
+
surfaces: {
|
|
17
|
+
templates: true,
|
|
18
|
+
sandbox: { enabled: true, modes: ['playground', 'markdown'] },
|
|
19
|
+
studio: { enabled: true, installable: true },
|
|
20
|
+
mcp: { enabled: true },
|
|
21
|
+
},
|
|
22
|
+
} as const;
|
|
23
|
+
|
|
24
|
+
export default example;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Main mini-app
|
|
2
|
+
export { CoachingMiniApp } from './CoachingMiniApp';
|
|
3
|
+
|
|
4
|
+
// Views
|
|
5
|
+
export { Overview, Steps, Progress, Timeline } from './views';
|
|
6
|
+
|
|
7
|
+
// Components
|
|
8
|
+
export { TipCard, EngagementMeter, TipFeed } from './components';
|
|
9
|
+
export { default as example } from './example';
|
|
10
|
+
import './docs';
|
|
@@ -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
|
+
}
|