/** * Hero Section Template * * Patterns for creating impactful hero sections with: * - 3D backgrounds (particle sphere, data globe, racing) * - Massive typography with scramble effects * - Animated CTAs * - Status badges */ import React, { useMemo, useRef, useState, useEffect } from 'react'; import { Canvas, useFrame } from '@react-three/fiber'; import { Stars } from '@react-three/drei'; import { motion } from 'framer-motion'; import { ChevronRight, Zap } from 'lucide-react'; import * as THREE from 'three'; // ============================================ // TEXT SCRAMBLE HOOK // ============================================ export const useTextScramble = (text: string, active: boolean = true) => { const [output, setOutput] = useState(''); const chars = '!<>-_\\/[]{}—=+*^?#'; useEffect(() => { if (!active) return; let iteration = 0; const interval = setInterval(() => { setOutput( text.split('').map((char, i) => { if (char === ' ') return ' '; if (i < iteration) return char; return chars[Math.floor(Math.random() * chars.length)]; }).join('') ); if (iteration >= text.length) clearInterval(interval); iteration += 1/3; }, 30); return () => clearInterval(interval); }, [text, active]); return output; }; // ============================================ // 3D BACKGROUNDS // ============================================ // Particle Sphere Background export const ParticleSphereBackground: React.FC<{ color?: string; count?: number; }> = ({ color = '#ff4d00', count = 3000 }) => { const pointsRef = useRef(null); const positions = useMemo(() => { const pos = new Float32Array(count * 3); for (let i = 0; i < count; i++) { const theta = Math.random() * Math.PI * 2; const phi = Math.acos(Math.random() * 2 - 1); const r = 2; pos[i * 3] = r * Math.sin(phi) * Math.cos(theta); pos[i * 3 + 1] = r * Math.sin(phi) * Math.sin(theta); pos[i * 3 + 2] = r * Math.cos(phi); } return pos; }, [count]); useFrame(() => { if (pointsRef.current) { pointsRef.current.rotation.y += 0.001; } }); return ( ); }; // Starfield Scene export const StarfieldScene: React.FC<{ particleColor?: string }> = ({ particleColor = '#ff4d00' }) => ( <> ); // ============================================ // UI COMPONENTS // ============================================ // Status Badge export const StatusBadge: React.FC<{ text: string; icon?: React.ReactNode; color?: string; pulse?: boolean; }> = ({ text, icon = , color = '#ff4d00', pulse = true }) => ( {pulse && (
)} {icon} {text} ); // Animated CTA Button export const CTAButton: React.FC<{ children: React.ReactNode; onClick?: () => void; variant?: 'primary' | 'secondary'; color?: string; icon?: React.ReactNode; }> = ({ children, onClick, variant = 'primary', color = '#ff4d00', icon = }) => ( {children} {icon && ( {icon} )} ); // ============================================ // HERO SECTION TEMPLATES // ============================================ // Template 1: Cyberpunk Hero export const CyberpunkHero: React.FC<{ title: string; subtitle?: string; badge?: string; primaryCTA?: { text: string; onClick: () => void }; secondaryCTA?: { text: string; onClick: () => void }; accentColor?: string; }> = ({ title, subtitle, badge = 'SYSTEM ONLINE', primaryCTA, secondaryCTA, accentColor = '#ff4d00', }) => { const scrambledTitle = useTextScramble(title, true); return (
{/* 3D Background */}
{/* Scanlines */}
{/* Content */}

{scrambledTitle}

{subtitle && (

{subtitle}

)}
{primaryCTA && ( {primaryCTA.text} )} {secondaryCTA && ( {secondaryCTA.text} )}
); }; // Template 2: Minimal Hero (no 3D) export const MinimalHero: React.FC<{ title: string; highlight?: string; subtitle?: string; accentColor?: string; }> = ({ title, highlight, subtitle, accentColor = '#ff4d00', }) => (
{title} {highlight && ( <>
{highlight} )}
{subtitle && ( {subtitle} )}
); // ============================================ // USAGE EXAMPLE // ============================================ /* import { CyberpunkHero } from './hero-section'; function LandingPage() { return ( {} }} secondaryCTA={{ text: 'Documentation', onClick: () => {} }} accentColor="#00f3ff" /> ); } */ export default { CyberpunkHero, MinimalHero, StatusBadge, CTAButton };