dramaling-vocab-learning/frontend/app/review-simple/components/SimpleProgress.tsx

50 lines
1.7 KiB
TypeScript

interface SimpleProgressProps {
current: number
total: number
score: { correct: number; total: number }
}
export function SimpleProgress({ current, total, score }: SimpleProgressProps) {
const progress = (current - 1) / total * 100
const accuracy = score.total > 0 ? Math.round((score.correct / score.total) * 100) : 0
return (
<div className="mb-8">
<div className="flex justify-between items-center mb-3">
<span className="text-sm font-medium text-gray-600"></span>
<div className="flex items-center gap-4 text-sm">
<span className="text-gray-600">
{current}/{total}
</span>
{score.total > 0 && (
<span className="text-green-600 font-medium">
{accuracy}%
</span>
)}
</div>
</div>
{/* 進度條 */}
<div className="w-full bg-gray-200 rounded-full h-3">
<div
className="bg-blue-500 h-3 rounded-full transition-all duration-300"
style={{ width: `${progress}%` }}
/>
</div>
{/* 詳細統計 */}
{score.total > 0 && (
<div className="flex justify-center gap-6 mt-3 text-sm">
<div className="flex items-center gap-1">
<span className="w-2 h-2 bg-green-500 rounded-full"></span>
<span className="text-green-700"> {score.correct}</span>
</div>
<div className="flex items-center gap-1">
<span className="w-2 h-2 bg-red-500 rounded-full"></span>
<span className="text-red-700"> {score.total - score.correct}</span>
</div>
</div>
)}
</div>
)
}