70 lines
2.1 KiB
TypeScript
70 lines
2.1 KiB
TypeScript
'use client';
|
|
|
|
import { useEffect, useRef, useState } from 'react';
|
|
|
|
import AnimatedCounter from '../shared/components/animated-counter';
|
|
import { useLanguage } from '@/shared/language';
|
|
|
|
export function StatsSection() {
|
|
const [isVisible, setIsVisible] = useState(false);
|
|
const sectionRef = useRef<HTMLDivElement>(null);
|
|
|
|
const { t } = useLanguage()
|
|
|
|
useEffect(() => {
|
|
const observer = new IntersectionObserver(
|
|
(entries) => {
|
|
const [entry] = entries;
|
|
if (entry.isIntersecting) {
|
|
setIsVisible(true);
|
|
observer.disconnect();
|
|
}
|
|
},
|
|
{
|
|
threshold: 0.1,
|
|
},
|
|
);
|
|
|
|
if (sectionRef.current) {
|
|
observer.observe(sectionRef.current);
|
|
}
|
|
|
|
return () => {
|
|
observer.disconnect();
|
|
};
|
|
}, []);
|
|
|
|
return (
|
|
<section ref={sectionRef} className='bg-red-600 py-6 sm:py-12 px-2 text-white'>
|
|
<div className='container mx-auto'>
|
|
<div className='grid grid-cols-2 gap-4 sm:gap-8 text-center md:grid-cols-4'>
|
|
<div className='space-y-2'>
|
|
<h3 className='text-3xl font-bold'>
|
|
{isVisible ? <AnimatedCounter end={25} suffix='+' /> : '0+'}
|
|
</h3>
|
|
<p className='text-sm text-white/80'>{t('home.stats.stations')}</p>
|
|
</div>
|
|
<div className='space-y-2'>
|
|
<h3 className='text-3xl font-bold'>
|
|
{isVisible ? <AnimatedCounter end={10000} suffix='+' /> : '0+'}
|
|
</h3>
|
|
<p className='text-sm text-white/80'>{t('home.stats.daily')}</p>
|
|
</div>
|
|
<div className='space-y-2'>
|
|
<h3 className='text-3xl font-bold'>
|
|
{isVisible ? <AnimatedCounter end={15} /> : '0'}
|
|
</h3>
|
|
<p className='text-sm text-white/80'>{t('home.stats.years')}</p>
|
|
</div>
|
|
<div className='space-y-2'>
|
|
<h3 className='text-3xl font-bold'>
|
|
{isVisible ? <AnimatedCounter end={24} suffix='/7' /> : '0/7'}
|
|
</h3>
|
|
<p className='text-sm text-white/80'>{t('home.stats.mode')}</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
);
|
|
}
|