"use client"; import React, { useEffect, useRef } from "react"; import gsap from "gsap"; import { SplitText } from "gsap/SplitText"; import Image from "next/image"; import Button from "@/components/shared/Button"; import SecondaryButton from "@/components/shared/Secondary"; import Navbar from "@/components/shared/Navbar"; import MobileNavbar from "@/components/ui/mobile-navbar"; // Register plugins (once) gsap.registerPlugin(SplitText); const Hero = () => { // ── Refs ───────────────────────────────────────────────────────────────────── const containerRef = useRef(null); const headingRef = useRef(null); const subHeadingRef = useRef(null); const buttonWrapperRef = useRef(null); useEffect(() => { const ctx = gsap.context(() => { // ── 2. HEADING – char-by-char ─────────────────────────────────── if (!headingRef.current) return; const headingSplit = new SplitText(headingRef.current, { type: "words" }); gsap.fromTo( headingSplit.words, { yPercent: 120, opacity: 0 }, { yPercent: 0, opacity: 1, duration: 1.2, ease: "expo.out", stagger: 0.09, delay: 0.3, // after navbar } ); // ── 3. SUB-HEADING – char-by-char ─────────────────────────────── if (subHeadingRef.current) { const subSplit = new SplitText(subHeadingRef.current, { type: "words", }); gsap.fromTo( subSplit.words, { yPercent: 100, opacity: 0 }, { yPercent: 0, opacity: 1, duration: 1, ease: "expo.out", stagger: 0.04, delay: 0.6, // after heading } ); } // ── 4. BUTTONS – slide up ─────────────────────────────────────── const buttons = buttonWrapperRef.current?.children; if (buttons?.length) { gsap.fromTo( buttons, { y: 40, opacity: 0 }, { y: 0, opacity: 1, duration: 0.8, ease: "power3.out", stagger: 0.15, delay: 0.9, // after sub-heading } ); } }, containerRef); // ── Cleanup ──────────────────────────────────────────────────────── return () => ctx.revert(); }, []); return (
{/* ── Desktop Navbar (wrapped) ───────────────────────────────────── */} {/* ── Mobile Navbar (wrapped) ────────────────────────────────────── */} {/* ── Hero Content ───────────────────────────────────────────────── */}
{/* Heading */}

Trees can talk. We help you{" "} listen.

{/* Sub-heading */}

Whispering Trees shows you if a tree is healthy or thirsty — in real time. So you water only when needed, save money, and keep trees alive longer.

{/* Buttons */}
{/* Blob overlay */} overlay
); }; export default Hero;