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

368 lines
17 KiB
TypeScript
Raw Normal View History

'use client';
import React, { useState, useEffect, useRef } from 'react';
import Link from 'next/link';
import dynamic from 'next/dynamic';
const Hero3DCanvas = dynamic(
() => import('@/components/3d/HeroCrystalCanvas').then((mod) => mod.HeroCrystalCanvas),
{ ssr: false, loading: () => null }
);
import {
Sparkles,
ArrowRight,
Smartphone,
ArrowDown,
ShieldCheck,
LockKeyhole,
Check,
Zap,
SlidersHorizontal,
UploadCloud,
QrCode
} from 'lucide-react';
import { ToolItem, VariantSpec, resolveLocalised } from '@/types';
import { TextAnimate } from '@/components/magicui/text-animate';
import { Particles } from '@/components/magicui/particles';
import { TryItWidget } from './TryItWidget';
import { GrainTransformShowcase } from '@/components/ui/GrainTransformShowcase';
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;
}
export function HeroSection({
title,
badge,
subtitle,
primaryCta,
secondaryCta,
variant = 'frontpage',
tool,
homeApp,
variants = [],
locale = 'en',
}: HeroSectionProps) {
const [mobileTab, setMobileTab] = useState<'upload' | 'compare'>('upload');
const resolvedBadge = resolveLocalised(badge, locale) || 'Next-Gen Creative Vision AI';
const primaryCtaLabel = resolveLocalised(primaryCta?.label, locale, 'Explore the Magic');
const primaryCtaHref = primaryCta?.href || '#our-tools';
const secondaryCtaLabel = resolveLocalised(secondaryCta?.label, locale, 'Mobile App Studio');
const secondaryCtaHref = secondaryCta?.href || '#recommended-apps';
// 1. Dedicated Tool Detail Page Hero (when viewing /tools/[slug] with variant='toolHero')
if (variant === 'toolHero' && tool) {
const appName = homeApp ? resolveLocalised(homeApp.name, locale) : 'Mobile App';
const toolMedia = (tool as any).media;
const primaryExample = tool.content?.examples?.[0] || {
before: toolMedia?.before || `/management/pages/tools/${tool.slug}/media/before.jpg`,
after: toolMedia?.after || `/management/pages/tools/${tool.slug}/media/after.jpg`,
caption: 'Sub-pixel neural transformation details',
};
return (
<section className="relative overflow-hidden bg-[#FAF8F5] border-b border-slate-900/[0.08] pt-24 sm:pt-28 pb-14 sm:pb-20 px-4 sm:px-6 lg:px-10">
<div className="max-w-[1640px] mx-auto">
{/* Breadcrumb Navigation */}
<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>
{/* Heading & Subtitle */}
<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 shadow-2xs">
<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>
{/* Mobile Tab Switcher */}
<div className="mt-7 flex lg:hidden items-center justify-center">
<div className="inline-flex p-1.5 rounded-2xl bg-slate-200/80 border border-slate-300 shadow-inner">
<button
type="button"
onClick={() => setMobileTab('upload')}
className={`flex items-center gap-2 px-5 py-2.5 rounded-xl text-xs font-bold transition-all ${
mobileTab === 'upload'
? 'bg-white text-blue-600 shadow-sm'
: 'text-slate-600 hover:text-slate-900'
}`}
>
<UploadCloud className="w-3.5 h-3.5" />
<span>Upload Photo</span>
</button>
<button
type="button"
onClick={() => setMobileTab('compare')}
className={`flex items-center gap-2 px-5 py-2.5 rounded-xl text-xs font-bold transition-all ${
mobileTab === 'compare'
? 'bg-blue-600 text-white shadow-sm'
: 'text-slate-600 hover:text-slate-900'
}`}
>
<SlidersHorizontal className="w-3.5 h-3.5" />
<span>Transform Result</span>
</button>
</div>
</div>
</div>
{/* Intelligent Side-by-Side Tool Studio */}
<div className="grid grid-cols-1 lg:grid-cols-12 gap-8 items-stretch max-w-7xl mx-auto" id="tool-studio">
{/* Column 1: Spacious, Prominent Upload Studio (lg:col-span-7) */}
<div className={`lg:col-span-7 flex flex-col ${mobileTab === 'upload' ? 'block' : 'hidden lg:flex'}`}>
<TryItWidget
tool={tool}
homeApp={homeApp}
variants={variants}
locale={locale}
className="h-full flex flex-col justify-between"
onSwitchToCompare={() => setMobileTab('compare')}
/>
</div>
{/* Column 2: Sleeker, Focused Neural Transformation Preview (lg:col-span-5) */}
<div className={`lg:col-span-5 flex flex-col ${mobileTab === 'compare' ? 'block' : 'hidden lg:flex'}`}>
<div className="h-full rounded-3xl overflow-hidden border border-slate-900/[0.1] shadow-cinematic-3d bg-slate-950 flex flex-col justify-between min-h-[380px] sm:min-h-[460px]">
<GrainTransformShowcase
beforeUrl={primaryExample.before}
afterUrl={primaryExample.after}
beforeLabel="BEFORE"
afterLabel="AFTER"
/>
</div>
{/* Mobile Jump to Upload (Only on small screens) */}
<div className="mt-3 lg:hidden">
<button
type="button"
onClick={() => setMobileTab('upload')}
className="w-full py-3 px-4 rounded-xl text-xs font-bold text-white bg-blue-600 hover:bg-blue-700 flex items-center justify-center gap-2 shadow-sm"
>
<UploadCloud className="w-4 h-4" />
<span>Upload Your Photo to Try</span>
</button>
</div>
</div>
</div>
{/* Clean Trust Indicators & Clickable App Links */}
<div className="mt-10 flex flex-wrap items-center justify-center gap-3 sm:gap-4 text-xs font-medium text-slate-600">
<span className="inline-flex items-center gap-1.5 px-3.5 py-2 rounded-full bg-slate-100 text-slate-700">
<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.5 py-2 rounded-full bg-slate-100 text-slate-700">
<LockKeyhole className="h-3.5 w-3.5 text-blue-600" />
<span>Private Processing</span>
</span>
<span className="inline-flex items-center gap-1.5 px-3.5 py-2 rounded-full bg-slate-100 text-slate-700">
<Check className="h-3.5 w-3.5 text-indigo-600" />
<span>Lossless Quality</span>
</span>
{/* Clickable Mobile App Button Link */}
{homeApp && (
<a
href="#app-handoff"
className="inline-flex items-center gap-2 px-4 py-2 rounded-full bg-blue-50 hover:bg-blue-100 border border-blue-200 text-blue-700 font-bold shadow-2xs hover:scale-105 active:scale-95 transition-all group"
>
<Smartphone className="h-4 w-4 text-blue-600 group-hover:scale-110 transition-transform" />
<span>Available in {appName} App</span>
<span className="text-[10px] font-mono bg-blue-600 text-white px-2 py-0.5 rounded-full font-bold">
50 Bonus Credits &amp; 4K ↗
</span>
</a>
)}
{/* Clickable QR Code Trigger Pill */}
{homeApp && (
<a
href="#app-handoff"
className="inline-flex items-center gap-1.5 text-xs font-mono font-semibold text-slate-700 hover:text-slate-950 bg-white hover:bg-slate-50 border border-slate-200 px-3.5 py-2 rounded-full shadow-2xs transition-all hover:scale-105 active:scale-95"
title="Scan QR Code to install mobile app"
>
<QrCode className="w-3.5 h-3.5 text-blue-600" />
<span>Scan QR</span>
</a>
)}
</div>
</div>
</section>
);
}
// 2. Centered Directory & Info Page Hero (for /tools, /apps, /pricing, /trust, /privacy, /terms)
if (variant === 'centered') {
const resolvedTitle = resolveLocalised(title, locale) || 'Creative Studio';
const resolvedSubtitle = resolveLocalised(subtitle, locale);
return (
<section className="relative overflow-hidden pt-28 pb-16 sm:pt-36 sm:pb-20 text-center bg-[#FAF8F5] border-b border-slate-900/[0.07]">
<div className="absolute top-0 left-1/2 -translate-x-1/2 w-full max-w-7xl h-96 bg-gradient-to-b from-blue-500/[0.04] to-transparent blur-3xl pointer-events-none -z-10" />
<div className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 space-y-6 relative z-10">
{resolvedBadge && (
<div className="inline-flex items-center gap-2 px-4 py-1.5 rounded-full bg-blue-50 border border-blue-200 text-xs font-mono font-semibold text-blue-700 shadow-sm">
<Sparkles className="w-3.5 h-3.5 text-blue-600" />
<span>{resolvedBadge}</span>
</div>
)}
<h1 className="text-4xl sm:text-5xl lg:text-6xl font-display font-black text-slate-900 tracking-tight leading-tight">
{resolvedTitle}
</h1>
{resolvedSubtitle && (
<p className="text-base sm:text-lg text-slate-600 max-w-2xl mx-auto leading-relaxed font-sans">
{resolvedSubtitle}
</p>
)}
<div className="flex flex-wrap items-center justify-center gap-4 pt-3">
<Link
href="/#our-tools"
className="inline-flex items-center gap-2 px-6 py-3 rounded-full font-bold text-xs sm:text-sm text-white bg-slate-950 hover:bg-blue-600 shadow-sm transition-all hover:scale-105 active:scale-95"
>
<span>Explore Studio Suite</span>
<ArrowRight className="w-4 h-4" />
</Link>
<Link
href="/apps"
className="inline-flex items-center gap-2 px-6 py-3 rounded-full font-bold text-xs sm:text-sm text-slate-700 bg-white border border-slate-200 hover:bg-slate-50 transition-colors shadow-sm"
>
<Smartphone className="w-4 h-4 text-blue-600" />
<span>Mobile Apps Suite</span>
</Link>
</div>
</div>
</section>
);
}
// -------------------------------------------------------------
// 3. Pure Front Page Hero View (for homepage /):
// Matching User Reference Image: Image_homepage.jpg background,
// Left-aligned typography, pill buttons, and glass telemetry capsule
// -------------------------------------------------------------
return (
<section className="relative min-h-[92vh] sm:min-h-screen flex items-center overflow-hidden bg-black pt-20 sm:pt-24 pb-14 sm:pb-20">
{/* 1. Background Image with Left Dark Gradient Overlay */}
<div className="absolute inset-0 z-0">
<img
src="/management/pages/home/Image_homepage.jpg"
alt="CRE AI Photo Magic"
className="w-full h-full object-cover object-[75%_center] sm:object-right-top select-none pointer-events-none"
loading="eager"
decoding="async"
/>
{/* Dark Gradient Overlay for Maximum Text Readability */}
<div className="absolute inset-0 bg-gradient-to-r from-black/95 via-black/75 to-black/30 sm:via-black/55 sm:to-transparent" />
{/* Smooth Bottom Blend to Section Below */}
<div className="absolute inset-x-0 bottom-0 h-28 bg-gradient-to-t from-[#FAF8F5] via-[#FAF8F5]/70 to-transparent pointer-events-none" />
</div>
{/* 2. Left-Aligned Content Container */}
<div className="relative z-10 max-w-[1640px] w-full mx-auto px-4 sm:px-8 lg:px-14 flex flex-col justify-center min-h-[90vh] sm:min-h-[92vh]">
<div className="max-w-2xl sm:max-w-3xl">
{/* Masterpiece Headline */}
<h1 className="text-4xl sm:text-6xl md:text-7xl lg:text-[5.2rem] font-display font-extrabold tracking-[-0.03em] leading-[1.06] text-left">
<span className="block text-white">
Imagine. Transform.
</span>
<span className="block mt-1 sm:mt-2 bg-gradient-to-r from-blue-400 via-indigo-300 to-pink-400 bg-clip-text text-transparent">
Create the Impossible.
</span>
</h1>
{/* Subtitle */}
<p className="mt-5 sm:mt-7 text-sm sm:text-base md:text-lg text-slate-200/90 max-w-xl text-left font-sans leading-relaxed">
Turn ordinary moments into extraordinary visual art, Instant, effortless, and private photo magic right in your browser.
</p>
{/* Action Buttons */}
<div className="mt-8 sm:mt-10 flex flex-wrap items-center gap-3 sm:gap-4">
<a
href={primaryCtaHref}
className="px-7 sm:px-8 py-3.5 sm:py-4 rounded-full text-xs sm:text-sm font-bold text-white bg-blue-600 hover:bg-blue-500 shadow-lg shadow-blue-600/35 transition-all duration-200 hover:scale-105 active:scale-95 cursor-pointer"
>
Explore Our Tools
</a>
<a
href={secondaryCtaHref}
className="px-7 sm:px-8 py-3.5 sm:py-4 rounded-full text-xs sm:text-sm font-bold text-slate-950 bg-white hover:bg-slate-100 shadow-md transition-all duration-200 hover:scale-105 active:scale-95 cursor-pointer"
>
Recommended Apps
</a>
</div>
{/* Glass Metrics Pill Capsule */}
<div className="mt-12 sm:mt-16 w-full max-w-2xl sm:max-w-3xl rounded-3xl sm:rounded-full bg-white/[0.06] backdrop-blur-xl border border-white/20 p-4 sm:py-4 sm:px-8 grid grid-cols-2 sm:grid-cols-4 gap-4 sm:gap-6 shadow-2xl">
{/* Metric 1 */}
<div className="flex flex-col text-left">
<span className="text-xl sm:text-2xl font-display font-black tracking-tight text-blue-400">
1.4M+
</span>
<span className="text-[11px] sm:text-xs text-slate-300 font-sans mt-0.5">
Photo Tranformed
</span>
</div>
{/* Metric 2 */}
<div className="flex flex-col text-left">
<span className="text-xl sm:text-2xl font-display font-black tracking-tight text-indigo-300">
&lt;0.8s
</span>
<span className="text-[11px] sm:text-xs text-slate-300 font-sans mt-0.5">
Instant Interene
</span>
</div>
{/* Metric 3 */}
<div className="flex flex-col text-left">
<span className="text-xl sm:text-2xl font-display font-black tracking-tight text-indigo-400">
100%
</span>
<span className="text-[11px] sm:text-xs text-slate-300 font-sans mt-0.5">
Client side privacy
</span>
</div>
{/* Metric 4 */}
<div className="flex flex-col text-left">
<span className="text-xl sm:text-2xl font-display font-black tracking-tight bg-gradient-to-r from-blue-300 via-indigo-300 to-pink-400 bg-clip-text text-transparent">
4K UHD
</span>
<span className="text-[11px] sm:text-xs text-slate-300 font-sans mt-0.5">
Studio Resolution
</span>
</div>
</div>
</div>
</div>
</section>
);
}