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

311 lines
15 KiB
TypeScript
Raw Normal View History

'use client';
import React, { useState } from 'react';
import Link from 'next/link';
import {
Sparkles,
ArrowRight,
Smartphone,
Layers,
ShieldCheck,
LockKeyhole,
ImagePlus,
Check,
Zap,
UploadCloud,
SlidersHorizontal,
} from 'lucide-react';
import { resolveLocalised, ToolItem, AppItem, VariantSpec } from '@/types';
import { TryItWidget } from './TryItWidget';
import { HeroPrism } from '@/components/3d/HeroPrism';
import { Kinetic3DText } from '@/components/ui/Kinetic3DText';
import { ShimmerBadge } from '@/components/animate-ui/ShimmerBadge';
import { CardBeforeAfterSlider } from '@/components/ui/CardBeforeAfterSlider';
import { BeforeAfterSlider } from '@/components/ui/BeforeAfterSlider';
interface HeroSectionProps {
title?: any;
subtitle?: any;
variant?: string;
badge?: any;
tryIt?: {
toolRef: string;
};
tool?: ToolItem | null;
homeApp?: AppItem | null;
variants?: VariantSpec[];
locale?: string;
}
export function HeroSection({
title,
subtitle,
variant = 'centered',
badge,
tool,
homeApp,
variants = [],
locale = 'en',
}: HeroSectionProps) {
const [mobileTab, setMobileTab] = useState<'upload' | 'compare'>('upload');
const resolvedTitle = resolveLocalised(title, locale);
const resolvedSubtitle = resolveLocalised(subtitle, locale);
const resolvedBadge = resolveLocalised(badge, locale);
if (variant === 'tryit' && tool) {
return (
<section className="relative isolate overflow-hidden pt-28 pb-16 sm:pt-36 sm:pb-24 lg:pt-40 lg:pb-28 bg-[#FAF8F5]">
<div className="absolute inset-x-0 top-0 h-[620px] bg-[radial-gradient(ellipse_at_72%_18%,rgba(87,132,220,0.14),transparent_48%),radial-gradient(ellipse_at_12%_0%,rgba(208,182,142,0.12),transparent_36%)] pointer-events-none" />
<div className="absolute right-[4%] top-12 w-[360px] h-[360px] opacity-35 pointer-events-none hidden lg:block" aria-hidden="true">
<HeroPrism />
</div>
<div className="relative z-10 max-w-[1440px] mx-auto px-4 sm:px-6 lg:px-10">
<div className="grid lg:grid-cols-[0.82fr_1.18fr] gap-10 xl:gap-16 items-center">
<div className="max-w-xl">
<div className="inline-flex items-center gap-2 rounded-full border border-blue-200/80 bg-white/75 px-3.5 py-2 text-[11px] font-semibold tracking-[0.12em] uppercase text-blue-800 shadow-sm backdrop-blur">
<Sparkles className="w-3.5 h-3.5" />
<span>{resolvedBadge || 'A calmer way to create'}</span>
</div>
<Kinetic3DText
primaryText={resolvedTitle}
subtitle={resolvedSubtitle}
className="mt-7 text-left [&_h1]:text-left [&_h1]:text-[2.7rem] sm:[&_h1]:text-6xl lg:[&_h1]:text-[4.25rem] [&_h1]:leading-[1.02] [&_p]:mx-0 [&_p]:mt-5 [&_p]:max-w-lg [&_p]:text-base [&_p]:sm:text-lg"
/>
<div className="mt-8 flex flex-wrap gap-3">
<Link href="/tools" className="group inline-flex items-center gap-2.5 rounded-full bg-slate-950 px-6 py-3.5 text-sm font-semibold text-white shadow-lg shadow-slate-900/10 transition-all hover:-translate-y-0.5 hover:bg-blue-700 hover:shadow-xl">
Explore the tools <ArrowRight className="h-4 w-4 transition-transform group-hover:translate-x-1" />
</Link>
<Link href="/apps" className="inline-flex items-center gap-2 rounded-full border border-slate-300/80 bg-white/75 px-5 py-3.5 text-sm font-semibold text-slate-800 shadow-sm transition-all hover:-translate-y-0.5 hover:border-slate-400 hover:bg-white">
<Smartphone className="h-4 w-4 text-blue-700" /> Our apps
</Link>
</div>
<div className="mt-9 flex flex-wrap gap-x-5 gap-y-2 text-xs font-medium text-slate-600">
<span className="inline-flex items-center gap-1.5"><ShieldCheck className="h-4 w-4 text-emerald-700" /> No account needed</span>
<span className="inline-flex items-center gap-1.5"><LockKeyhole className="h-4 w-4 text-emerald-700" /> Photos aren’t stored</span>
<span className="inline-flex items-center gap-1.5"><ImagePlus className="h-4 w-4 text-emerald-700" /> Try with a sample</span>
</div>
</div>
<div className="relative min-w-0">
<div className="absolute -inset-4 rounded-[2.25rem] bg-gradient-to-br from-blue-200/50 via-white/30 to-amber-100/60 blur-2xl" />
<div className="relative rounded-[1.8rem] border border-slate-200/90 bg-white/88 p-1.5 shadow-[0_35px_100px_-38px_rgba(32,49,84,0.32)] sm:p-2">
<TryItWidget tool={tool} homeApp={homeApp} variants={variants} locale={locale} />
</div>
</div>
</div>
</div>
</section>
);
}
// Dedicated Tool Landing Hero (for Google Search / Direct Traffic SEO)
if (variant === 'toolHero' && tool) {
const categoryName = tool.category?.replace('-', ' ').toUpperCase() || 'AI TOOL';
const appName = homeApp ? resolveLocalised(homeApp.name, locale) : 'Mobile App';
const primaryExample = tool.content?.examples?.[0] || {
before: 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=800&auto=format&fit=crop&q=80',
after: 'https://images.unsplash.com/photo-1578632767115-351597cf2477?w=800&auto=format&fit=crop&q=80',
caption: 'Sub-pixel neural transformation details',
};
return (
<section className="relative isolate overflow-hidden pt-28 pb-16 sm:pt-32 sm:pb-20 lg:pt-36 lg:pb-24 bg-[#FAF8F5] border-b border-slate-900/[0.07]">
{/* Ambient subtle warm gradient */}
<div className="absolute inset-x-0 top-0 h-[640px] bg-[radial-gradient(ellipse_at_75%_20%,rgba(87,132,220,0.12),transparent_50%),radial-gradient(ellipse_at_15%_0%,rgba(208,182,142,0.15),transparent_40%)] pointer-events-none" />
<div className="relative z-10 max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
{/* Breadcrumb Navigation */}
<nav aria-label="Breadcrumb" className="mb-5 flex items-center justify-center gap-2 text-xs font-medium text-slate-500">
<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">{resolvedTitle}</span>
</nav>
{/* Centered Tool Header */}
<div className="text-center max-w-3xl mx-auto mb-6 sm:mb-8">
<div className="inline-flex items-center gap-2 rounded-full border border-blue-200/80 bg-white/80 px-3.5 py-1.5 text-[11px] font-semibold tracking-[0.14em] uppercase text-blue-800 shadow-sm backdrop-blur">
<Sparkles className="w-3.5 h-3.5 text-blue-600" />
<span>{categoryName} • AI NEURAL TOOL</span>
</div>
<h1 className="mt-3.5 text-3xl sm:text-4xl lg:text-5xl font-display font-black tracking-tight text-slate-900 leading-[1.1]">
{resolvedTitle}
</h1>
<p className="mt-3 text-sm sm:text-base leading-relaxed text-slate-600 max-w-2xl mx-auto">
{resolvedSubtitle}
</p>
</div>
{/* Intelligent Mobile Tab Switcher (Visible ONLY on Mobile < 768px) */}
<div className="flex md:hidden items-center justify-center mb-5">
<div className="inline-flex rounded-2xl bg-white p-1 border border-slate-200/90 shadow-2xs">
<button
type="button"
onClick={() => setMobileTab('upload')}
className={`flex items-center gap-2 px-4 py-2 rounded-xl text-xs font-bold transition-all ${
mobileTab === 'upload'
? 'bg-blue-600 text-white shadow-sm'
: 'text-slate-600 hover:text-slate-900'
}`}
>
<UploadCloud className="w-3.5 h-3.5" />
<span>Upload &amp; Try</span>
</button>
<button
type="button"
onClick={() => setMobileTab('compare')}
className={`flex items-center gap-2 px-4 py-2 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>Before &amp; After</span>
</button>
</div>
</div>
{/* Intelligent Side-by-Side Tool Studio (Side-by-Side on Tablet & Desktop) */}
<div className="grid grid-cols-1 md:grid-cols-2 gap-6 lg:gap-8 items-stretch max-w-6xl mx-auto" id="tool-studio">
{/* Column 1: Live Comparison Showcase */}
<div className={`flex flex-col ${mobileTab === 'compare' ? 'block' : 'hidden md:flex'}`}>
<div className="flex flex-col justify-between h-full bg-white rounded-3xl p-5 sm:p-7 lg:p-8 border border-slate-900/[0.08] shadow-cream-md overflow-hidden">
<div>
{/* Card Header */}
<div className="flex items-center justify-between pb-4 sm:pb-5 border-b border-slate-100">
<div className="flex items-center gap-2.5">
<div className="w-8 h-8 rounded-xl bg-indigo-50 border border-indigo-200/80 flex items-center justify-center text-indigo-600">
<Sparkles className="w-4 h-4" />
</div>
<div>
<h3 className="text-xs sm:text-sm font-display font-bold text-slate-900">
Neural Transformation Preview
</h3>
<p className="text-[11px] font-mono text-slate-500">Interactive Model Result</p>
</div>
</div>
<span className="inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-[10px] font-mono font-semibold text-emerald-800 bg-emerald-50 border border-emerald-200/90 shadow-2xs">
<span className="w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse" />
Live Demo
</span>
</div>
{/* Comparison Slider */}
<div className="mt-5">
<BeforeAfterSlider
beforeUrl={primaryExample.before}
afterUrl={primaryExample.after}
beforeLabel="Original"
afterLabel="CRE AI Result"
caption={primaryExample.caption}
aspectRatio="aspect-[4/3] sm:aspect-[16/11]"
autoSlide={true}
/>
</div>
</div>
<div>
{/* Model Specs Strip */}
<div className="mt-5 pt-4 border-t border-slate-100 flex flex-wrap items-center justify-between gap-3 text-xs text-slate-500 font-mono">
<span className="inline-flex items-center gap-1.5">
<Check className="w-3.5 h-3.5 text-blue-600" /> Lossless 4K preservation
</span>
<span className="inline-flex items-center gap-1.5">
<Zap className="w-3.5 h-3.5 text-amber-500" /> Instant sub-second inference
</span>
</div>
{/* Mobile Jump to Upload */}
<div className="mt-4 md: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 Now</span>
</button>
</div>
</div>
</div>
</div>
{/* Column 2: Upload Action Studio */}
<div className={`flex flex-col ${mobileTab === 'upload' ? 'block' : 'hidden md:flex'}`}>
<TryItWidget
tool={tool}
homeApp={homeApp}
variants={variants}
locale={locale}
className="h-full"
onSwitchToCompare={() => setMobileTab('compare')}
/>
</div>
</div>
{/* Clean Trust Indicators */}
<div className="mt-8 flex flex-wrap items-center justify-center gap-x-6 gap-y-2 text-xs font-medium text-slate-500">
<span className="inline-flex items-center gap-1.5"><ShieldCheck className="h-4 w-4 text-emerald-600" /> No account required</span>
<span className="inline-flex items-center gap-1.5"><LockKeyhole className="h-4 w-4 text-emerald-600" /> Photos never stored</span>
<span className="inline-flex items-center gap-1.5"><Check className="h-4 w-4 text-blue-600" /> High-res 4K export</span>
{homeApp && (
<Link href={`/apps/${homeApp.slug}`} className="inline-flex items-center gap-1.5 text-blue-700 hover:underline font-semibold">
<Smartphone className="h-4 w-4" /> Available in {appName} App
</Link>
)}
</div>
</div>
</section>
);
}
// Centered Hero for Tools/Apps/Pricing pages
return (
<section className="relative overflow-hidden pt-28 pb-20 sm:pt-36 sm:pb-28 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>
<p className="text-base sm:text-xl text-slate-600 max-w-2xl mx-auto leading-relaxed">
{resolvedSubtitle}
</p>
<div className="flex flex-wrap items-center justify-center gap-4 pt-4">
<Link
href="/#studio-suite"
className="inline-flex items-center gap-2 px-7 py-3.5 rounded-full font-bold text-xs sm:text-sm text-white bg-blue-600 hover:bg-blue-700 shadow-sm shadow-blue-500/20 transition-all hover:scale-105 active:scale-95"
>
<Layers className="w-4 h-4 text-white" />
<span>The Creative Suite</span>
</Link>
<Link
href="/apps"
className="inline-flex items-center gap-2 px-7 py-3.5 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>
);
}