Spaces:
Running
Running
Upload components/Stats.js with huggingface_hub
Browse files1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950import { 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> )}components/Stats.jsAdded+50