"use client"; import { motion } from "framer-motion"; import Header from "@/components/Header"; import Footer from "@/components/Footer"; import Section from "@/components/Section"; import Button from "@/components/Button"; import BannerSlider from "@/components/BannerSlider"; import Image from "next/image"; import { useState, useEffect, useRef, useCallback } from "react"; import ProductCategory from "@/components/ProductCategory"; import SocialMedia from "@/components/SocialMedia"; // Premium animation variants const fadeInUp = { initial: { opacity: 0, y: 30 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.8, ease: [0.25, 0.46, 0.45, 0.94] }, }; const fadeInLeft = { initial: { opacity: 0, x: -30 }, animate: { opacity: 1, x: 0 }, transition: { duration: 0.8, ease: [0.25, 0.46, 0.45, 0.94] }, }; const fadeInRight = { initial: { opacity: 0, x: 30 }, animate: { opacity: 1, x: 0 }, transition: { duration: 0.8, ease: [0.25, 0.46, 0.45, 0.94] }, }; const staggerContainer = { animate: { transition: { staggerChildren: 0.2, }, }, }; const categories = [ "Bars", "Barks", "Pralines", "Spreads", "Dragees", "Gelatos", ]; const partnerImages = [ "/partners/p1.svg", "/partners/p2.svg", "/partners/p3.svg", "/partners/p4.svg", ]; export default function Home() { const [currentCategory, setCurrentCategory] = useState(0); const categoriesSectionRef = useRef(null); const currentCategoryRef = useRef(currentCategory); // Update ref when currentCategory changes useEffect(() => { currentCategoryRef.current = currentCategory; }, [currentCategory]); // Optimized wheel event handler const handleWheel = useCallback((e: WheelEvent) => { e.preventDefault(); // Determine scroll direction if (e.deltaY > 0) { // Scroll down - next category if (currentCategoryRef.current < categories.length - 1) { setCurrentCategory((prev) => prev + 1); } } else if (e.deltaY < 0) { // Scroll up - previous category if (currentCategoryRef.current > 0) { setCurrentCategory((prev) => prev - 1); } } }, []); // Wheel event for scroll-based category switching useEffect(() => { const section = categoriesSectionRef.current; if (!section) return; let isScrolling = false; let scrollTimeout: NodeJS.Timeout; const onWheel = (e: WheelEvent) => { if (isScrolling) return; isScrolling = true; clearTimeout(scrollTimeout); handleWheel(e); // Reset scrolling flag after delay scrollTimeout = setTimeout(() => { isScrolling = false; }, 800); }; section.addEventListener("wheel", onWheel, { passive: false }); return () => { section.removeEventListener("wheel", onWheel); clearTimeout(scrollTimeout); }; }, [handleWheel]); const [spotlightIndex, setSpotlightIndex] = useState(0); useEffect(() => { const timer = setInterval(() => { setSpotlightIndex((prev) => (prev + 1) % partnerImages.length); }, 2500); return () => clearInterval(timer); }, []); // Memoize expensive components return (
{/* Brand Story */}
{/* Brand Story - Left Text */} Brand Story
Mozimo's journey is a passionate pursuit of crafting exceptional chocolate that celebrates the origin of each cocoa bean. We meticulously roast, crack, winnow, and refine beans in-house, using modern techniques to highlight their natural flavors. Each chocolate is a masterpiece, capturing the essence of cocoa in its purest form.
{/* Brand Story - Right Image */} Cocoa pods and beans - Mozimo chocolate ingredients
{/* Chocolate Tempering - Left Video */}
{/* Our Collections Section */}
Our Collections {[ { src: "/collection/cl1.svg", title: "Bestsellers", alt: "Bestsellers - Mozimo chocolate bars with geometric patterns", }, { src: "/collection/cl2.svg", title: "New Arrivals", alt: "New Arrivals - Stacked chocolate barks with nuts and toppings", }, { src: "/collection/cl3.svg", title: "Gift Collection", alt: "Gift Collection - Mozimo packaged chocolate products and gift items", }, ].map((item) => ( {item.alt}

{item.title}

))}
{/* Social Media Call to Action */} {/* In the Spotlight Section */}
In the Spotlight
{Array(12) .fill(0) .map((_, i) => { const imgIdx = i % partnerImages.length; const img = partnerImages[imgIdx]; return ( {`Partner ); })}
); }