diff --git a/src/components/Header.tsx b/src/components/Header.tsx index 20a854d..bef6144 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -74,6 +74,10 @@ const Header = ({ navItems }: HeaderProps) => { }; }, []); + useEffect(() => { + setIsMobileMenuOpen(false); + }, [pathname]); + return (
{/* Logo */} @@ -90,7 +94,7 @@ const Header = ({ navItems }: HeaderProps) => { {/* Right side - Navigation + controls */}
{/* Desktop Navigation */} -
+ ); } diff --git a/src/components/TeaserCarousel.tsx b/src/components/TeaserCarousel.tsx index e2da99c..badaafc 100644 --- a/src/components/TeaserCarousel.tsx +++ b/src/components/TeaserCarousel.tsx @@ -1,6 +1,6 @@ "use client"; -import { useState, useEffect, useCallback } from "react"; +import { useState, useEffect, useCallback, useRef } from "react"; import Image from "next/image"; import { Link } from "@/i18n/routing"; import { vipnagorgialla } from "@/components/Vipnagorgialla"; @@ -64,6 +64,7 @@ const slides: Slide[] = [ export default function TeaserCarousel() { const t = useTranslations("home.teaser"); const [current, setCurrent] = useState(0); + const intervalRef = useRef | null>(null); const next = useCallback( () => setCurrent((c) => (c + 1) % slides.length), @@ -71,66 +72,91 @@ export default function TeaserCarousel() { ); const prev = () => setCurrent((c) => (c - 1 + slides.length) % slides.length); - useEffect(() => { - const id = setInterval(next, 5000); - return () => clearInterval(id); + const restartAutoplay = useCallback(() => { + if (intervalRef.current) { + clearInterval(intervalRef.current); + } + intervalRef.current = setInterval(next, 5000); }, [next]); + useEffect(() => { + restartAutoplay(); + + return () => { + if (intervalRef.current) { + clearInterval(intervalRef.current); + } + }; + }, [restartAutoplay]); + + const headingOnRight = Boolean(slides[current]?.flip); + return (
- {/* Sliding track */} + {/* Slides (fade transition + hero lift effect) */}
-
- {slides.map((slide) => { - const title = t(`${slide.key}.title`); - const description = t(`${slide.key}.description`); - return ( -
- {/* Background image */} - {slide.imageAlt} - {/* Overlay */} -
+ {slides.map((slide, i) => { + const title = t(`${slide.key}.title`); + const description = t(`${slide.key}.description`); + const isActive = i === current; - {/* Content */} + return ( +
+ {/* Background image */} + {slide.imageAlt} + + {/* Overlay */} +
+ + {/* Content */} +
+ {/* Title + description at bottom */} +
+ +

+ {title} +

+ +

+ {description} +

+
+
+ + {/* Hero image */} +
- {/* Heading at top */} -

- {highlightLAN(t("heading"))} -

- {/* Title + description at bottom */} -
- -

- {title} -

- -

- {description} -

-
-
- {/* Hero image */} -
- ); - })} +
+ ); + })} + + {/* Floating heading (mobile) */} +
+

+ {highlightLAN(t("heading"))} +

+
+ + {/* Floating heading (desktop/tablet) */} +
+
+

+ {highlightLAN(t("heading"))} +

+
{/* Arrow buttons */}