@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.
- package/.turbo/turbo-build$colon$bundle.log +57 -0
- package/.turbo/turbo-build.log +58 -0
- package/CHANGELOG.md +466 -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 +7 -0
- package/dist/example.d.ts.map +1 -0
- package/dist/example.js +42 -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 +76 -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 +31 -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,76 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@contractspec/example.learning-journey-ui-coaching",
|
|
3
|
+
"version": "0.0.0-canary-20260113170453",
|
|
4
|
+
"description": "Contextual coaching UI with tip cards and engagement tracking.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./dist/index.js",
|
|
9
|
+
"./CoachingMiniApp": "./dist/CoachingMiniApp.js",
|
|
10
|
+
"./components": "./dist/components/index.js",
|
|
11
|
+
"./components/EngagementMeter": "./dist/components/EngagementMeter.js",
|
|
12
|
+
"./components/TipCard": "./dist/components/TipCard.js",
|
|
13
|
+
"./components/TipFeed": "./dist/components/TipFeed.js",
|
|
14
|
+
"./docs": "./dist/docs/index.js",
|
|
15
|
+
"./docs/learning-journey-ui-coaching.docblock": "./dist/docs/learning-journey-ui-coaching.docblock.js",
|
|
16
|
+
"./example": "./dist/example.js",
|
|
17
|
+
"./views": "./dist/views/index.js",
|
|
18
|
+
"./views/Overview": "./dist/views/Overview.js",
|
|
19
|
+
"./views/Progress": "./dist/views/Progress.js",
|
|
20
|
+
"./views/Steps": "./dist/views/Steps.js",
|
|
21
|
+
"./views/Timeline": "./dist/views/Timeline.js",
|
|
22
|
+
"./*": "./*"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
|
|
26
|
+
"publish:pkg:canary": "bun publish:pkg --tag canary",
|
|
27
|
+
"build": "bun build:types && bun build:bundle",
|
|
28
|
+
"build:bundle": "tsdown",
|
|
29
|
+
"build:types": "tsc --noEmit",
|
|
30
|
+
"dev": "bun build:bundle --watch",
|
|
31
|
+
"clean": "rimraf dist .turbo",
|
|
32
|
+
"lint": "bun lint:fix",
|
|
33
|
+
"lint:fix": "eslint src --fix",
|
|
34
|
+
"lint:check": "eslint src",
|
|
35
|
+
"test": "bun test"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@contractspec/lib.contracts": "0.0.0-canary-20260113170453",
|
|
39
|
+
"@contractspec/example.learning-journey-ui-shared": "0.0.0-canary-20260113170453",
|
|
40
|
+
"@contractspec/example.learning-journey-ambient-coach": "0.0.0-canary-20260113170453",
|
|
41
|
+
"@contractspec/example.learning-journey-crm-onboarding": "0.0.0-canary-20260113170453",
|
|
42
|
+
"@contractspec/module.learning-journey": "0.0.0-canary-20260113170453",
|
|
43
|
+
"@contractspec/lib.design-system": "0.0.0-canary-20260113170453",
|
|
44
|
+
"@contractspec/lib.ui-kit-web": "0.0.0-canary-20260113170453",
|
|
45
|
+
"react": "19.2.3"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@contractspec/tool.tsdown": "0.0.0-canary-20260113170453",
|
|
49
|
+
"@contractspec/tool.typescript": "0.0.0-canary-20260113170453",
|
|
50
|
+
"@types/react": "^19.2.8",
|
|
51
|
+
"tsdown": "^0.19.0",
|
|
52
|
+
"typescript": "^5.9.3"
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"react": "^19.2.3"
|
|
56
|
+
},
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"exports": {
|
|
59
|
+
".": "./dist/index.js",
|
|
60
|
+
"./example": "./dist/example.js",
|
|
61
|
+
"./docs": "./dist/docs/index.js",
|
|
62
|
+
"./views": "./dist/views/index.js",
|
|
63
|
+
"./components": "./dist/components/index.js",
|
|
64
|
+
"./*": "./*"
|
|
65
|
+
},
|
|
66
|
+
"registry": "https://registry.npmjs.org/",
|
|
67
|
+
"access": "public"
|
|
68
|
+
},
|
|
69
|
+
"license": "MIT",
|
|
70
|
+
"repository": {
|
|
71
|
+
"type": "git",
|
|
72
|
+
"url": "https://github.com/lssm-tech/contractspec.git",
|
|
73
|
+
"directory": "packages/examples/learning-journey-ui-coaching"
|
|
74
|
+
},
|
|
75
|
+
"homepage": "https://contractspec.io"
|
|
76
|
+
}
|
|
@@ -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,31 @@
|
|
|
1
|
+
import { defineExample } from '@contractspec/lib.contracts';
|
|
2
|
+
|
|
3
|
+
const example = defineExample({
|
|
4
|
+
meta: {
|
|
5
|
+
key: 'learning-journey-ui-coaching',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
title: 'Learning Journey UI — Coaching',
|
|
8
|
+
description:
|
|
9
|
+
'UI mini-app for coaching patterns: tips, engagement meter, progress.',
|
|
10
|
+
kind: 'ui',
|
|
11
|
+
visibility: 'public',
|
|
12
|
+
stability: 'experimental',
|
|
13
|
+
owners: ['@platform.core'],
|
|
14
|
+
tags: ['learning', 'ui', 'coaching'],
|
|
15
|
+
},
|
|
16
|
+
docs: {
|
|
17
|
+
rootDocId: 'docs.examples.learning-journey-ui-coaching',
|
|
18
|
+
},
|
|
19
|
+
entrypoints: {
|
|
20
|
+
packageName: '@contractspec/example.learning-journey-ui-coaching',
|
|
21
|
+
docs: './docs',
|
|
22
|
+
},
|
|
23
|
+
surfaces: {
|
|
24
|
+
templates: true,
|
|
25
|
+
sandbox: { enabled: true, modes: ['playground', 'markdown'] },
|
|
26
|
+
studio: { enabled: true, installable: true },
|
|
27
|
+
mcp: { enabled: true },
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
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';
|