Download src/components/dashboard/daily-ring.tsx from NAP1320/RotNot: direct link, hf CLI and curl.
- Browser
- Download file 2.37 kB
-
https://huggingface.co/spaces/NAP1320/RotNot/resolve/main/src/components/dashboard/daily-ring.tsx
- Command line
-
hf download hf://spaces/NAP1320/RotNot/src/components/dashboard/daily-ring.tsx
-
curl -L -o daily-ring.tsx https://huggingface.co/spaces/NAP1320/RotNot/resolve/main/src/components/dashboard/daily-ring.tsx
2.37 kB
| "use client"; | |
| import { motion } from "framer-motion"; | |
| interface DailyRingProps { | |
| xpEarned: number; | |
| goalXp: number; | |
| size?: number; | |
| strokeWidth?: number; | |
| } | |
| export function DailyRing({ | |
| xpEarned, | |
| goalXp, | |
| size = 140, | |
| strokeWidth = 12, | |
| }: DailyRingProps) { | |
| const radius = (size - strokeWidth) / 2; | |
| const circumference = 2 * Math.PI * radius; | |
| const progress = Math.min(xpEarned / goalXp, 1); | |
| const offset = circumference * (1 - progress); | |
| const goalMet = xpEarned >= goalXp; | |
| const pct = Math.round(progress * 100); | |
| return ( | |
| <div className="flex flex-col items-center gap-2"> | |
| <div className="relative" style={{ width: size, height: size }}> | |
| <svg width={size} height={size} className="-rotate-90" style={{ display: "block" }}> | |
| {/* Track */} | |
| <circle | |
| cx={size / 2} | |
| cy={size / 2} | |
| r={radius} | |
| fill="none" | |
| stroke="rgba(255,255,255,0.07)" | |
| strokeWidth={strokeWidth} | |
| /> | |
| {/* Progress arc */} | |
| <motion.circle | |
| cx={size / 2} | |
| cy={size / 2} | |
| r={radius} | |
| fill="none" | |
| stroke={goalMet ? "#10b981" : "#6366f1"} | |
| strokeWidth={strokeWidth} | |
| strokeLinecap="round" | |
| strokeDasharray={circumference} | |
| initial={{ strokeDashoffset: circumference }} | |
| animate={{ strokeDashoffset: offset }} | |
| transition={{ duration: 1.2, ease: "easeOut" }} | |
| /> | |
| </svg> | |
| {/* Center text */} | |
| <div | |
| className="absolute inset-0 flex flex-col items-center justify-center" | |
| style={{ fontFamily: "var(--font-mono)" }} | |
| > | |
| <span | |
| className="text-2xl font-bold leading-none" | |
| style={{ color: goalMet ? "#10b981" : "var(--text-primary)" }} | |
| > | |
| {pct}% | |
| </span> | |
| <span className="text-xs mt-1" style={{ color: "var(--text-muted)" }}> | |
| daily goal | |
| </span> | |
| </div> | |
| </div> | |
| <div className="text-center"> | |
| <span className="text-sm font-semibold" style={{ fontFamily: "var(--font-mono)" }}> | |
| {xpEarned} | |
| </span> | |
| <span className="text-sm" style={{ color: "var(--text-muted)" }}> | |
| {" "}/ {goalXp} XP | |
| </span> | |
| </div> | |
| </div> | |
| ); | |
| } | |