import { motion, useScroll, useTransform, useAnimation } from 'framer-motion' import { Sparkles } from 'lucide-react' import { t, Language } from '../../i18n/translations' import { useGitHubStats } from '../../hooks/useGitHubStats' import { useCounterAnimation } from '../../hooks/useCounterAnimation' interface HeroSectionProps { language: Language } export default function HeroSection({ language }: HeroSectionProps) { const { scrollYProgress } = useScroll() const opacity = useTransform(scrollYProgress, [0, 0.2], [1, 0]) const scale = useTransform(scrollYProgress, [0, 0.2], [1, 0.8]) const handControls = useAnimation() const { stars, daysOld, isLoading } = useGitHubStats('NoFxAiOS', 'nofx') // 动画数字 - 仅对 stars 添加动画 const animatedStars = useCounterAnimation({ start: 0, end: stars, duration: 2000, }) const fadeInUp = { initial: { opacity: 0, y: 60 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.6, ease: [0.6, -0.05, 0.01, 0.99] }, } const staggerContainer = { animate: { transition: { staggerChildren: 0.1 } }, } return (
{/* Left Content */} {isLoading ? ( t('githubStarsInDays', language) ) : language === 'zh' ? ( <> {daysOld} 天内{' '} {(animatedStars / 1000).toFixed(1)} K+ GitHub Stars ) : ( <> {(animatedStars / 1000).toFixed(1)} K+ GitHub Stars in {daysOld} days )}

{t('heroTitle1', language)}
{t('heroTitle2', language)}

{t('heroDescription', language)}
GitHub Stars GitHub Forks GitHub Contributors
{t('poweredBy', language)}
{/* Right Visual - Interactive Robot */}
{ handControls.start({ y: [-8, 8, -8], rotate: [-3, 3, -3], x: [-2, 2, -2], transition: { duration: 2.5, repeat: Infinity, ease: 'easeInOut', times: [0, 0.5, 1], }, }) }} onMouseLeave={() => { handControls.start({ y: 0, rotate: 0, x: 0, transition: { duration: 0.6, ease: 'easeOut', }, }) }} > {/* Background Layer */} {/* Hand Layer - Animated */}
) }