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 { STAR_POLYGON_POINTS } from "../utils/starPolygon.js"; import { useTranslation } from 'react-i18next'; const HOME_STAR_LAYERS = [ { className: "star-rotate-slow-cw", size: 168 }, { className: "star-rotate-slow-ccw", size: 159 }, { className: "star-rotate-medium-cw", size: 150 }, ]; /** Teal/cyan stack for the right (Konfigurator) star — same motion, blue color scheme */ const TEAL_STAR_LAYERS = [ { className: "star-rotate-slow-ccw", size: 168 }, { className: "star-rotate-medium-cw", size: 159 }, { className: "star-rotate-slow-cw", size: 150 }, ]; /** Initial fill per variant (matches keyframe 0%) — avoids black flash before CSS animates */ const STAR_INITIAL_FILLS = { home: ["#B8860B", "#DAA520", "#FFD700"], filiale: ["#5F9EA0", "#7FCDCD", "#AFEEEE"], }; /** Injected in render (not useEffect) so first paint already has keyframes — avoids angle/color snap on load */ const STAR_DECORATION_CSS = ` @keyframes rotateClockwise { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } @keyframes rotateCounterClockwise { from { transform: rotate(0deg); } to { transform: rotate(-360deg); } } .star-rotate-slow-cw, .star-rotate-slow-ccw, .star-rotate-medium-cw { transform-box: fill-box; transform-origin: center; } .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; } .star-layer-svg-home { mix-blend-mode: screen; opacity: 0.92; filter: drop-shadow(3px 3px 6px rgba(0, 0, 0, 0.5)) drop-shadow(0 0 10px rgba(255, 215, 0, 0.6)) drop-shadow(0 0 20px rgba(255, 215, 0, 0.3)); } .star-layer-svg-filiale { mix-blend-mode: soft-light; opacity: 0.94; filter: drop-shadow(3px 3px 6px rgba(0, 0, 0, 0.5)) drop-shadow(0 0 10px rgba(127, 205, 205, 0.6)) drop-shadow(0 0 18px rgba(95, 158, 160, 0.35)); } .star-layer-svg { shape-rendering: geometricPrecision; transform: translateZ(0); } @keyframes starFillHome0 { 0%, 100% { fill: #B8860B; } 33% { fill: #FFD700; } 66% { fill: #DAA520; } } @keyframes starFillHome1 { 0%, 100% { fill: #DAA520; } 33% { fill: #B8860B; } 66% { fill: #FFD700; } } @keyframes starFillHome2 { 0%, 100% { fill: #FFD700; } 33% { fill: #DAA520; } 66% { fill: #B8860B; } } @keyframes starDriftHome0 { 0%, 100% { transform: rotate(20deg) translate(0px, 0px); } 50% { transform: rotate(20deg) translate(5px, -5px); } } @keyframes starDriftHome1 { 0%, 100% { transform: rotate(-25deg) translate(0px, 0px); } 50% { transform: rotate(-25deg) translate(-4px, 6px); } } @keyframes starDriftHome2 { 0%, 100% { transform: translate(0px, 0px); } 50% { transform: translate(3px, 4px); } } .star-layer-wrap.star-layer-home-0 { animation: starDriftHome0 6.5s ease-in-out infinite; animation-fill-mode: both; } .star-layer-wrap.star-layer-home-1 { animation: starDriftHome1 7s ease-in-out 0.4s infinite; animation-fill-mode: both; } .star-layer-wrap.star-layer-home-2 { animation: starDriftHome2 5.5s ease-in-out 0.8s infinite; animation-fill-mode: both; } .star-poly-home-0 { animation: starFillHome0 10s ease-in-out 0s infinite both; } .star-poly-home-1 { animation: starFillHome1 10s ease-in-out 1.1s infinite both; } .star-poly-home-2 { animation: starFillHome2 10s ease-in-out 2.2s infinite both; } @keyframes starFillFil0 { 0%, 100% { fill: #5F9EA0; } 33% { fill: #AFEEEE; } 66% { fill: #7FCDCD; } } @keyframes starFillFil1 { 0%, 100% { fill: #7FCDCD; } 33% { fill: #5F9EA0; } 66% { fill: #AFEEEE; } } @keyframes starFillFil2 { 0%, 100% { fill: #AFEEEE; } 33% { fill: #7FCDCD; } 66% { fill: #5F9EA0; } } @keyframes starDriftFil0 { 0%, 100% { transform: rotate(20deg) translate(0px, 0px); } 50% { transform: rotate(20deg) translate(4px, -4px); } } @keyframes starDriftFil1 { 0%, 100% { transform: rotate(-25deg) translate(0px, 0px); } 50% { transform: rotate(-25deg) translate(-5px, 5px); } } @keyframes starDriftFil2 { 0%, 100% { transform: translate(0px, 0px); } 50% { transform: translate(3px, 3px); } } .star-layer-wrap.star-layer-filiale-0 { animation: starDriftFil0 6.5s ease-in-out infinite; animation-fill-mode: both; } .star-layer-wrap.star-layer-filiale-1 { animation: starDriftFil1 7s ease-in-out 0.4s infinite; animation-fill-mode: both; } .star-layer-wrap.star-layer-filiale-2 { animation: starDriftFil2 5.5s ease-in-out 0.8s infinite; animation-fill-mode: both; } .star-poly-filiale-0 { animation: starFillFil0 10s ease-in-out 0s infinite both; } .star-poly-filiale-1 { animation: starFillFil1 10s ease-in-out 1.1s infinite both; } .star-poly-filiale-2 { animation: starFillFil2 10s ease-in-out 2.2s infinite both; } `; const StarDecorationLayers = ({ layers, variant }) => ( <> {layers.map(({ className, size }, i) => { const half = size / 2; const initialFill = STAR_INITIAL_FILLS[variant][i]; return (
); })} ); const ContentBox = ({ box, index, pageType, starHovered, setStarHovered, opacity, translatedContent }) => ( {index === 0 && pageType === "home" && (
{translatedContent.outdoorSeason}
{translatedContent.selectSeedRate}
)} {index === 1 && pageType === "home" && (
{translatedContent.buildYourSet}
)}
setStarHovered(true) : undefined } onMouseLeave={ pageType === "home" && index === 0 ? () => setStarHovered(false) : undefined } > {opacity === 1 && ( {box.title} )} {box.title}
); const MainPageLayout = () => { const location = useLocation(); const currentPath = location.pathname; const { t } = useTranslation(); const [starHovered, setStarHovered] = React.useState(false); const translatedContent = { buildYourSet: t('sections.buildYourSet'), selectSeedRate: t('sections.selectSeedRate'), outdoorSeason: t('sections.outdoorSeason') }; const isHome = currentPath === "/"; const isAktionen = currentPath === "/aktionen"; const isFiliale = currentPath === "/filiale"; const getNavigationConfig = () => { if (isHome) return { leftNav: { text: t('navigation.aktionen'), link: "/aktionen" }, rightNav: { text: t('navigation.filiale'), link: "/filiale" } }; if (isAktionen) return { leftNav: { text: t('navigation.filiale'), link: "/filiale" }, rightNav: { text: t('navigation.home'), link: "/" } }; 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.home'), aktionen: t('titles.aktionen'), filiale: t('titles.filiale') }; const allContentBoxes = { home: [ { title: t('sections.seeds'), image: "/assets/images/seeds.avif", bgcolor: "#e1f0d3", link: "/Kategorie/Seeds" }, { title: t('sections.konfigurator'), image: "/assets/images/konfigurator.avif", bgcolor: "#e8f5d6", link: "/Konfigurator" } ], aktionen: [ { title: t('sections.oilPress'), image: "/assets/images/presse.jpg", bgcolor: "#e1f0d3", link: "/Artikel/Graveda-10t-presse-tagesmiete-inkl-prepress-vorpressform" }, { title: t('sections.thcTest'), image: "/assets/images/purpl.jpg", bgcolor: "#e8f5d6", link: "/Artikel/1x-messung-purplpro-thc-cbd-restfeuchte-wasseraktivitaet" } ], filiale: [ { 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" } ] }; 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(); 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 ( {Object.entries(allTitles).map(([pageType, title]) => ( {title} ))} {navTexts.map((navItem, index) => { const isActive = navConfig.leftNav && navConfig.leftNav.text === navItem.text; return ( {navItem.text} ); })} {Object.entries(allTitles).map(([pageType, title]) => ( {title} ))} {navTexts.map((navItem, index) => { const isActive = navConfig.rightNav && navConfig.rightNav.text === navItem.text; return ( {navItem.text} ); })} {Object.entries(allContentBoxes).map(([pageType, contentBoxes]) => ( {contentBoxes.map((box, index) => ( ))} ))} ); }; export default MainPageLayout;