@contractspec/example.learning-journey-ui-onboarding 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.
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 +278 -0
  4. package/LICENSE +21 -0
  5. package/README.md +35 -0
  6. package/dist/OnboardingMiniApp.d.ts +17 -0
  7. package/dist/OnboardingMiniApp.d.ts.map +1 -0
  8. package/dist/OnboardingMiniApp.js +63 -0
  9. package/dist/OnboardingMiniApp.js.map +1 -0
  10. package/dist/components/CodeSnippet.d.ts +16 -0
  11. package/dist/components/CodeSnippet.d.ts.map +1 -0
  12. package/dist/components/CodeSnippet.js +50 -0
  13. package/dist/components/CodeSnippet.js.map +1 -0
  14. package/dist/components/JourneyMap.d.ts +17 -0
  15. package/dist/components/JourneyMap.d.ts.map +1 -0
  16. package/dist/components/JourneyMap.js +49 -0
  17. package/dist/components/JourneyMap.js.map +1 -0
  18. package/dist/components/StepChecklist.d.ts +25 -0
  19. package/dist/components/StepChecklist.d.ts.map +1 -0
  20. package/dist/components/StepChecklist.js +80 -0
  21. package/dist/components/StepChecklist.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-onboarding.docblock.d.ts +1 -0
  27. package/dist/docs/learning-journey-ui-onboarding.docblock.js +20 -0
  28. package/dist/docs/learning-journey-ui-onboarding.docblock.js.map +1 -0
  29. package/dist/example.d.ts +33 -0
  30. package/dist/example.d.ts.map +1 -0
  31. package/dist/example.js +35 -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 +15 -0
  36. package/dist/views/Overview.d.ts.map +1 -0
  37. package/dist/views/Overview.js +180 -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 +161 -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 +92 -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 +98 -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 +80 -0
  55. package/src/OnboardingMiniApp.tsx +93 -0
  56. package/src/components/CodeSnippet.tsx +56 -0
  57. package/src/components/JourneyMap.tsx +86 -0
  58. package/src/components/StepChecklist.tsx +136 -0
  59. package/src/components/index.ts +3 -0
  60. package/src/docs/index.ts +1 -0
  61. package/src/docs/learning-journey-ui-onboarding.docblock.ts +18 -0
  62. package/src/example.ts +24 -0
  63. package/src/index.ts +10 -0
  64. package/src/views/Overview.tsx +204 -0
  65. package/src/views/Progress.tsx +186 -0
  66. package/src/views/Steps.tsx +92 -0
  67. package/src/views/Timeline.tsx +141 -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,56 @@
