@contractspec/example.learning-journey-ui-onboarding 3.7.6 → 3.7.7
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 +3 -3
- package/AGENTS.md +50 -24
- package/README.md +66 -26
- package/dist/OnboardingMiniApp.js +280 -280
- package/dist/browser/OnboardingMiniApp.js +280 -280
- package/dist/browser/components/CodeSnippet.js +4 -4
- package/dist/browser/components/JourneyMap.js +1 -1
- package/dist/browser/components/StepChecklist.js +6 -6
- package/dist/browser/components/index.js +11 -11
- package/dist/browser/index.js +285 -284
- package/dist/browser/views/Overview.js +14 -14
- package/dist/browser/views/Progress.js +9 -9
- package/dist/browser/views/Steps.js +8 -8
- package/dist/browser/views/Timeline.js +6 -6
- package/dist/browser/views/index.js +276 -276
- package/dist/components/CodeSnippet.js +4 -4
- package/dist/components/JourneyMap.js +1 -1
- package/dist/components/StepChecklist.js +6 -6
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +11 -11
- package/dist/index.d.ts +4 -4
- package/dist/index.js +285 -284
- package/dist/node/OnboardingMiniApp.js +280 -280
- package/dist/node/components/CodeSnippet.js +4 -4
- package/dist/node/components/JourneyMap.js +1 -1
- package/dist/node/components/StepChecklist.js +6 -6
- package/dist/node/components/index.js +11 -11
- package/dist/node/index.js +285 -284
- package/dist/node/views/Overview.js +14 -14
- package/dist/node/views/Progress.js +9 -9
- package/dist/node/views/Steps.js +8 -8
- package/dist/node/views/Timeline.js +6 -6
- package/dist/node/views/index.js +276 -276
- package/dist/views/Overview.js +14 -14
- package/dist/views/Progress.js +9 -9
- package/dist/views/Steps.js +8 -8
- package/dist/views/Timeline.js +6 -6
- package/dist/views/index.d.ts +1 -1
- package/dist/views/index.js +276 -276
- package/package.json +10 -10
- package/src/OnboardingMiniApp.tsx +70 -70
- package/src/components/CodeSnippet.tsx +43 -43
- package/src/components/JourneyMap.tsx +70 -70
- package/src/components/StepChecklist.tsx +118 -118
- package/src/components/index.ts +1 -1
- package/src/docs/learning-journey-ui-onboarding.docblock.ts +11 -11
- package/src/example.ts +25 -25
- package/src/index.ts +5 -6
- package/src/learning-journey-ui-onboarding.feature.ts +12 -12
- package/src/views/Overview.tsx +182 -182
- package/src/views/Progress.tsx +167 -167
- package/src/views/Steps.tsx +79 -79
- package/src/views/Timeline.tsx +126 -126
- package/src/views/index.ts +1 -1
- package/tsconfig.json +7 -8
- package/tsdown.config.js +7 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contractspec/example.learning-journey-ui-onboarding",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.7",
|
|
4
4
|
"description": "Developer onboarding UI with checklists and journey maps.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -120,21 +120,21 @@
|
|
|
120
120
|
"dev": "contractspec-bun-build dev",
|
|
121
121
|
"clean": "rimraf dist .turbo",
|
|
122
122
|
"lint": "bun lint:fix",
|
|
123
|
-
"lint:fix": "
|
|
124
|
-
"lint:check": "
|
|
123
|
+
"lint:fix": "biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .",
|
|
124
|
+
"lint:check": "biome check .",
|
|
125
125
|
"test": "bun test --pass-with-no-tests",
|
|
126
126
|
"prebuild": "contractspec-bun-build prebuild",
|
|
127
127
|
"typecheck": "tsc --noEmit"
|
|
128
128
|
},
|
|
129
129
|
"dependencies": {
|
|
130
130
|
"@contractspec/lib.ui-kit-core": "3.7.6",
|
|
131
|
-
"@contractspec/lib.contracts-spec": "
|
|
132
|
-
"@contractspec/example.learning-journey-ui-shared": "3.7.
|
|
133
|
-
"@contractspec/example.learning-journey-studio-onboarding": "3.7.
|
|
134
|
-
"@contractspec/example.learning-journey-platform-tour": "3.7.
|
|
135
|
-
"@contractspec/module.learning-journey": "3.7.
|
|
136
|
-
"@contractspec/lib.design-system": "3.
|
|
137
|
-
"@contractspec/lib.ui-kit-web": "3.
|
|
131
|
+
"@contractspec/lib.contracts-spec": "4.0.0",
|
|
132
|
+
"@contractspec/example.learning-journey-ui-shared": "3.7.7",
|
|
133
|
+
"@contractspec/example.learning-journey-studio-onboarding": "3.7.7",
|
|
134
|
+
"@contractspec/example.learning-journey-platform-tour": "3.7.7",
|
|
135
|
+
"@contractspec/module.learning-journey": "3.7.7",
|
|
136
|
+
"@contractspec/lib.design-system": "3.8.0",
|
|
137
|
+
"@contractspec/lib.ui-kit-web": "3.8.0",
|
|
138
138
|
"react": "19.2.0"
|
|
139
139
|
},
|
|
140
140
|
"devDependencies": {
|
|
@@ -1,93 +1,93 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { useState, useCallback } from 'react';
|
|
4
|
-
import { Card, CardContent } from '@contractspec/lib.ui-kit-web/ui/card';
|
|
5
3
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
type LearningMiniAppProps,
|
|
5
|
+
type LearningView,
|
|
6
|
+
useLearningProgress,
|
|
7
|
+
ViewTabs,
|
|
10
8
|
} from '@contractspec/example.learning-journey-ui-shared';
|
|
9
|
+
import { Card, CardContent } from '@contractspec/lib.ui-kit-web/ui/card';
|
|
10
|
+
import { useCallback, useState } from 'react';
|
|
11
11
|
import { Overview } from './views/Overview';
|
|
12
|
-
import { Steps } from './views/Steps';
|
|
13
12
|
import { Progress } from './views/Progress';
|
|
13
|
+
import { Steps } from './views/Steps';
|
|
14
14
|
import { Timeline } from './views/Timeline';
|
|
15
15
|
|
|
16
16
|
type OnboardingMiniAppProps = Omit<LearningMiniAppProps, 'progress'> & {
|
|
17
|
-
|
|
17
|
+
progress?: LearningMiniAppProps['progress'];
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
export function OnboardingMiniApp({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
track,
|
|
22
|
+
progress: externalProgress,
|
|
23
|
+
onStepComplete: externalOnStepComplete,
|
|
24
|
+
onViewChange,
|
|
25
|
+
initialView = 'overview',
|
|
26
26
|
}: OnboardingMiniAppProps) {
|
|
27
|
-
|
|
27
|
+
const [currentView, setCurrentView] = useState<LearningView>(initialView);
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
// Use internal progress if not provided externally
|
|
30
|
+
const { progress: internalProgress, completeStep: internalCompleteStep } =
|
|
31
|
+
useLearningProgress(track);
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
const progress = externalProgress ?? internalProgress;
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
const handleViewChange = useCallback(
|
|
36
|
+
(view: LearningView) => {
|
|
37
|
+
setCurrentView(view);
|
|
38
|
+
onViewChange?.(view);
|
|
39
|
+
},
|
|
40
|
+
[onViewChange]
|
|
41
|
+
);
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
const handleStartFromOverview = useCallback(() => {
|
|
55
|
+
setCurrentView('steps');
|
|
56
|
+
onViewChange?.('steps');
|
|
57
|
+
}, [onViewChange]);
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
const renderView = () => {
|
|
60
|
+
const viewProps = {
|
|
61
|
+
track,
|
|
62
|
+
progress,
|
|
63
|
+
onStepComplete: handleStepComplete,
|
|
64
|
+
};
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
79
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
88
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
{/* Current View */}
|
|
90
|
+
{renderView()}
|
|
91
|
+
</div>
|
|
92
|
+
);
|
|
93
93
|
}
|
|
@@ -1,56 +1,56 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { useState } from 'react';
|
|
4
3
|
import { Button } from '@contractspec/lib.design-system';
|
|
4
|
+
import { useState } from 'react';
|
|
5
5
|
|
|
6
6
|
interface CodeSnippetProps {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
code: string;
|
|
8
|
+
language?: string;
|
|
9
|
+
title?: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export function CodeSnippet({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
code,
|
|
14
|
+
language = 'typescript',
|
|
15
|
+
title,
|
|
16
16
|
}: CodeSnippetProps) {
|
|
17
|
-
|
|
17
|
+
const [copied, setCopied] = useState(false);
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
const handleCopy = async () => {
|
|
20
|
+
await navigator.clipboard.writeText(code);
|
|
21
|
+
setCopied(true);
|
|
22
|
+
setTimeout(() => setCopied(false), 2000);
|
|
23
|
+
};
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
25
|
+
return (
|
|
26
|
+
<div className="overflow-hidden rounded-lg border bg-muted/50">
|
|
27
|
+
{/* Header */}
|
|
28
|
+
<div className="flex items-center justify-between border-b bg-muted px-4 py-2">
|
|
29
|
+
<div className="flex items-center gap-2">
|
|
30
|
+
<span className="font-medium text-muted-foreground text-xs 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
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
{/* Code */}
|
|
51
|
+
<pre className="overflow-x-auto p-4">
|
|
52
|
+
<code className="text-sm">{code}</code>
|
|
53
|
+
</pre>
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
56
|
}
|
|
@@ -4,83 +4,83 @@ import { cn } from '@contractspec/lib.ui-kit-web/ui/utils';
|
|
|
4
4
|
import type { LearningJourneyStepSpec } from '@contractspec/module.learning-journey/track-spec';
|
|
5
5
|
|
|
6
6
|
interface JourneyMapProps {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
steps: LearningJourneyStepSpec[];
|
|
8
|
+
completedStepIds: string[];
|
|
9
|
+
currentStepId?: string | null;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
const SURFACE_ICONS: Record<string, string> = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
templates: '📋',
|
|
14
|
+
'spec-editor': '✏️',
|
|
15
|
+
regenerator: '🔄',
|
|
16
|
+
playground: '🎮',
|
|
17
|
+
evolution: '🤖',
|
|
18
|
+
dashboard: '📊',
|
|
19
|
+
settings: '⚙️',
|
|
20
|
+
default: '📍',
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
export function JourneyMap({
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
steps,
|
|
25
|
+
completedStepIds,
|
|
26
|
+
currentStepId,
|
|
27
27
|
}: JourneyMapProps) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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 font-medium text-xs',
|
|
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
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
86
|
}
|