import { useEffect, useRef, useState } from 'react'; import { Link } from 'react-router-dom'; import { motion, useScroll, useTransform } from 'framer-motion'; import { api } from '../../api/client.js'; import usePageMeta from '../../hooks/usePageMeta.js'; import Reveal from '../../components/Reveal.jsx'; import Accordion from '../../components/Accordion.jsx'; import StarRating from '../../components/StarRating.jsx'; import TestimonialSlider from '../../components/TestimonialSlider.jsx'; import { useSiteSettings } from '../../context/SiteSettingsContext.jsx'; import { useLanguage } from '../../context/LanguageContext.jsx'; import defaultHeroImage from '../../assets/photos/gallery-dash2.webp'; import galleryAmp from '../../assets/photos/gallery-amp-purple.webp'; import gallerySpeaker from '../../assets/photos/gallery-speaker.webp'; import gallerySubs from '../../assets/photos/gallery-subs.webp'; import galleryDash from '../../assets/photos/gallery-dash.webp'; import galleryTrunk from '../../assets/photos/hero-trunk.webp'; import galleryRear from '../../assets/photos/gallery-rear.webp'; import heroHighlight from '../../assets/leistungen/hero-highlight.webp'; import youtubeVideo from '../../assets/videos/youtube-hintergrund.mp4'; const YOUTUBE_URL = 'https://www.youtube.com/@hifiplanet2812'; const YOUTUBE_VIDEO_ID = 'ostj2mKDVUc'; const brands = ['Ground Zero Audio', 'Audison', 'Hertz', 'Helix', 'Brax', 'Gladen', 'Alpine', 'Pioneer', 'Kenwood', 'JVC']; // Native Pixelmasse der Bilder unten - nur fuer die width/height-Attribute auf , // damit der Browser vor dem Laden Platz reserviert (verhindert Layout-Sprung). Die // tatsaechliche Anzeigegroesse wird weiterhin komplett per CSS (aspect-square etc.) // bestimmt, diese Werte muessen also nicht exakt zum gerenderten Seitenverhaeltnis passen. const galleryImages = [ { src: gallerySubs, width: 900, height: 600 }, { src: galleryAmp, width: 900, height: 600 }, { src: gallerySpeaker, width: 900, height: 1200 }, { src: galleryDash, width: 900, height: 814 }, { src: galleryRear, width: 900, height: 1200 }, { src: galleryTrunk, width: 1920, height: 1280 }, ]; export default function Home() { const { hero_image_path: heroImagePath } = useSiteSettings(); const heroImage = heroImagePath || defaultHeroImage; const { t, language } = useLanguage(); const stats = t('home.stats'); const galleryAlts = t('home.galleryAlts'); const gallery = galleryImages.map((img, i) => ({ ...img, alt: galleryAlts[i] })); const testimonials = t('home.testimonials'); const [faqs, setFaqs] = useState([]); useEffect(() => { api .get('/faqs') .then((rows) => { setFaqs( rows.map((f) => ({ question: language === 'de' ? f.question_de : f.question_en, answer: language === 'de' ? f.answer_de : f.answer_en, })) ); }) .catch(() => {}); }, [language]); usePageMeta({ title: t('home.metaTitle'), description: t('home.metaDescription'), path: '/', }); useEffect(() => { if (faqs.length === 0) return; const script = document.createElement('script'); script.type = 'application/ld+json'; script.text = JSON.stringify({ '@context': 'https://schema.org', '@type': 'FAQPage', mainEntity: faqs.map((f) => ({ '@type': 'Question', name: f.question, acceptedAnswer: { '@type': 'Answer', text: f.answer }, })), }); document.head.appendChild(script); return () => document.head.removeChild(script); }, [faqs]); const heroRef = useRef(null); const { scrollYProgress: heroProgress } = useScroll({ target: heroRef, offset: ['start start', 'end start'] }); const heroImageY = useTransform(heroProgress, [0, 1], ['-6%', '6%']); const heroTextY = useTransform(heroProgress, [0, 1], ['0%', '60%']); const heroOpacity = useTransform(heroProgress, [0, 0.8], [1, 0]); const ctaOpacity = useTransform(heroProgress, [0.5, 1], [0, 1]); const ctaPointerEvents = useTransform(ctaOpacity, (v) => (v > 0.05 ? 'auto' : 'none')); const ctaY = useTransform(heroProgress, [0.5, 1], [16, 0]); return (

{t('home.stickyCta')}

{t('home.selectVehicle')} {t('home.getInTouch')}

{t('home.welcome')}

{t('home.heroTitle')}

{t('home.heroSubtitle')}

{t('home.selectVehicle')} {t('home.getInTouch')}
{stats.map((stat, i) => (

{stat.value}

{stat.label}

))}

{t('home.brandsHeading')}

{brands.map((brand, i) => ( {brand} ))}

{t('home.youtubeBadge')}

{t('home.youtubeTitle')}

{t('home.youtubeText')}

{t('home.youtubeCta')}
{t('home.craftImageAlt')}

{t('home.craftEyebrow')}

{t('home.craftTitle')}

{t('home.craftText')}

{t('home.adviceEyebrow')}

{t('home.adviceTitle')}

{t('home.adviceText')}

{t('home.adviceImageAlt')}

{t('home.insightsTitle')}

{t('home.insightsText')}

{gallery.map((img, i) => ( {img.alt} ))}

{t('home.reviewsRating')}

{t('home.reviewsText')}

{t('home.reviewsLink')}
{t('home.moreImageAlt')}

{t('home.moreTitle')}

{t('home.moreText')}

{t('home.moreCta')}

{t('home.faqHeading')}

); }