|
| 1 | +"use client"; |
| 2 | + |
| 3 | +import { useTheme } from "next-themes"; |
| 4 | +import { useEffect, useState } from "react"; |
| 5 | +import { PixelBlast } from "./PixelBlast"; |
| 6 | + |
| 7 | +export function HeroSection({ children }: { children: React.ReactNode }) { |
| 8 | + const { resolvedTheme } = useTheme(); |
| 9 | + const [mounted, setMounted] = useState(false); |
| 10 | + const [isMobile, setIsMobile] = useState(false); |
| 11 | + |
| 12 | + useEffect(() => { |
| 13 | + setMounted(true); |
| 14 | + const check = () => setIsMobile(window.innerWidth < 768); |
| 15 | + check(); |
| 16 | + window.addEventListener("resize", check, { passive: true }); |
| 17 | + return () => window.removeEventListener("resize", check); |
| 18 | + }, []); |
| 19 | + |
| 20 | + const pixelColor = resolvedTheme === "dark" ? "#79C476" : "#5fa05c"; |
| 21 | + const pixelSize = isMobile ? 5 : 3; |
| 22 | + const patternDensity = isMobile ? 0.72 : 0.88; |
| 23 | + const edgeFade = isMobile ? 0.42 : 0.28; |
| 24 | + |
| 25 | + return ( |
| 26 | + // pb-24 absorbs the visual gap between Hero and Features so the |
| 27 | + // PixelBlast canvas covers it — no bleed needed, no z-index fights. |
| 28 | + <div className="relative pb-44"> |
| 29 | + {/* PixelBlast: strictly inside this container. Only rendered after |
| 30 | + hydration to prevent the SSR white-flash. */} |
| 31 | + {mounted && ( |
| 32 | + <PixelBlast |
| 33 | + color={pixelColor} |
| 34 | + variant="circle" |
| 35 | + pixelSize={pixelSize} |
| 36 | + patternScale={2.5} |
| 37 | + patternDensity={patternDensity} |
| 38 | + speed={0.4} |
| 39 | + edgeFade={edgeFade} |
| 40 | + enableRipples={true} |
| 41 | + rippleIntensityScale={1.1} |
| 42 | + rippleSpeed={0.3} |
| 43 | + rippleThickness={0.12} |
| 44 | + transparent={true} |
| 45 | + /> |
| 46 | + )} |
| 47 | + |
| 48 | + {/* Hero content */} |
| 49 | + <div className="relative z-10">{children}</div> |
| 50 | + |
| 51 | + {/* Bottom fade — purely inside the section, never touches Features. |
| 52 | + Tailwind dark: avoids any JS-driven hydration colour flash. */} |
| 53 | + <div className="absolute bottom-0 left-0 right-0 h-44 pointer-events-none z-20 bg-gradient-to-b from-transparent to-white dark:to-gray-950" /> |
| 54 | + </div> |
| 55 | + ); |
| 56 | +} |
0 commit comments