import React from "react"; import { useLocation } from "react-router-dom"; import Container from "@mui/material/Container"; import Box from "@mui/material/Box"; import Typography from "@mui/material/Typography"; import Paper from "@mui/material/Paper"; import Grid from "@mui/material/Grid"; import ChevronLeft from "@mui/icons-material/ChevronLeft"; import ChevronRight from "@mui/icons-material/ChevronRight"; import { Link } from "react-router-dom"; import SharedCarousel from "./SharedCarousel.js"; import { getCombinedAnimatedBorderStyles } from "../utils/animatedBorderStyles.js"; import { useTranslation } from 'react-i18next'; const MainPageLayout = () => { const location = useLocation(); const currentPath = location.pathname; const { t } = useTranslation(); const [starHovered, setStarHovered] = React.useState(false); // Determine which page we're on const isHome = currentPath === "/"; const isAktionen = currentPath === "/aktionen"; const isFiliale = currentPath === "/filiale"; // Add CSS animations for rotating stars React.useEffect(() => { const style = document.createElement('style'); style.textContent = ` @keyframes rotateClockwise { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } @keyframes rotateCounterClockwise { from { transform: rotate(0deg); } to { transform: rotate(-360deg); } } .star-rotate-slow-cw { animation: rotateClockwise 60s linear infinite; } .star-rotate-slow-ccw { animation: rotateCounterClockwise 45s linear infinite; } .star-rotate-medium-cw { animation: rotateClockwise 30s linear infinite; } `; document.head.appendChild(style); return () => { document.head.removeChild(style); }; }, []); // Get navigation config based on current page const getNavigationConfig = () => { if (isHome) { return { leftNav: { text: t('navigation.aktionen'), link: "/aktionen" }, rightNav: { text: t('navigation.filiale'), link: "/filiale" } }; } else if (isAktionen) { return { leftNav: { text: t('navigation.filiale'), link: "/filiale" }, rightNav: { text: t('navigation.home'), link: "/" } }; } else if (isFiliale) { return { leftNav: { text: t('navigation.home'), link: "/" }, rightNav: { text: t('navigation.aktionen'), link: "/aktionen" } }; } return { leftNav: null, rightNav: null }; }; const allTitles = { home: t('titles.filiale'), aktionen: t('titles.aktionen'), filiale: t('titles.home') }; // Define all content boxes for layered rendering const allContentBoxes = { home: [ { title: t('sections.address1'), image: "/assets/images/filiale1.jpg", bgcolor: "#e1f0d3", link: "/filiale" }, { title: t('sections.address2'), image: "/assets/images/filiale2.jpg", bgcolor: "#e8f5d6", link: "/filiale" } ], aktionen: [ { title: t('sections.oilPress'), image: "/assets/images/presse.jpg", bgcolor: "#e1f0d3", link: "/presseverleih" }, { title: t('sections.thcTest'), image: "/assets/images/purpl.jpg", bgcolor: "#e8f5d6", link: "/thc-test" } ], filiale: [ { title: t('sections.seeds'), image: "/assets/images/seeds.jpg", bgcolor: "#e1f0d3", link: "/Kategorie/Seeds" }, { title: t('sections.stecklinge'), image: "/assets/images/cutlings.jpg", bgcolor: "#e8f5d6", link: "/Kategorie/Stecklinge" } ] }; // Get opacity for each page layer const getOpacity = (pageType) => { if (pageType === "home" && isHome) return 1; if (pageType === "aktionen" && isAktionen) return 1; if (pageType === "filiale" && isFiliale) return 1; return 0; }; const navConfig = getNavigationConfig(); // Navigation text mapping for translation const navTexts = [ { key: 'aktionen', text: t('navigation.aktionen'), link: '/aktionen' }, { key: 'filiale', text: t('navigation.filiale'), link: '/filiale' }, { key: 'home', text: t('navigation.home'), link: '/' } ]; return ( {/* Main Navigation Header */} {/* Title for portrait phones - shown first */} {Object.entries(allTitles).map(([pageType, title]) => ( {title} ))} {/* Navigation container for portrait phones */} {/* Left Navigation - Layered rendering */} {navTexts.map((navItem, index) => { const isActive = navConfig.leftNav && navConfig.leftNav.text === navItem.text; const link = navItem.link; return ( {navItem.text} ); })} {/* Center Title - Layered rendering - Hidden on portrait phones, shown on larger screens */} {Object.entries(allTitles).map(([pageType, title]) => ( {title} ))} {/* Right Navigation - Layered rendering */} {navTexts.map((navItem, index) => { const isActive = navConfig.rightNav && navConfig.rightNav.text === navItem.text; const link = navItem.link; return ( {navItem.text} ); })} {/* Content Boxes - Layered rendering */} {Object.entries(allContentBoxes).map(([pageType, contentBoxes]) => ( {contentBoxes.map((box, index) => ( {/* Multi-pointed star for seeds box - moved to Grid level */} {index === 0 && pageType === "filiale" && ( setStarHovered(true)} onMouseLeave={() => setStarHovered(false)} > {/* Background star - slightly larger and rotated */} {/* Middle star - medium size with different rotation */} {/* Foreground star - main star with text */} {/* Text positioned in the center of the star */}
{t('sections.showUsPhoto')}
{/* Hover text */}
{t('sections.selectSeedRate')}
)} {/* Multi-pointed star for stecklinge box - bottom right */} {index === 1 && pageType === "filiale" && ( {/* Background star - slightly larger and rotated */} {/* Middle star - medium size with different rotation */} {/* Foreground star - main star with text */} {/* Text positioned in the center of the star */}
{t('sections.indoorSeason')}
)}
{/* Image loaded only when needed */} {getOpacity(pageType) === 1 && ( {box.title} )} {box.title}
))}
))}
{/* Shared Carousel */}
); }; export default MainPageLayout;