Files
webb/src/components/sections/HeroSection.tsx
T

552 lines
23 KiB
TypeScript
Raw Normal View History

'use client';
import React, { useState, useEffect, useRef } from 'react';
import Link from 'next/link';
import * as THREE from 'three';
import {
Sparkles,
ArrowRight,
Smartphone,
ShieldCheck,
Zap,
Check,
Sliders,
ArrowDown,
UploadCloud,
Scissors,
Wand2,
Palette,
Layers,
LockKeyhole
} from 'lucide-react';
import { ToolItem, VariantSpec, resolveLocalised } from '@/types';
import { TextAnimate } from '@/components/magicui/text-animate';
import { BorderBeam } from '@/components/magicui/border-beam';
import { Particles } from '@/components/magicui/particles';
interface HeroSectionProps {
title?: Record<string, string> | string;
badge?: Record<string, string> | string;
subtitle?: Record<string, string> | string;
primaryCta?: { label?: Record<string, string> | string; href?: string };
secondaryCta?: { label?: Record<string, string> | string; href?: string };
variant?: string;
tool?: ToolItem;
homeApp?: any;
variants?: VariantSpec[];
locale?: string;
}
const HERO_SHOWCASE_TABS = [
{
id: 'enhancer',
label: '4K Super-Resolution',
icon: Wand2,
badge: '4K RESTORATION',
beforeUrl: '/management/pages/home/media/landscape_enhancer_before.jpg',
afterUrl: '/management/pages/home/media/landscape_enhancer_after.jpg',
tagline: 'Sub-pore facial reconstruction & 4K crystal super-resolution.',
href: '/tools/photo-enhancer',
},
{
id: 'blemish',
label: 'Blemish & Pore Retouch',
icon: Sparkles,
badge: 'STUDIO RETOUCH',
beforeUrl: '/management/pages/home/media/landscape_blemish_before.jpg',
afterUrl: '/management/pages/home/media/landscape_blemish_after.jpg',
tagline: 'Erase acne, redness & blemishes while preserving authentic pores.',
href: '/tools/blemish-remover',
},
{
id: 'restore',
label: 'Vintage Photo Restore',
icon: Palette,
badge: 'ARCHIVAL AI',
beforeUrl: '/management/pages/home/media/landscape_restore_before.jpg',
afterUrl: '/management/pages/home/media/landscape_restore_after.jpg',
tagline: 'Repair severe scratches, faded contrast, and restore historical iris clarity.',
href: '/tools/old-photo-restorer',
},
{
id: 'teeth',
label: 'Teeth Whitener AI',
icon: Layers,
badge: 'SMILE ENHANCE',
beforeUrl: '/management/pages/home/media/landscape_teeth_before.jpg',
afterUrl: '/management/pages/home/media/landscape_teeth_after.jpg',
tagline: 'Brighten tooth enamel with natural luminosity and gum tone preservation.',
href: '/tools/teeth-whitener',
},
];
export function HeroSection({
title,
badge,
subtitle,
primaryCta,
secondaryCta,
tool,
variants = [],
locale = 'en',
}: HeroSectionProps) {
const resolvedSubtitle = resolveLocalised(subtitle, locale) || 'Studio-grade neural vision tools with zero sign-up and zero data retention. Process high-resolution portraits, precision cutouts, and 4K restorations directly in your browser.';
const resolvedBadge = resolveLocalised(badge, locale) || 'All-in-One Neural AI Studio';
const primaryCtaLabel = resolveLocalised(primaryCta?.label, locale, 'Explore Our Tools');
const primaryCtaHref = primaryCta?.href || '#our-tools';
const secondaryCtaLabel = resolveLocalised(secondaryCta?.label, locale, 'Recommended Apps');
const secondaryCtaHref = secondaryCta?.href || '#recommended-apps';
// Tool detail page hero
if (tool) {
return (
<section className="relative overflow-hidden bg-white border-b border-slate-900/[0.08] pt-24 sm:pt-28 pb-12 sm:pb-16 px-4 sm:px-6 lg:px-10">
<div className="max-w-[1640px] mx-auto">
<nav className="flex items-center gap-2 text-xs font-mono text-slate-500 mb-8">
<Link href="/" className="hover:text-blue-700 transition-colors">Home</Link>
<span>/</span>
<Link href="/tools" className="hover:text-blue-700 transition-colors">Tools</Link>
<span>/</span>
<span className="text-slate-900 font-semibold">{resolveLocalised(tool.name, locale)}</span>
</nav>
<div className="text-center max-w-4xl mx-auto mb-10 sm:mb-12">
<div className="inline-flex items-center gap-2 px-3 py-1 rounded-full text-xs font-mono font-semibold tracking-wider uppercase text-blue-700 bg-blue-50 border border-blue-200">
<Sparkles className="w-3.5 h-3.5 text-blue-600" />
<span>Studio Neural Tool</span>
</div>
<h1 className="mt-4 text-3xl sm:text-5xl lg:text-6xl font-display font-black tracking-tight text-slate-900 leading-[1.08]">
<TextAnimate animation="slideLeft" by="word">{resolveLocalised(tool.name, locale)}</TextAnimate>
</h1>
<p className="mt-4 text-base sm:text-lg leading-relaxed text-slate-600 max-w-2xl mx-auto font-sans">
<TextAnimate animation="fadeIn" by="word" delay={0.15}>{resolveLocalised(tool.summary, locale)}</TextAnimate>
</p>
<div className="mt-6 flex flex-wrap items-center justify-center gap-2 sm:gap-3 text-xs font-medium text-slate-600">
<span className="inline-flex items-center gap-1.5 px-3 py-1 rounded-full bg-slate-100">
<ShieldCheck className="h-3.5 w-3.5 text-emerald-600" />
<span>Zero Storage</span>
</span>
<span className="inline-flex items-center gap-1.5 px-3 py-1 rounded-full bg-slate-100">
<LockKeyhole className="h-3.5 w-3.5 text-blue-600" />
<span>Client-Side Processing</span>
</span>
<span className="inline-flex items-center gap-1.5 px-3 py-1 rounded-full bg-slate-100">
<Check className="h-3.5 w-3.5 text-indigo-600" />
<span>Lossless Quality</span>
</span>
</div>
</div>
</div>
</section>
);
}
// -------------------------------------------------------------
// High-Impact AI Ease Style Hero View
// -------------------------------------------------------------
return (
<section className="relative isolate min-h-[96vh] flex flex-col justify-center items-center text-center overflow-hidden bg-[#FAF8F5] pt-24 pb-20 px-4 sm:px-6 md:px-8 lg:px-10">
{/* 1. Background MagicUI Particles */}
<Particles
className="absolute inset-0 -z-20 opacity-40"
quantity={60}
color="#3b82f6"
size={0.7}
/>
{/* 2. Interactive 3D WebGL Canvas Rotating Behind */}
<div className="absolute inset-0 -z-10 flex items-center justify-center pointer-events-none select-none overflow-hidden">
<div className="w-[600px] h-[600px] sm:w-[900px] sm:h-[900px] lg:w-[1200px] lg:h-[1200px] opacity-60 transform-gpu transition-opacity duration-1000">
<Hero3DCanvas className="w-full h-full" />
</div>
</div>
{/* 3. Ambient Atmospheric Glows */}
<div
className="absolute inset-0 -z-30 pointer-events-none"
style={{
background: 'radial-gradient(circle at 50% 35%, rgba(37,99,235,0.12) 0%, rgba(14,165,233,0.06) 40%, transparent 70%)',
}}
/>
<div className="absolute inset-x-0 bottom-0 h-44 bg-gradient-to-t from-[#FAF8F5] to-transparent -z-10 pointer-events-none" />
{/* 4. Hero Content Container */}
<div className="relative z-10 max-w-[1640px] mx-auto flex flex-col items-center justify-center w-full">
{/* Subtle Elegant Pill Badge */}
<div className="inline-flex items-center gap-2 rounded-full border border-blue-500/20 bg-white/90 backdrop-blur-md px-4 py-1.5 text-xs font-mono font-medium tracking-wider uppercase text-blue-800 shadow-sm mb-6">
<span className="flex h-2 w-2 relative">
<span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-blue-400 opacity-75"></span>
<span className="relative inline-flex rounded-full h-2 w-2 bg-blue-600"></span>
</span>
<span>{resolvedBadge}</span>
</div>
{/* Editorial High-Impact Headline (SF Pro & Poppins) */}
<h1 className="text-4xl sm:text-6xl md:text-7xl lg:text-[5.25rem] font-display font-black tracking-[-0.04em] text-slate-900 leading-[1.05] max-w-5xl mx-auto text-balance">
<span className="block text-slate-900">
<TextAnimate animation="slideLeft" by="character">
Transform Photos with
</TextAnimate>
</span>
<span className="block mt-2 text-blue-600 font-extrabold">
<TextAnimate animation="slideLeft" by="character" delay={0.2}>
Next-Gen Neural AI
</TextAnimate>
</span>
</h1>
{/* Balanced, Readable Subtitle */}
<p className="mt-6 text-base sm:text-lg lg:text-xl text-slate-600 max-w-3xl mx-auto font-sans leading-relaxed text-pretty">
<TextAnimate animation="fadeIn" by="word" delay={0.25}>
{resolvedSubtitle}
</TextAnimate>
</p>
{/* Quick Feature Chips (aiease.ai style) */}
<div className="mt-7 flex flex-wrap items-center justify-center gap-2 text-xs font-mono font-semibold">
<Link href="/tools/background-remover" className="px-3.5 py-1.5 rounded-full bg-white/80 hover:bg-white text-slate-700 hover:text-blue-600 border border-slate-200/80 shadow-sm transition-all hover:scale-105">
🎯 Background Remover
</Link>
<Link href="/tools/photo-enhancer" className="px-3.5 py-1.5 rounded-full bg-white/80 hover:bg-white text-slate-700 hover:text-blue-600 border border-slate-200/80 shadow-sm transition-all hover:scale-105">
⚡ 4K Enhancer
</Link>
<Link href="/tools/blemish-remover" className="px-3.5 py-1.5 rounded-full bg-white/80 hover:bg-white text-slate-700 hover:text-blue-600 border border-slate-200/80 shadow-sm transition-all hover:scale-105">
✨ Blemish Cleaner
</Link>
<Link href="/tools/old-photo-restorer" className="px-3.5 py-1.5 rounded-full bg-white/80 hover:bg-white text-slate-700 hover:text-blue-600 border border-slate-200/80 shadow-sm transition-all hover:scale-105">
🎨 Vintage Restorer
</Link>
<Link href="/tools/cartoon-avatar" className="px-3.5 py-1.5 rounded-full bg-white/80 hover:bg-white text-slate-700 hover:text-blue-600 border border-slate-200/80 shadow-sm transition-all hover:scale-105">
🎭 Anime Avatar
</Link>
</div>
{/* Action Buttons */}
<div className="mt-8 flex flex-wrap items-center justify-center gap-4">
<a
href={primaryCtaHref}
className="group inline-flex items-center gap-3 rounded-full bg-gradient-to-r from-slate-950 via-slate-900 to-indigo-950 px-8 py-4 text-xs sm:text-sm font-bold text-white border border-white/15 shadow-xl shadow-slate-900/20 transition-all duration-300 hover:scale-[1.03] hover:from-blue-600 hover:to-indigo-600 active:scale-95"
>
<span>{primaryCtaLabel}</span>
<ArrowDown className="w-4 h-4 transition-transform group-hover:translate-y-0.5" />
</a>
<a
href={secondaryCtaHref}
className="inline-flex items-center gap-2.5 rounded-full border border-slate-300/80 bg-white/90 backdrop-blur-md px-7 py-4 text-xs sm:text-sm font-semibold text-slate-800 shadow-sm transition-all duration-300 hover:scale-[1.03] hover:border-blue-400 hover:text-blue-600 hover:bg-white active:scale-95"
>
<Smartphone className="w-4 h-4 text-blue-600" />
<span>{secondaryCtaLabel}</span>
</a>
</div>
{/* ----------------------------------------------------------- */}
{/* HERO INTERACTIVE SHOWCASE CARD (AI Ease Style with 3D BorderBeam) */}
{/* ----------------------------------------------------------- */}
<HeroShowcaseCard />
{/* Trust Badges Strip */}
<div className="mt-12 flex flex-wrap items-center justify-center gap-3 sm:gap-4 text-xs font-medium text-slate-600 font-sans">
<span className="inline-flex items-center gap-1.5 px-3.5 py-1.5 rounded-full bg-white/80 border border-slate-200/70 shadow-sm">
<ShieldCheck className="h-4 w-4 text-emerald-600" />
<span>Zero-Storage Guarantee</span>
</span>
<span className="inline-flex items-center gap-1.5 px-3.5 py-1.5 rounded-full bg-white/80 border border-slate-200/70 shadow-sm">
<Check className="h-4 w-4 text-blue-600" />
<span>Lossless 4K Export</span>
</span>
<span className="inline-flex items-center gap-1.5 px-3.5 py-1.5 rounded-full bg-white/80 border border-slate-200/70 shadow-sm">
<Zap className="h-4 w-4 text-amber-500" />
<span>&lt; 0.8s Inference</span>
</span>
</div>
</div>
</section>
);
}
// ---------------------------------------------------------------------
// Hero Showcase Card (Interactive Tabs + Live Slider + BorderBeam)
// ---------------------------------------------------------------------
function HeroShowcaseCard() {
const [activeTabIdx, setActiveTabIdx] = useState(0);
const [sliderPos, setSliderPos] = useState(50);
const [isHovered, setIsHovered] = useState(false);
const animRef = useRef<number | null>(null);
const activeTab = HERO_SHOWCASE_TABS[activeTabIdx];
// Smooth automatic oscillating sweep when not manually hovering
useEffect(() => {
let startTime = Date.now();
const animate = () => {
if (!isHovered) {
const elapsed = (Date.now() - startTime) / 1000;
const pos = 50 + Math.sin(elapsed * 1.8) * 22;
setSliderPos(pos);
}
animRef.current = requestAnimationFrame(animate);
};
animRef.current = requestAnimationFrame(animate);
return () => {
if (animRef.current) cancelAnimationFrame(animRef.current);
};
}, [isHovered]);
const handleMouseMove = (e: React.MouseEvent<HTMLDivElement>) => {
setIsHovered(true);
const rect = e.currentTarget.getBoundingClientRect();
const x = Math.max(0, Math.min(e.clientX - rect.left, rect.width));
const percent = Math.max(10, Math.min(90, (x / rect.width) * 100));
setSliderPos(percent);
};
const handleMouseLeave = () => {
setIsHovered(false);
};
return (
<div className="mt-12 w-full max-w-5xl mx-auto text-left">
{/* Interactive Tabs Header */}
<div className="flex items-center justify-center flex-wrap gap-2 mb-4">
{HERO_SHOWCASE_TABS.map((tab, idx) => {
const isActive = idx === activeTabIdx;
const Icon = tab.icon;
return (
<button
key={tab.id}
onClick={() => setActiveTabIdx(idx)}
className={`flex items-center gap-2 px-4 py-2 rounded-full text-xs font-bold transition-all duration-300 ${
isActive
? 'bg-slate-900 text-white shadow-md shadow-slate-900/15 scale-105'
: 'bg-white/80 hover:bg-white text-slate-700 hover:text-blue-600 border border-slate-200/80 shadow-sm'
}`}
>
<Icon className={`w-3.5 h-3.5 ${isActive ? 'text-cyan-400' : 'text-blue-600'}`} />
<span>{tab.label}</span>
</button>
);
})}
</div>
{/* Main Interactive Showcase Card with BorderBeam & 3D Perspective */}
<div className="relative rounded-3xl bg-slate-950 border border-slate-800 shadow-2xl overflow-hidden p-2 sm:p-3 transform-gpu transition-all duration-500 hover:shadow-blue-500/10">
{/* MagicUI BorderBeam Glow running around perimeter */}
<BorderBeam size={300} duration={10} colorFrom="#06b6d4" colorTo="#3b82f6" />
{/* Comparison Viewport */}
<div
onMouseMove={handleMouseMove}
onMouseLeave={handleMouseLeave}
className="relative w-full h-[320px] sm:h-[440px] lg:h-[480px] rounded-2xl overflow-hidden cursor-ew-resize select-none bg-slate-950"
>
{/* Before Image (Locked centered scale) */}
<img
src={activeTab.beforeUrl}
alt="Before"
className="absolute inset-0 w-full h-full object-cover pointer-events-none"
loading="eager"
/>
{/* After Image (Clipped via clip-path) */}
<img
src={activeTab.afterUrl}
alt="After"
className="absolute inset-0 w-full h-full object-cover pointer-events-none"
style={{
clipPath: `inset(0 ${100 - sliderPos}% 0 0)`,
}}
loading="eager"
/>
{/* Glowing Slider Line */}
<div
className="absolute top-0 bottom-0 w-0.5 bg-white shadow-[0_0_14px_rgba(255,255,255,1)] pointer-events-none z-20"
style={{ left: `${sliderPos}%` }}
>
<div className="absolute top-1/2 -translate-y-1/2 -translate-x-1/2 w-8 h-8 rounded-full bg-white shadow-xl border border-slate-200 flex items-center justify-center text-xs font-bold text-slate-900 pointer-events-none">
↔
</div>
</div>
{/* 4 Floating Corner Telemetry Badges */}
<div className="absolute top-4 left-4 z-30 pointer-events-none">
<span className="inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-[10px] font-mono font-bold tracking-wider uppercase bg-black/70 backdrop-blur-md text-cyan-400 border border-cyan-500/30 shadow-md">
<Sparkles className="w-3 h-3 text-cyan-400" />
{activeTab.badge}
</span>
</div>
<div className="absolute top-4 right-4 z-30 pointer-events-none">
<span className="inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-[10px] font-mono font-bold tracking-wider uppercase bg-black/70 backdrop-blur-md text-emerald-400 border border-emerald-500/30 shadow-md">
<Zap className="w-3 h-3 text-emerald-400" />
&lt; 0.8s Inference
</span>
</div>
<div className="absolute bottom-4 left-4 z-30 pointer-events-none">
<span className="inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-[10px] font-mono font-bold tracking-wider uppercase bg-black/70 backdrop-blur-md text-white border border-white/20 shadow-md">
<ShieldCheck className="w-3 h-3 text-emerald-400" />
Zero Cloud Retention
</span>
</div>
<div className="absolute bottom-4 right-4 z-30 pointer-events-none">
<span className="px-3 py-1 rounded-full text-[10px] font-mono font-bold tracking-wider uppercase bg-black/70 backdrop-blur-md text-white/90 border border-white/20 shadow-md">
AFTER | BEFORE
</span>
</div>
</div>
{/* Bottom Quick Action Bar */}
<div className="p-4 sm:p-5 flex flex-col sm:flex-row items-center justify-between gap-4 text-xs">
<p className="text-slate-300 font-sans">
<strong className="text-white font-semibold">{activeTab.label}:</strong> {activeTab.tagline}
</p>
<Link
href={activeTab.href}
className="flex-shrink-0 inline-flex items-center gap-2 px-5 py-2.5 rounded-full font-bold text-slate-900 bg-white hover:bg-cyan-400 transition-colors shadow-sm"
>
<UploadCloud className="w-4 h-4" />
<span>Try with Your Photo Free</span>
<ArrowRight className="w-3.5 h-3.5" />
</Link>
</div>
</div>
</div>
);
}
// -------------------------------------------------------------
// Interactive 3D WebGL Crystal Prism Background Canvas
// -------------------------------------------------------------
function Hero3DCanvas({ className }: { className?: string }) {
const containerRef = useRef<HTMLDivElement>(null);
useEffect(() => {
const container = containerRef.current;
if (!container) return;
let width = container.clientWidth || 600;
let height = container.clientHeight || 600;
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(45, width / height, 0.1, 100);
camera.position.z = 4.2;
let renderer: THREE.WebGLRenderer | null = null;
try {
renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true });
renderer.setSize(width, height);
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
container.appendChild(renderer.domElement);
} catch (e) {
return;
}
// Geometry: Floating Octahedron Crystal Prism
const geometry = new THREE.OctahedronGeometry(1.65, 0);
const material = new THREE.MeshPhysicalMaterial({
color: 0x2563eb,
emissive: 0x1d4ed8,
emissiveIntensity: 0.15,
roughness: 0.25,
metalness: 0.1,
transmission: 0.85,
transparent: true,
opacity: 0.75,
ior: 1.5,
});
const crystal = new THREE.Mesh(geometry, material);
scene.add(crystal);
// Wireframe Cage
const wireGeo = new THREE.WireframeGeometry(geometry);
const wireMat = new THREE.LineBasicMaterial({
color: 0x93c5fd,
transparent: true,
opacity: 0.35,
});
const wireframe = new THREE.LineSegments(wireGeo, wireMat);
crystal.add(wireframe);
// Subtle Particle Constellation
const particleCount = 40;
const particleGeo = new THREE.BufferGeometry();
const posArray = new Float32Array(particleCount * 3);
for (let i = 0; i < particleCount * 3; i++) {
posArray[i] = (Math.random() - 0.5) * 6;
}
particleGeo.setAttribute('position', new THREE.BufferAttribute(posArray, 3));
const particleMat = new THREE.PointsMaterial({
size: 0.04,
color: 0x60a5fa,
transparent: true,
opacity: 0.5,
});
const particles = new THREE.Points(particleGeo, particleMat);
scene.add(particles);
// Studio Lights
const ambientLight = new THREE.AmbientLight(0xffffff, 0.85);
scene.add(ambientLight);
const pointLight = new THREE.PointLight(0x06b6d4, 3, 10);
pointLight.position.set(3, 3, 3);
scene.add(pointLight);
const pointLight2 = new THREE.PointLight(0x4f46e5, 2.5, 10);
pointLight2.position.set(-3, -2, 2);
scene.add(pointLight2);
let animId = 0;
let clock = new THREE.Clock();
const animate = () => {
animId = requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
crystal.rotation.x = elapsed * 0.18;
crystal.rotation.y = elapsed * 0.25;
particles.rotation.y = elapsed * 0.05;
particles.rotation.x = elapsed * 0.03;
if (renderer) renderer.render(scene, camera);
};
animate();
const handleResize = () => {
if (!container || !renderer) return;
const w = container.clientWidth;
const h = container.clientHeight;
camera.aspect = w / h;
camera.updateProjectionMatrix();
renderer.setSize(w, h);
};
window.addEventListener('resize', handleResize);
return () => {
cancelAnimationFrame(animId);
window.removeEventListener('resize', handleResize);
if (renderer && renderer.domElement && container.contains(renderer.domElement)) {
container.removeChild(renderer.domElement);
}
geometry.dispose();
material.dispose();
renderer?.dispose();
};
}, []);
return <div ref={containerRef} className={className} />;
}