Spaces:
Running
Running
Download components/Stats.js from powerllm/anycoder-cf48624d: direct link, hf CLI and curl.
- Browser
- Download file 1.63 kB
-
https://huggingface.co/spaces/powerllm/anycoder-cf48624d/resolve/main/components/Stats.js
- Command line
-
hf download hf://spaces/powerllm/anycoder-cf48624d/components/Stats.js
-
curl -L -o Stats.js https://huggingface.co/spaces/powerllm/anycoder-cf48624d/resolve/main/components/Stats.js
1.63 kB
| import { useEffect, useState } from 'react' | |
| const stats = [ | |
| { value: 500, suffix: '+', label: 'Happy Clients' }, | |
| { value: 99.9, suffix: '%', label: 'Uptime Guarantee' }, | |
| { value: 150, suffix: 'M+', label: 'API Requests/Day' }, | |
| { value: 24, suffix: '/7', label: 'Expert Support' } | |
| ] | |
| export default function Stats() { | |
| const [counts, setCounts] = useState(stats.map(() => 0)) | |
| useEffect(() => { | |
| const duration = 2000 | |
| const steps = 60 | |
| const increment = stats.map(stat => stat.value / steps) | |
| let step = 0 | |
| const timer = setInterval(() => { | |
| step++ | |
| setCounts(prev => prev.map((count, i) => { | |
| if (step >= steps) return stats[i].value | |
| return Math.min(count + increment[i], stats[i].value) | |
| })) | |
| if (step >= steps) clearInterval(timer) | |
| }, duration / steps) | |
| return () => clearInterval(timer) | |
| }, []) | |
| return ( | |
| <section id="stats" className="py-20 px-4"> | |
| <div className="container mx-auto"> | |
| <div className="bg-gradient-to-r from-primary-600/20 to-primary-800/20 border border-primary-500/20 rounded-2xl p-8 lg:p-12"> | |
| <div className="grid grid-cols-2 lg:grid-cols-4 gap-8"> | |
| {stats.map((stat, index) => ( | |
| <div key={index} className="text-center"> | |
| <p className="text-4xl lg:text-5xl font-bold gradient-text mb-2"> | |
| {counts[index].toFixed(index === 1 ? 1 : 0)}{stat.suffix} | |
| </p> | |
| <p className="text-dark-300">{stat.label}</p> | |
| </div> | |
| ))} | |
| </div> | |
| </div> | |
| </div> | |
| </section> | |
| ) | |
| } |