From c2e8d68b478c5abdc14084d5c23b3a6ea6bd4da3 Mon Sep 17 00:00:00 2001 From: Marco Pedone Date: Tue, 24 Mar 2026 12:03:31 +0100 Subject: [PATCH] feat: add AnniversaryBanner component with visibility animation and update Home page layout --- apps/infoalloggi/src/components/banners.tsx | 118 +++++++++++++++++- .../src/components/frequent_searches.tsx | 2 +- .../src/components/navbar/mobile-nav.tsx | 4 +- apps/infoalloggi/src/pages/index.tsx | 16 +-- 4 files changed, 129 insertions(+), 11 deletions(-) diff --git a/apps/infoalloggi/src/components/banners.tsx b/apps/infoalloggi/src/components/banners.tsx index 8ba1587..9c10e49 100644 --- a/apps/infoalloggi/src/components/banners.tsx +++ b/apps/infoalloggi/src/components/banners.tsx @@ -2,7 +2,7 @@ import { getCookie, setCookie } from "cookies-next/client"; import { add } from "date-fns"; import { X } from "lucide-react"; import Link from "next/link"; -import { type MouseEvent, useEffect, useState } from "react"; +import { type MouseEvent, useEffect, useRef, useState } from "react"; import { IconMatrix, type IconType } from "~/components/IconComponents"; import { cn } from "~/lib/utils"; import type { Banners } from "~/schemas/public/Banners"; @@ -116,3 +116,119 @@ export const BannerFactory = (bannerData: Banners) => { }; return ; }; + +export function AnniversaryBanner() { + const [isVisible, setIsVisible] = useState(false); + const bannerRef = useRef(null); + const fundingDate = new Date("2000-08-01"); + const currentDate = new Date(); + const yearsOfExperience = + currentDate.getFullYear() - fundingDate.getFullYear(); + + useEffect(() => { + const observer = new IntersectionObserver( + ([entry]) => { + if (entry?.isIntersecting) { + setIsVisible(true); + } + }, + { threshold: 0.3 }, + ); + + if (bannerRef.current) { + observer.observe(bannerRef.current); + } + + return () => observer.disconnect(); + }, []); + + return ( +
+ {/* Decorative background "25" */} +
+ {yearsOfExperience} +
+ + {/* Main content - horizontal layout */} +
+ {/* Left: Badge + Number */} +
+
+
+ + Da più di + +
+
+ + {yearsOfExperience} + + + Anni + +
+
+ + {/* Center: Tagline */} +
+

+ Un quarto di secolo di{" "} + eccellenza,{" "} + innovazione, e{" "} + fiducia +

+
+ + {/* Right: Mini stats */} +
+ + +
+
+ + {/* Accent lines */} +
+
+
+ ); +} + +function Stat({ value, label }: { value: string; label: string }) { + return ( +
+ + {value} + + + {label} + +
+ ); +} diff --git a/apps/infoalloggi/src/components/frequent_searches.tsx b/apps/infoalloggi/src/components/frequent_searches.tsx index 52301cb..64b47f0 100644 --- a/apps/infoalloggi/src/components/frequent_searches.tsx +++ b/apps/infoalloggi/src/components/frequent_searches.tsx @@ -21,7 +21,7 @@ export const FrequentSearches = () => { const { locale } = useTranslation(); const t = locale === "en" ? en : it; return ( - + {t.title} diff --git a/apps/infoalloggi/src/components/navbar/mobile-nav.tsx b/apps/infoalloggi/src/components/navbar/mobile-nav.tsx index fad2f3b..0ca7c52 100644 --- a/apps/infoalloggi/src/components/navbar/mobile-nav.tsx +++ b/apps/infoalloggi/src/components/navbar/mobile-nav.tsx @@ -39,7 +39,7 @@ export function MobileNav({ }: MobileNavProps) { const session = useSession(); const { t } = useTranslation(); - const verySmallScreen = useMediaQuery("(max-width: 320px)"); + const verySmallScreen = useMediaQuery("(max-width: 280px)"); return ( <> @@ -127,7 +127,7 @@ export function MobileNav({ {verySmallScreen ? ( diff --git a/apps/infoalloggi/src/pages/index.tsx b/apps/infoalloggi/src/pages/index.tsx index 3e65640..b7b7f24 100644 --- a/apps/infoalloggi/src/pages/index.tsx +++ b/apps/infoalloggi/src/pages/index.tsx @@ -3,9 +3,9 @@ import type { NextPage } from "next"; import Head from "next/head"; import Link from "next/link"; import { AccordionComp } from "~/components/accordionComp"; +import { AnniversaryBanner } from "~/components/banners"; import { CodiceBox } from "~/components/codiceRicerca"; import { ComeFunziona } from "~/components/expand_guida"; -import { FrequentSearches } from "~/components/frequent_searches"; import { PricingChoice } from "~/components/prezzi"; import { HeroSvg, LogoSvg } from "~/components/svgs"; import { env } from "~/env"; @@ -42,8 +42,8 @@ const Home: NextPage = () => {
-
-
+
+
@@ -51,13 +51,15 @@ const Home: NextPage = () => {
-
- -
+ +
+ + {/* */} +