@contractspec/example.learning-journey-ui-gamified 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 +6 -6
- package/AGENTS.md +50 -25
- package/README.md +63 -20
- package/dist/GamifiedMiniApp.js +246 -246
- package/dist/browser/GamifiedMiniApp.js +246 -246
- package/dist/browser/components/DayCalendar.js +1 -1
- package/dist/browser/components/FlashCard.js +6 -6
- package/dist/browser/components/MasteryRing.js +1 -1
- package/dist/browser/components/index.js +100 -100
- package/dist/browser/index.js +247 -246
- package/dist/browser/views/Overview.js +16 -16
- package/dist/browser/views/Progress.js +7 -7
- package/dist/browser/views/Steps.js +8 -8
- package/dist/browser/views/Timeline.js +8 -8
- package/dist/browser/views/index.js +242 -242
- package/dist/components/DayCalendar.js +1 -1
- package/dist/components/FlashCard.js +6 -6
- package/dist/components/MasteryRing.js +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +100 -100
- package/dist/index.d.ts +3 -3
- package/dist/index.js +247 -246
- package/dist/node/GamifiedMiniApp.js +246 -246
- package/dist/node/components/DayCalendar.js +1 -1
- package/dist/node/components/FlashCard.js +6 -6
- package/dist/node/components/MasteryRing.js +1 -1
- package/dist/node/components/index.js +100 -100
- package/dist/node/index.js +247 -246
- package/dist/node/views/Overview.js +16 -16
- package/dist/node/views/Progress.js +7 -7
- package/dist/node/views/Steps.js +8 -8
- package/dist/node/views/Timeline.js +8 -8
- package/dist/node/views/index.js +242 -242
- package/dist/views/Overview.js +16 -16
- package/dist/views/Progress.js +7 -7
- package/dist/views/Steps.js +8 -8
- package/dist/views/Timeline.js +8 -8
- package/dist/views/index.d.ts +1 -1
- package/dist/views/index.js +242 -242
- package/package.json +10 -10
- package/src/GamifiedMiniApp.tsx +70 -70
- package/src/components/DayCalendar.tsx +41 -41
- package/src/components/FlashCard.tsx +83 -83
- package/src/components/MasteryRing.tsx +64 -64
- package/src/components/index.ts +1 -1
- package/src/docs/learning-journey-ui-gamified.docblock.ts +11 -11
- package/src/example.ts +25 -25
- package/src/index.ts +5 -6
- package/src/learning-journey-ui-gamified.feature.ts +12 -12
- package/src/views/Overview.tsx +145 -145
- package/src/views/Progress.tsx +167 -167
- package/src/views/Steps.tsx +40 -40
- package/src/views/Timeline.tsx +177 -177
- 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-gamified",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.7",
|
|
4
4
|
"description": "Duolingo-style gamified learning UI for drills and quests.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -120,20 +120,20 @@
|
|
|
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
|
-
"@contractspec/lib.contracts-spec": "
|
|
131
|
-
"@contractspec/example.learning-journey-ui-shared": "3.7.
|
|
132
|
-
"@contractspec/example.learning-journey-duo-drills": "3.7.
|
|
133
|
-
"@contractspec/example.learning-journey-quest-challenges": "3.7.
|
|
134
|
-
"@contractspec/module.learning-journey": "3.7.
|
|
135
|
-
"@contractspec/lib.design-system": "3.
|
|
136
|
-
"@contractspec/lib.ui-kit-web": "3.
|
|
130
|
+
"@contractspec/lib.contracts-spec": "4.0.0",
|
|
131
|
+
"@contractspec/example.learning-journey-ui-shared": "3.7.7",
|
|
132
|
+
"@contractspec/example.learning-journey-duo-drills": "3.7.7",
|
|
133
|
+
"@contractspec/example.learning-journey-quest-challenges": "3.7.7",
|
|
134
|
+
"@contractspec/module.learning-journey": "3.7.7",
|
|
135
|
+
"@contractspec/lib.design-system": "3.8.0",
|
|
136
|
+
"@contractspec/lib.ui-kit-web": "3.8.0",
|
|
137
137
|
"react": "19.2.0"
|
|
138
138
|
},
|
|
139
139
|
"devDependencies": {
|
package/src/GamifiedMiniApp.tsx
CHANGED
|
@@ -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 GamifiedMiniAppProps = Omit<LearningMiniAppProps, 'progress'> & {
|
|
17
|
-
|
|
17
|
+
progress?: LearningMiniAppProps['progress'];
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
export function GamifiedMiniApp({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
track,
|
|
22
|
+
progress: externalProgress,
|
|
23
|
+
onStepComplete: externalOnStepComplete,
|
|
24
|
+
onViewChange,
|
|
25
|
+
initialView = 'overview',
|
|
26
26
|
}: GamifiedMiniAppProps) {
|
|
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
|
}
|
|
@@ -3,51 +3,51 @@
|
|
|
3
3
|
import { cn } from '@contractspec/lib.ui-kit-web/ui/utils';
|
|
4
4
|
|
|
5
5
|
interface DayCalendarProps {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
totalDays: number;
|
|
7
|
+
currentDay: number;
|
|
8
|
+
completedDays: number[];
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export function DayCalendar({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
totalDays,
|
|
13
|
+
currentDay,
|
|
14
|
+
completedDays,
|
|
15
15
|
}: DayCalendarProps) {
|
|
16
|
-
|
|
16
|
+
const days = Array.from({ length: totalDays }, (_, i) => i + 1);
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
return (
|
|
19
|
+
<div className="grid grid-cols-7 gap-2">
|
|
20
|
+
{days.map((day) => {
|
|
21
|
+
const isCompleted = completedDays.includes(day);
|
|
22
|
+
const isCurrent = day === currentDay;
|
|
23
|
+
const isLocked = day > currentDay;
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
25
|
+
return (
|
|
26
|
+
<div
|
|
27
|
+
key={day}
|
|
28
|
+
className={cn(
|
|
29
|
+
'flex h-12 w-12 flex-col items-center justify-center rounded-lg border font-medium text-sm transition-all',
|
|
30
|
+
isCompleted && 'border-green-500 bg-green-500/10 text-green-500',
|
|
31
|
+
isCurrent &&
|
|
32
|
+
!isCompleted &&
|
|
33
|
+
'border-violet-500 bg-violet-500/10 text-violet-500 ring-2 ring-violet-500/50',
|
|
34
|
+
isLocked && 'border-muted bg-muted/50 text-muted-foreground',
|
|
35
|
+
!isCompleted && !isCurrent && !isLocked && 'border-border bg-card'
|
|
36
|
+
)}
|
|
37
|
+
>
|
|
38
|
+
{isCompleted ? (
|
|
39
|
+
<span className="text-lg">✓</span>
|
|
40
|
+
) : isLocked ? (
|
|
41
|
+
<span className="text-lg">🔒</span>
|
|
42
|
+
) : (
|
|
43
|
+
<>
|
|
44
|
+
<span className="text-muted-foreground text-xs">Day</span>
|
|
45
|
+
<span>{day}</span>
|
|
46
|
+
</>
|
|
47
|
+
)}
|
|
48
|
+
</div>
|
|
49
|
+
);
|
|
50
|
+
})}
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
53
|
}
|
|
@@ -1,100 +1,100 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { useState } from 'react';
|
|
4
3
|
import { Button } from '@contractspec/lib.design-system';
|
|
5
4
|
import { Card, CardContent } from '@contractspec/lib.ui-kit-web/ui/card';
|
|
6
5
|
import { cn } from '@contractspec/lib.ui-kit-web/ui/utils';
|
|
7
6
|
import type { LearningJourneyStepSpec } from '@contractspec/module.learning-journey/track-spec';
|
|
7
|
+
import { useState } from 'react';
|
|
8
8
|
|
|
9
9
|
interface FlashCardProps {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
step: LearningJourneyStepSpec;
|
|
11
|
+
isCompleted: boolean;
|
|
12
|
+
isCurrent: boolean;
|
|
13
|
+
onComplete?: () => void;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export function FlashCard({
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
step,
|
|
18
|
+
isCompleted,
|
|
19
|
+
isCurrent,
|
|
20
|
+
onComplete,
|
|
21
21
|
}: FlashCardProps) {
|
|
22
|
-
|
|
22
|
+
const [isFlipped, setIsFlipped] = useState(false);
|
|
23
23
|
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
24
|
+
return (
|
|
25
|
+
<Card
|
|
26
|
+
className={cn(
|
|
27
|
+
'relative cursor-pointer overflow-hidden transition-all duration-300',
|
|
28
|
+
isCurrent && 'ring-2 ring-primary',
|
|
29
|
+
isCompleted && 'opacity-60'
|
|
30
|
+
)}
|
|
31
|
+
onClick={() => !isCompleted && setIsFlipped(!isFlipped)}
|
|
32
|
+
>
|
|
33
|
+
<CardContent className="p-6">
|
|
34
|
+
{/* Front of card */}
|
|
35
|
+
<div
|
|
36
|
+
className={cn(
|
|
37
|
+
'space-y-4 transition-opacity duration-200',
|
|
38
|
+
isFlipped ? 'opacity-0' : 'opacity-100'
|
|
39
|
+
)}
|
|
40
|
+
>
|
|
41
|
+
<div className="flex items-start justify-between">
|
|
42
|
+
<div className="flex-1">
|
|
43
|
+
<h3 className="font-semibold text-lg">{step.title}</h3>
|
|
44
|
+
{step.description && (
|
|
45
|
+
<p className="mt-1 text-muted-foreground text-sm">
|
|
46
|
+
{step.description}
|
|
47
|
+
</p>
|
|
48
|
+
)}
|
|
49
|
+
</div>
|
|
50
|
+
{step.xpReward && (
|
|
51
|
+
<span className="rounded-full bg-green-500/10 px-2 py-1 font-semibold text-green-500 text-xs">
|
|
52
|
+
+{step.xpReward} XP
|
|
53
|
+
</span>
|
|
54
|
+
)}
|
|
55
|
+
</div>
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
{isCompleted && (
|
|
58
|
+
<div className="flex items-center gap-2 text-green-500">
|
|
59
|
+
<span>✓</span>
|
|
60
|
+
<span className="font-medium text-sm">Completed</span>
|
|
61
|
+
</div>
|
|
62
|
+
)}
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
{isCurrent && !isCompleted && (
|
|
65
|
+
<p className="text-muted-foreground text-xs">
|
|
66
|
+
Tap to reveal action
|
|
67
|
+
</p>
|
|
68
|
+
)}
|
|
69
|
+
</div>
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
71
|
+
{/* Back of card (action) */}
|
|
72
|
+
{isFlipped && !isCompleted && (
|
|
73
|
+
<div className="absolute inset-0 flex flex-col items-center justify-center gap-4 bg-gradient-to-br from-violet-500/10 to-violet-600/10 p-6">
|
|
74
|
+
<p className="text-center text-sm">
|
|
75
|
+
{step.instructions ?? 'Complete this step to earn XP'}
|
|
76
|
+
</p>
|
|
77
|
+
<div className="flex gap-2">
|
|
78
|
+
<Button
|
|
79
|
+
variant="outline"
|
|
80
|
+
size="sm"
|
|
81
|
+
onClick={() => setIsFlipped(false)}
|
|
82
|
+
>
|
|
83
|
+
Back
|
|
84
|
+
</Button>
|
|
85
|
+
<Button
|
|
86
|
+
size="sm"
|
|
87
|
+
onClick={(e) => {
|
|
88
|
+
e.stopPropagation();
|
|
89
|
+
onComplete?.();
|
|
90
|
+
}}
|
|
91
|
+
>
|
|
92
|
+
Mark Complete
|
|
93
|
+
</Button>
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
)}
|
|
97
|
+
</CardContent>
|
|
98
|
+
</Card>
|
|
99
|
+
);
|
|
100
100
|
}
|
|
@@ -3,79 +3,79 @@
|
|
|
3
3
|
import { cn } from '@contractspec/lib.ui-kit-web/ui/utils';
|
|
4
4
|
|
|
5
5
|
interface MasteryRingProps {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
label: string;
|
|
7
|
+
percentage: number;
|
|
8
|
+
size?: 'sm' | 'md' | 'lg';
|
|
9
|
+
color?: 'green' | 'blue' | 'violet' | 'orange';
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
const sizeStyles = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
sm: { container: 'h-16 w-16', text: 'text-xs', ring: 48, stroke: 4 },
|
|
14
|
+
md: { container: 'h-24 w-24', text: 'text-sm', ring: 72, stroke: 6 },
|
|
15
|
+
lg: { container: 'h-32 w-32', text: 'text-base', ring: 96, stroke: 8 },
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
const colorStyles = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
green: 'stroke-green-500',
|
|
20
|
+
blue: 'stroke-blue-500',
|
|
21
|
+
violet: 'stroke-violet-500',
|
|
22
|
+
orange: 'stroke-orange-500',
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
export function MasteryRing({
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
label,
|
|
27
|
+
percentage,
|
|
28
|
+
size = 'md',
|
|
29
|
+
color = 'violet',
|
|
30
30
|
}: MasteryRingProps) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
const styles = sizeStyles[size];
|
|
32
|
+
const radius = (styles.ring - styles.stroke) / 2;
|
|
33
|
+
const circumference = 2 * Math.PI * radius;
|
|
34
|
+
const strokeDashoffset = circumference - (percentage / 100) * circumference;
|
|
35
35
|
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
36
|
+
return (
|
|
37
|
+
<div
|
|
38
|
+
className={cn(
|
|
39
|
+
'relative flex flex-col items-center gap-1',
|
|
40
|
+
styles.container
|
|
41
|
+
)}
|
|
42
|
+
>
|
|
43
|
+
<svg
|
|
44
|
+
className="absolute -rotate-90"
|
|
45
|
+
width={styles.ring}
|
|
46
|
+
height={styles.ring}
|
|
47
|
+
viewBox={`0 0 ${styles.ring} ${styles.ring}`}
|
|
48
|
+
>
|
|
49
|
+
{/* Background ring */}
|
|
50
|
+
<circle
|
|
51
|
+
cx={styles.ring / 2}
|
|
52
|
+
cy={styles.ring / 2}
|
|
53
|
+
r={radius}
|
|
54
|
+
fill="none"
|
|
55
|
+
strokeWidth={styles.stroke}
|
|
56
|
+
className="stroke-muted"
|
|
57
|
+
/>
|
|
58
|
+
{/* Progress ring */}
|
|
59
|
+
<circle
|
|
60
|
+
cx={styles.ring / 2}
|
|
61
|
+
cy={styles.ring / 2}
|
|
62
|
+
r={radius}
|
|
63
|
+
fill="none"
|
|
64
|
+
strokeWidth={styles.stroke}
|
|
65
|
+
strokeLinecap="round"
|
|
66
|
+
strokeDasharray={circumference}
|
|
67
|
+
strokeDashoffset={strokeDashoffset}
|
|
68
|
+
className={cn('transition-all duration-500', colorStyles[color])}
|
|
69
|
+
/>
|
|
70
|
+
</svg>
|
|
71
|
+
<div className="flex h-full flex-col items-center justify-center">
|
|
72
|
+
<span className={cn('font-bold', styles.text)}>
|
|
73
|
+
{Math.round(percentage)}%
|
|
74
|
+
</span>
|
|
75
|
+
</div>
|
|
76
|
+
<span className={cn('mt-1 truncate text-muted-foreground', styles.text)}>
|
|
77
|
+
{label}
|
|
78
|
+
</span>
|
|
79
|
+
</div>
|
|
80
|
+
);
|
|
81
81
|
}
|
package/src/components/index.ts
CHANGED