1
+ 'use client';
2
+
3
+ import { useState } from 'react';
4
+ import { Button } from '@contractspec/lib.design-system';
5
+
6
+ interface CodeSnippetProps {
7
+ code: string;
8
+ language?: string;
9
+ title?: string;
10
+ }
11
+
12
+ export function CodeSnippet({
13
+ code,
14
+ language = 'typescript',
15
+ title,
16
+ }: CodeSnippetProps) {
17
+ const [copied, setCopied] = useState(false);
18
+
19
+ const handleCopy = async () => {
20
+ await navigator.clipboard.writeText(code);
21
+ setCopied(true);
22
+ setTimeout(() => setCopied(false), 2000);
23
+ };
24
+
25
+ return (
26
+ <div className="bg-muted/50 overflow-hidden rounded-lg border">
27
+ {/* Header */}
28
+ <div className="bg-muted flex items-center justify-between border-b px-4 py-2">
29
+ <div className="flex items-center gap-2">
30
+ <span className="text-muted-foreground text-xs font-medium uppercase">
31
+ {language}
32
+ </span>
33
+ {title && (
34
+ <>
35
+ <span className="text-muted-foreground">•</span>
36
+ <span className="text-sm">{title}</span>
37
+ </>
38
+ )}
39
+ </div>
40
+ <Button
41
+ variant="ghost"
42
+ size="sm"
43
+ onClick={handleCopy}
44
+ className="h-7 text-xs"
45
+ >
46
+ {copied ? '✓ Copied' : 'Copy'}
47
+ </Button>
48
+ </div>
49
+
50
+ {/* Code */}
51
+ <pre className="overflow-x-auto p-4">
52
+ <code className="text-sm">{code}</code>
53
+ </pre>
54
+ </div>
55
+ );
56
+ }
@@ -0,0 +1,86 @@
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 JourneyMapProps {
7
+ steps: LearningJourneyStepSpec[];
8
+ completedStepIds: string[];
9
+ currentStepId?: string | null;
10
+ }
11
+
12
+ const SURFACE_ICONS: Record<string, string> = {
13
+ templates: '📋',
14
+ 'spec-editor': '✏️',
15
+ regenerator: '🔄',
16
+ playground: '🎮',
17
+ evolution: '🤖',
18
+ dashboard: '📊',
19
+ settings: '⚙️',
20
+ default: '📍',
21
+ };
22
+
23
+ export function JourneyMap({
24
+ steps,
25
+ completedStepIds,
26
+ currentStepId,
27
+ }: JourneyMapProps) {
28
+ return (
29
+ <div className="relative overflow-x-auto pb-4">
30
+ <div className="flex min-w-max items-center gap-2">
31
+ {steps.map((step, index) => {
32
+ const isCompleted = completedStepIds.includes(step.id);
33
+ const isCurrent = step.id === currentStepId;
34
+ const surface = (step.metadata?.surface as string) ?? 'default';
35
+ const icon = SURFACE_ICONS[surface] ?? SURFACE_ICONS.default;
36
+
37
+ return (
38
+ <div key={step.id} className="flex items-center">
39
+ {/* Node */}
40
+ <div className="flex flex-col items-center gap-2">
41
+ <div
42
+ className={cn(
43
+ 'flex h-14 w-14 items-center justify-center rounded-2xl border-2 text-2xl transition-all',
44
+ isCompleted && 'border-green-500 bg-green-500/10',
45
+ isCurrent &&
46
+ !isCompleted &&
47
+ 'border-violet-500 bg-violet-500/10 ring-4 ring-violet-500/20',
48
+ !isCompleted && !isCurrent && 'border-muted bg-muted/50'
49
+ )}
50
+ >
51
+ {isCompleted ? '✓' : icon}
52
+ </div>
53
+ <div className="text-center">
54
+ <p
55
+ className={cn(
56
+ 'max-w-[100px] truncate text-xs font-medium',
57
+ isCompleted && 'text-green-500',
58
+ isCurrent && !isCompleted && 'text-violet-500',
59
+ !isCompleted && !isCurrent && 'text-muted-foreground'
60
+ )}
61
+ >
62
+ {step.title}
63
+ </p>
64
+ </div>
65
+ </div>
66
+
67
+ {/* Connector */}
68
+ {index < steps.length - 1 && (
69
+ <div
70
+ className={cn(
71
+ 'mx-2 h-1 w-8 rounded-full transition-colors',
72
+ completedStepIds.includes(steps[index + 1]?.id ?? '')
73
+ ? 'bg-green-500'
74
+ : isCompleted
75
+ ? 'bg-green-500/50'
76
+ : 'bg-muted'
77
+ )}
78
+ />
79
+ )}
80
+ </div>
81
+ );
82
+ })}
83
+ </div>
84
+ </div>
85
+ );
86
+ }
@@ -0,0 +1,136 @@
1
+ 'use client';
2
+
3
+ import { Button } from '@contractspec/lib.design-system';
4
+ import { cn } from '@contractspec/lib.ui-kit-core';
5
+ import type { LearningJourneyStepSpec } from '@contractspec/module.learning-journey/track-spec';
6
+
7
+ interface StepChecklistProps {
8
+ step: LearningJourneyStepSpec;
9
+ stepNumber: number;
10
+ isCompleted: boolean;
11
+ isCurrent: boolean;
12
+ isExpanded: boolean;
13
+ onToggle: () => void;
14
+ onComplete?: () => void;
15
+ }
16
+
17
+ export function StepChecklist({
18
+ step,
19
+ stepNumber,
20
+ isCompleted,
21
+ isCurrent,
22
+ isExpanded,
23
+ onToggle,
24
+ onComplete,
25
+ }: StepChecklistProps) {
26
+ return (
27
+ <div
28
+ className={cn(
29
+ 'rounded-xl border transition-all',
30
+ isCompleted && 'border-green-500/50 bg-green-500/5',
31
+ isCurrent && !isCompleted && 'border-violet-500 bg-violet-500/5',
32
+ !isCompleted && !isCurrent && 'border-border'
33
+ )}
34
+ >
35
+ {/* Header */}
36
+ <button
37
+ type="button"
38
+ className="flex w-full items-center gap-4 p-4 text-left"
39
+ onClick={onToggle}
40
+ >
41
+ {/* Checkbox/Number */}
42
+ <div
43
+ className={cn(
44
+ 'flex h-8 w-8 shrink-0 items-center justify-center rounded-full border-2 text-sm font-semibold transition-colors',
45
+ isCompleted && 'border-green-500 bg-green-500 text-white',
46
+ isCurrent && !isCompleted && 'border-violet-500 text-violet-500',
47
+ !isCompleted &&
48
+ !isCurrent &&
49
+ 'border-muted-foreground text-muted-foreground'
50
+ )}
51
+ >
52
+ {isCompleted ? '✓' : stepNumber}
53
+ </div>
54
+
55
+ {/* Title & Description */}
56
+ <div className="min-w-0 flex-1">
57
+ <h4
58
+ className={cn(
59
+ 'font-semibold',
60
+ isCompleted && 'text-green-500',
61
+ isCurrent && !isCompleted && 'text-foreground',
62
+ !isCompleted && !isCurrent && 'text-muted-foreground'
63
+ )}
64
+ >
65
+ {step.title}
66
+ </h4>
67
+ {!isExpanded && step.description && (
68
+ <p className="text-muted-foreground truncate text-sm">
69
+ {step.description}
70
+ </p>
71
+ )}
72
+ </div>
73
+
74
+ {/* XP Badge */}
75
+ {step.xpReward && (
76
+ <span
77
+ className={cn(
78
+ 'shrink-0 rounded-full px-2 py-1 text-xs font-semibold',
79
+ isCompleted
80
+ ? 'bg-green-500/10 text-green-500'
81
+ : 'bg-muted text-muted-foreground'
82
+ )}
83
+ >
84
+ +{step.xpReward} XP
85
+ </span>
86
+ )}
87
+
88
+ {/* Expand indicator */}
89
+ <span
90
+ className={cn(
91
+ 'shrink-0 transition-transform',
92
+ isExpanded && 'rotate-180'
93
+ )}
94
+ >
95
+
96
+ </span>
97
+ </button>
98
+
99
+ {/* Expanded Content */}
100
+ {isExpanded && (
101
+ <div className="border-t px-4 py-4">
102
+ {step.description && (
103
+ <p className="text-muted-foreground mb-4">{step.description}</p>
104
+ )}
105
+
106
+ {step.instructions && (
107
+ <div className="bg-muted mb-4 rounded-lg p-4">
108
+ <p className="mb-2 text-sm font-medium">Instructions:</p>
109
+ <p className="text-muted-foreground text-sm">
110
+ {step.instructions}
111
+ </p>
112
+ </div>
113
+ )}
114
+
115
+ {/* Action buttons */}
116
+ <div className="flex flex-wrap gap-2">
117
+ {step.actionUrl && (
118
+ <Button
119
+ variant="outline"
120
+ size="sm"
121
+ onClick={() => window.open(step.actionUrl, '_blank')}
122
+ >
123
+ {step.actionLabel ?? 'Try it'}
124
+ </Button>
125
+ )}
126
+ {!isCompleted && (
127
+ <Button size="sm" onClick={onComplete}>
128
+ Mark as Complete
129
+ </Button>
130
+ )}
131
+ </div>
132
+ </div>
133
+ )}
134
+ </div>
135
+ );
136
+ }
@@ -0,0 +1,3 @@
1
+ export { StepChecklist } from './StepChecklist';
2
+ export { CodeSnippet } from './CodeSnippet';
3
+ export { JourneyMap } from './JourneyMap';
@@ -0,0 +1 @@
1
+ import './learning-journey-ui-onboarding.docblock';
@@ -0,0 +1,18 @@
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-onboarding',
7
+ title: 'Learning Journey UI — Onboarding',
8
+ summary:
9
+ 'UI mini-app components for onboarding: checklists, snippets, and journey mapping.',
10
+ kind: 'reference',
11
+ visibility: 'public',
12
+ route: '/docs/examples/learning-journey-ui-onboarding',
13
+ tags: ['learning', 'ui', 'onboarding'],
14
+ body: `## Includes\n- Onboarding mini-app shell\n- Views: overview, steps, progress, timeline\n- Components: step checklist, code snippet, journey map\n\n## Notes\n- Compose with design system components.\n- Ensure accessible labels and keyboard navigation.`,
15
+ },
16
+ ];
17
+
18
+ registerDocBlocks(blocks);
package/src/example.ts ADDED
@@ -0,0 +1,24 @@
1
+ const example = {
2
+ id: 'learning-journey-ui-onboarding',
3
+ title: 'Learning Journey UI — Onboarding',
4
+ summary:
5
+ 'UI mini-app for onboarding patterns: checklists, code snippets, journey map.',
6
+ tags: ['learning', 'ui', 'onboarding'],
7
+ kind: 'ui',
8
+ visibility: 'public',
9
+ docs: {
10
+ rootDocId: 'docs.examples.learning-journey-ui-onboarding',
11
+ },
12
+ entrypoints: {
13
+ packageName: '@contractspec/example.learning-journey-ui-onboarding',
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 { OnboardingMiniApp } from './OnboardingMiniApp';
3
+
4
+ // Views
5
+ export { Overview, Steps, Progress, Timeline } from './views';
6
+
7
+ // Components
8
+ export { StepChecklist, CodeSnippet, JourneyMap } from './components';
9
+ export { default as example } from './example';
10
+ import './docs';
@@ -0,0 +1,204 @@
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 { Progress } from '@contractspec/lib.ui-kit-web/ui/progress';
11
+ import { XpBar } from '@contractspec/example.learning-journey-ui-shared';
12
+ import type { LearningViewProps } from '@contractspec/example.learning-journey-ui-shared';
13
+
14
+ interface OnboardingOverviewProps extends LearningViewProps {
15
+ onStart?: () => void;
16
+ }
17
+
18
+ export function Overview({
19
+ track,
20
+ progress,
21
+ onStart,
22
+ }: OnboardingOverviewProps) {
23
+ const totalSteps = track.steps.length;
24
+ const completedSteps = progress.completedStepIds.length;
25
+ const percentComplete =
26
+ totalSteps > 0 ? (completedSteps / totalSteps) * 100 : 0;
27
+ const isComplete = completedSteps === totalSteps;
28
+
29
+ // Estimate time remaining (rough: 5 min per step)
30
+ const remainingSteps = totalSteps - completedSteps;
31
+ const estimatedMinutes = remainingSteps * 5;
32
+
33
+ const totalXp =
34
+ track.totalXp ??
35
+ track.steps.reduce((sum, s) => sum + (s.xpReward ?? 0), 0) +
36
+ (track.completionRewards?.xpBonus ?? 0);
37
+
38
+ return (
39
+ <div className="space-y-6">
40
+ {/* Welcome Banner */}
41
+ <Card className="overflow-hidden bg-gradient-to-r from-blue-500/10 via-violet-500/10 to-purple-500/10">
42
+ <CardContent className="p-8">
43
+ <div className="flex flex-col items-center gap-6 text-center md:flex-row md:text-left">
44
+ <div className="flex h-20 w-20 items-center justify-center rounded-2xl bg-gradient-to-br from-blue-500 to-violet-600 text-4xl shadow-lg">
45
+ {isComplete ? '🎉' : '🚀'}
46
+ </div>
47
+ <div className="flex-1">
48
+ <h1 className="text-2xl font-bold">{track.name}</h1>
49
+ <p className="text-muted-foreground mt-1 max-w-2xl">
50
+ {track.description}
51
+ </p>
52
+ {!isComplete && (
53
+ <p className="text-muted-foreground mt-3 text-sm">
54
+ ⏱️ Estimated time:{' '}
55
+ {estimatedMinutes > 0
56
+ ? `~${estimatedMinutes} minutes`
57
+ : 'Less than a minute'}
58
+ </p>
59
+ )}
60
+ </div>
61
+ {!isComplete && (
62
+ <Button size="lg" onClick={onStart}>
63
+ {completedSteps > 0 ? 'Continue' : 'Get Started'}
64
+ </Button>
65
+ )}
66
+ </div>
67
+ </CardContent>
68
+ </Card>
69
+
70
+ {/* Progress Overview */}
71
+ <div className="grid gap-4 md:grid-cols-3">
72
+ <Card>
73
+ <CardHeader className="pb-2">
74
+ <CardTitle className="text-muted-foreground text-sm font-medium">
75
+ Progress
76
+ </CardTitle>
77
+ </CardHeader>
78
+ <CardContent>
79
+ <div className="text-3xl font-bold">
80
+ {Math.round(percentComplete)}%
81
+ </div>
82
+ <Progress value={percentComplete} className="mt-2 h-2" />
83
+ <p className="text-muted-foreground mt-2 text-sm">
84
+ {completedSteps} of {totalSteps} steps completed
85
+ </p>
86
+ </CardContent>
87
+ </Card>
88
+
89
+ <Card>
90
+ <CardHeader className="pb-2">
91
+ <CardTitle className="text-muted-foreground text-sm font-medium">
92
+ XP Earned
93
+ </CardTitle>
94
+ </CardHeader>
95
+ <CardContent>
96
+ <div className="text-3xl font-bold text-blue-500">
97
+ {progress.xpEarned}
98
+ </div>
99
+ <XpBar
100
+ current={progress.xpEarned}
101
+ max={totalXp}
102
+ showLabel={false}
103
+ size="sm"
104
+ />
105
+ </CardContent>
106
+ </Card>
107
+
108
+ <Card>
109
+ <CardHeader className="pb-2">
110
+ <CardTitle className="text-muted-foreground text-sm font-medium">
111
+ Time Remaining
112
+ </CardTitle>
113
+ </CardHeader>
114
+ <CardContent>
115
+ <div className="text-3xl font-bold">
116
+ {isComplete ? '✓' : `~${estimatedMinutes}m`}
117
+ </div>
118
+ <p className="text-muted-foreground mt-2 text-sm">
119
+ {isComplete ? 'All done!' : `${remainingSteps} steps to go`}
120
+ </p>
121
+ </CardContent>
122
+ </Card>
123
+ </div>
124
+
125
+ {/* Step Preview */}
126
+ <Card>
127
+ <CardHeader>
128
+ <CardTitle className="flex items-center gap-2">
129
+ <span>📋</span>
130
+ <span>Your Journey</span>
131
+ </CardTitle>
132
+ </CardHeader>
133
+ <CardContent>
134
+ <div className="space-y-3">
135
+ {track.steps.map((step, index) => {
136
+ const isStepCompleted = progress.completedStepIds.includes(
137
+ step.id
138
+ );
139
+ const isCurrent =
140
+ !isStepCompleted &&
141
+ track.steps
142
+ .slice(0, index)
143
+ .every((s) => progress.completedStepIds.includes(s.id));
144
+
145
+ return (
146
+ <div
147
+ key={step.id}
148
+ className="flex items-center gap-4 rounded-lg border p-3"
149
+ >
150
+ <div
151
+ className={`flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-sm font-semibold ${
152
+ isStepCompleted
153
+ ? 'bg-green-500 text-white'
154
+ : isCurrent
155
+ ? 'bg-blue-500 text-white'
156
+ : 'bg-muted text-muted-foreground'
157
+ }`}
158
+ >
159
+ {isStepCompleted ? '✓' : index + 1}
160
+ </div>
161
+ <div className="min-w-0 flex-1">
162
+ <p
163
+ className={`font-medium ${
164
+ isStepCompleted
165
+ ? 'text-green-500'
166
+ : isCurrent
167
+ ? 'text-foreground'
168
+ : 'text-muted-foreground'
169
+ }`}
170
+ >
171
+ {step.title}
172
+ </p>
173
+ </div>
174
+ {step.xpReward && (
175
+ <span className="text-muted-foreground text-sm">
176
+ +{step.xpReward} XP
177
+ </span>
178
+ )}
179
+ </div>
180
+ );
181
+ })}
182
+ </div>
183
+ </CardContent>
184
+ </Card>
185
+
186
+ {/* Completion Message */}
187
+ {isComplete && (
188
+ <Card className="border-green-500/50 bg-green-500/5">
189
+ <CardContent className="flex items-center gap-4 p-6">
190
+ <div className="text-4xl">🎉</div>
191
+ <div>
192
+ <h3 className="text-lg font-semibold text-green-500">
193
+ Onboarding Complete!
194
+ </h3>
195
+ <p className="text-muted-foreground">
196
+ You've completed all {totalSteps} steps. Welcome aboard!
197
+ </p>
198
+ </div>
199
+ </CardContent>
200
+ </Card>
201
+ )}
202
+ </div>
203
+ );
204
+ }