'use client'; import Image from 'next/image'; import { useState, useEffect } from 'react'; import FadeInSection from './FadeInSection'; import { ChevronLeft, ChevronRight } from 'lucide-react'; type ProjectsSectionProps = { onCatalogClick?: () => void; }; const projects = [ { id: 1, title: 'Гармония', description: 'Общая площадь 200 кв.м.', images: [ { type: 'facade', src: '/images/garmony.png', alt: 'Фасад дома Гармония' }, { type: 'plan', src: '/images/2.jpg', alt: 'Планировка 1 этажа' }, { type: 'plan', src: '/images/3.jpg', alt: 'Планировка 2 этажа' } ], file: '/projects/garmony.pdf', }, { id: 2, title: 'Горизонт', description: 'Общая площадь 360 кв.м.', images: [ { type: 'facade', src: '/images/gorizont.png', alt: 'Фасад дома Горизонт' }, { type: 'plan', src: '/images/22.jpg', alt: 'Планировка 1 этажа' }, { type: 'plan', src: '/images/33.jpg', alt: 'Планировка 2 этажа' } ], file: '/projects/gorizont.pdf', }, { id: 3, title: 'Европейский квартал', description: 'Общая площадь 120 кв.м.', images: [ { type: 'facade', src: '/images/filimonov.png', alt: 'Фасад дома Европейский квартал' }, { type: 'plan', src: '/images/333.jpg', alt: 'Планировка дома' } ], file: '/projects/filimonov.pdf', }, { id: 4, title: 'Проект 12', description: 'Общая площадь 100 кв.м.', images: [ { type: 'facade', src: '/images/moronchov.png', alt: 'Фасад дома Проект 12' }, { type: 'plan', src: '/images/3333.jpg', alt: 'Планировка дома' } ], file: '/projects/moronchov.pdf', }, { id: 5, title: 'Ранчо', description: 'Общая площадь 96 кв.м.', images: [ { type: 'facade', src: '/images/rancho.png', alt: 'Фасад дома Ранчо' }, { type: 'plan', src: '/images/111.jpg', alt: 'Планировка 1 этажа' }, { type: 'plan', src: '/images/222.jpg', alt: 'Планировка 2 этажа' } ], file: '/projects/rancho.pdf', }, { id: 6, title: 'Тихие Зори', description: 'Общая площадь 130 кв.м.', images: [ { type: 'facade', src: '/images/zori.png', alt: 'Фасад дома Тихие Зори' }, { type: 'plan', src: '/images/122.jpg', alt: 'Планировка дома' } ], file: '/projects/zori.pdf', }, { id: 7, title: 'Уютное гнездышко', description: 'Общая площадь 98 кв.м.', images: [ { type: 'facade', src: '/images/gnezdo.png', alt: 'Фасад дома Уютное гнездышко' }, { type: 'plan', src: '/images/3333.jpg', alt: 'Планировка дома' } ], file: '/projects/gnezdo.pdf', }, { id: 8, title: 'Аура', description: 'Общая площадь 73 кв.м.', images: [ { type: 'facade', src: '/images/aura.png', alt: 'Фасад дома Аура' }, { type: 'plan', src: '/images/444.jpg', alt: 'Планировка 1 этажа' }, { type: 'plan', src: '/images/555.jpg', alt: 'Планировка 2 этажа' } ], file: '/projects/aura.pdf', }, { id: 9, title: 'Надежда', description: 'Общая площадь 100 кв.м.', images: [ { type: 'facade', src: '/images/nade.png', alt: 'Фасад дома Надежда' }, { type: 'plan', src: '/images/666.jpg', alt: 'Планировка дома' } ], file: '/projects/nade.pdf', }, ]; // Компонент внутреннего слайдера для каждого проекта const ProjectImageSlider = ({ project }: { project: typeof projects[0] }) => { const [currentImageIndex, setCurrentImageIndex] = useState(0); const handlePreviousImage = () => { setCurrentImageIndex(prev => prev === 0 ? project.images.length - 1 : prev - 1 ); }; const handleNextImage = () => { setCurrentImageIndex(prev => prev === project.images.length - 1 ? 0 : prev + 1 ); }; const currentImage = project.images[currentImageIndex]; const isFloorPlan = currentImage.type === 'floorplan'; return (
{/* Фон для планировок */} {isFloorPlan && (
)}
{/* Текущее изображение */} {currentImage.alt} {/* Навигация по изображениям */} {project.images.length > 1 && ( <> {/* Индикаторы изображений */}
{project.images.map((_, index) => (
{/* Тип изображения */}
{currentImage.type === 'facade' ? '🏠 Фасад' : '📐 Планировка'}
)} {/* Декоративные элементы */}
); }; const ProjectsSection = ({ onCatalogClick }: ProjectsSectionProps) => { const [currentIndex, setCurrentIndex] = useState(0); // Количество проектов для показа на разных экранах const getItemsPerView = () => { if (typeof window !== 'undefined') { if (window.innerWidth >= 1024) return 3; // lg и больше if (window.innerWidth >= 768) return 2; // md return 1; // sm } return 3; // по умолчанию }; const [itemsPerView, setItemsPerView] = useState(3); // Обновляем количество элементов при изменении размера экрана useEffect(() => { const handleResize = () => { setItemsPerView(getItemsPerView()); setCurrentIndex(0); // Сбрасываем индекс при изменении размера }; // Устанавливаем начальное значение setItemsPerView(getItemsPerView()); window.addEventListener('resize', handleResize); return () => window.removeEventListener('resize', handleResize); }, []); // Общее количество слайдов (групп проектов) const totalSlides = Math.ceil(projects.length / itemsPerView); const handlePrevious = () => { setCurrentIndex(prev => Math.max(0, prev - 1)); }; const handleNext = () => { setCurrentIndex(prev => Math.min(totalSlides - 1, prev + 1)); }; // Получаем проекты для текущего слайда const startIndex = currentIndex * itemsPerView; const visibleProjects = projects.slice(startIndex, startIndex + itemsPerView); return (
{/* Статичный фон */}
{/* Заголовок секции */}

Каталог проектов

{/* Карусель */}
{/* Навигационные кнопки */} {/* Контейнер проектов */}
{visibleProjects.map((project, index) => ( {/* Фон */}
{/* Слайдер изображений */} {/* Информация о проекте */}

{project.title}

{project.description}

{/* Дополнительная информация */}
Доступен для строительства
📐 {project.images.length - 1} планировки
{/* Декоративный элемент */}
))}
{/* Индикаторы */}
{Array.from({ length: totalSlides }, (_, index) => (
{/* Призыв к действию */}
); }; export default ProjectsSection;