From ef693589bce076d312d67ae220ec2299b5192dc5 Mon Sep 17 00:00:00 2001 From: Vadym Samoilenko Date: Thu, 28 May 2026 16:51:24 +0100 Subject: [PATCH] fix(header,accordion): liquid-glass header + progress bar animation Co-Authored-By: Claude Sonnet 4.6 --- src/app/globals.css | 9 ++++++ src/components/layout/HeaderClient.tsx | 6 ++-- src/components/sections/WhyParents.tsx | 38 +++++++++++++++++++++----- 3 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/app/globals.css b/src/app/globals.css index 9045ea7..25fcfc4 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -24,3 +24,12 @@ /* Brand shadow used on cards, buttons */ --shadow-brand: 0px 4px 60px rgba(242, 139, 74, 0.25); } + +@keyframes progress-fill { + from { + width: 0%; + } + to { + width: 100%; + } +} diff --git a/src/components/layout/HeaderClient.tsx b/src/components/layout/HeaderClient.tsx index e823a16..97f113a 100644 --- a/src/components/layout/HeaderClient.tsx +++ b/src/components/layout/HeaderClient.tsx @@ -39,8 +39,10 @@ export function HeaderClient({ navLinks, ctaLabel, ctaHref, logo }: HeaderClient
diff --git a/src/components/sections/WhyParents.tsx b/src/components/sections/WhyParents.tsx index ad52235..9b6dd31 100644 --- a/src/components/sections/WhyParents.tsx +++ b/src/components/sections/WhyParents.tsx @@ -45,27 +45,39 @@ interface WhyParentsProps { title?: string } +const INTERVAL = 4000 + export function WhyParents({ items, sideGallery: _sideGallery, title }: WhyParentsProps) { const [openIndex, setOpenIndex] = useState(0) + const [progressKey, setProgressKey] = useState(0) const autoTimer = useRef | null>(null) + const lenRef = useRef(0) const activeItems = items && items.length > 0 ? items : STATIC_ITEMS useEffect(() => { - autoTimer.current = setInterval(() => { - setOpenIndex((prev) => (prev + 1) % activeItems.length) - }, 4000) + lenRef.current = activeItems.length + }) + + useEffect(() => { + const tick = () => { + setOpenIndex((prev) => (prev + 1) % lenRef.current) + setProgressKey((k) => k + 1) + } + autoTimer.current = setInterval(tick, INTERVAL) return () => { if (autoTimer.current) clearInterval(autoTimer.current) } - }, [activeItems.length]) + }, []) function handleItemClick(i: number) { setOpenIndex(i) + setProgressKey((k) => k + 1) if (autoTimer.current) clearInterval(autoTimer.current) autoTimer.current = setInterval(() => { - setOpenIndex((prev) => (prev + 1) % activeItems.length) - }, 4000) + setOpenIndex((prev) => (prev + 1) % lenRef.current) + setProgressKey((k) => k + 1) + }, INTERVAL) } return ( @@ -89,7 +101,7 @@ export function WhyParents({ items, sideGallery: _sideGallery, title }: WhyParen
+ {/* Progress bar — CSS animation, keyed to reset on each advance */} + {isOpen && ( +
+
+
+ )} ) })}