Open History to see the last commit
1'use client'
2
3import { motion } from 'framer-motion'
4import type { ProgressProps } from '@/lib/reports/types'
5
6const variantColors = {
7 default: 'bg-[var(--report-accent)]',
8 success: 'bg-[var(--report-success)]',
9 warning: 'bg-[var(--report-warning)]',
10 error: 'bg-[var(--report-error)]',
11}
12
13const sizeClasses = {
14 sm: 'h-1.5',
15 md: 'h-2.5',
16 lg: 'h-4',
17}
18
19export function Progress({
20 value,
21 max = 100,
22 label,
23 showValue = true,
24 variant = 'default',
25 size = 'md',
26}: ProgressProps) {
27 const percentage = Math.min(100, Math.max(0, (value / max) * 100))
28
29 return (
30 <div className="w-full">
31 {(label || showValue) && (
32 <div className="flex justify-between items-center mb-1.5">
33 {label && (
34 <span className="text-sm text-[var(--report-text-muted)]">
35 {label}
36 </span>
37 )}
38 {showValue && (
39 <span className="text-sm font-medium text-[var(--report-text)]">
40 {Math.round(percentage)}%
41 </span>
42 )}
43 </div>
44 )}
45 <div
46 className={`w-full bg-sky-200/60 rounded-full overflow-hidden ${sizeClasses[size]}`}
47 >
48 <motion.div
49 className={`h-full rounded-full ${variantColors[variant]}`}
50 initial={{ width: 0 }}
51 animate={{ width: `${percentage}%` }}
52 transition={{ duration: 0.5, ease: 'easeOut' }}
53 />
54 </div>
55 </div>
56 )
57}