VibeCodingStudio commited on
Commit
10ca394
·
verified ·
1 Parent(s): 0d7862d

Upload components/MetricRing.jsx with huggingface_hub

Browse files
Files changed (1) hide show
  1. components/MetricRing.jsx +44 -0
components/MetricRing.jsx ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { clsx } from 'clsx';
2
+
3
+ export default function MetricRing({ value, max, label, color = 'purple', size = 80, strokeWidth = 6 }) {
4
+ const radius = (size - strokeWidth) / 2;
5
+ const circumference = 2 * Math.PI * radius;
6
+ const percentage = Math.min((value / max) * 100, 100);
7
+ const offset = circumference - (percentage / 100) * circumference;
8
+
9
+ const colorMap = {
10
+ purple: { stroke: '#8b5cf6', text: 'text-purple-400', glow: 'rgba(139, 92, 246, 0.4)' },
11
+ cyan: { stroke: '#06b6d4', text: 'text-cyan-400', glow: 'rgba(6, 182, 212, 0.4)' },
12
+ green: { stroke: '#10b981', text: 'text-emerald-400', glow: 'rgba(16, 185, 129, 0.4)' },
13
+ amber: { stroke: '#f59e0b', text: 'text-amber-400', glow: 'rgba(245, 158, 11, 0.4)' },
14
+ red: { stroke: '#ef4444', text: 'text-red-400', glow: 'rgba(239, 68, 68, 0.4)' },
15
+ };
16
+
17
+ const colors = colorMap[color] || colorMap.purple;
18
+
19
+ return (
20
+ <div className="flex flex-col items-center gap-1">
21
+ <div className="relative" style={{ width: size, height: size }}>
22
+ <svg width={size} height={size} className="ring-chart">
23
+ <circle
24
+ cx={size / 2}
25
+ cy={size / 2}
26
+ r={radius}
27
+ fill="none"
28
+ stroke="rgba(139, 92, 246, 0.1)"
29
+ strokeWidth={strokeWidth}
30
+ />
31
+ <circle
32
+ cx={size / 2}
33
+ cy={size / 2}
34
+ r={radius}
35
+ fill="none"
36
+ stroke={colors.stroke}
37
+ strokeWidth={strokeWidth}
38
+ strokeDasharray={circumference}
39
+ strokeDashoffset={offset}
40
+ strokeLinecap="round"
41
+ className="transition-all duration-1000 ease-out"
42
+ style={{ filter: `drop-shadow(0 0 4px ${colors.glow})` }}
43
+ />
44
+ </svg