"use client"; import { useState, useEffect, useCallback } from "react"; import ContactPopup from '@/components/common/ContactPopup/ContactPopup'; const features = [ { img: "/assets/img/home/section5/conversion.webp", title: "Conversion-Focused Website Architecture", desc: "We design every page with one goal — turning visitors into leads or customers. From clear CTAs to strategic layout flow, your website will guide users toward action.", }, { img: "/assets/img/home/section5/speed.webp", title: "Speed & Performance Optimized", desc: "A slow website kills conversions. We build lightweight, optimized websites that load fast, improve user experience, and boost your Google rankings.", }, { img: "/assets/img/home/section5/seo.webp", title: "SEO-Ready Development", desc: "Your website is built with clean code, proper structure, meta setup, schema basics, and search-friendly URLs — helping you rank better on Google from day one.", }, { img: "/assets/img/home/section5/mobile.webp", title: "Mobile-First & Fully Responsive", desc: "Over 70% of traffic comes from mobile. We ensure your website looks perfect and functions smoothly on smartphones, tablets, and desktops.", } ]; // Group features into pairs (columns of 2 cards each) const columns: typeof features[] = []; for (let i = 0; i < features.length; i += 2) { columns.push(features.slice(i, i + 2)); } const KeyFeatures = () => { const [currentIndex, setCurrentIndex] = useState(0); const [visibleCols, setVisibleCols] = useState(2); const [isContactOpen, setIsContactOpen] = useState(false); const totalCols = columns.length; // 2 columns useEffect(() => { const handleResize = () => { if (window.innerWidth <= 576) setVisibleCols(1); else setVisibleCols(2); }; handleResize(); window.addEventListener("resize", handleResize); return () => window.removeEventListener("resize", handleResize); }, []); const maxIndex = Math.max(0, totalCols - visibleCols); const handleNext = useCallback(() => { setCurrentIndex((prev) => (prev < maxIndex ? prev + 1 : 0)); }, [maxIndex]); const handlePrev = useCallback(() => { setCurrentIndex((prev) => (prev > 0 ? prev - 1 : maxIndex)); }, [maxIndex]); // Auto-slide every 5s useEffect(() => { const timer = setInterval(handleNext, 5000); return () => clearInterval(timer); }, [handleNext]); // Clamp index on resize useEffect(() => { if (currentIndex > maxIndex) setCurrentIndex(maxIndex); }, [maxIndex, currentIndex]); return (
{/* Left – Single Full Image */}
Key Features
{/* Right – Slider */}

Key Features

{columns.map((column, colIdx) => (
{column.map((feature, idx) => (
{feature.title}
{feature.title}

{feature.desc}

))} {column.length < 2 &&
}
))}
{/* Dots */}
{Array.from({ length: maxIndex + 1 }).map((_, idx) => (
setCurrentIndex(idx)} /> ))}
{/* Controls + CTA */}
setIsContactOpen(false)} />
); }; export default KeyFeatures;