feat: place tool comparison and upload side-by-side intelligently across desktop, tablet, and mobile
This commit is contained in:
@@ -1,14 +1,27 @@
|
||||
'use client';
|
||||
|
||||
import React from 'react';
|
||||
import React, { useState } from 'react';
|
||||
import Link from 'next/link';
|
||||
import { Sparkles, ArrowRight, Smartphone, Layers, ShieldCheck, LockKeyhole, ImagePlus, Check, Zap } from 'lucide-react';
|
||||
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;
|
||||
@@ -34,6 +47,7 @@ export function HeroSection({
|
||||
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);
|
||||
@@ -92,15 +106,20 @@ export function HeroSection({
|
||||
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-36 sm:pb-20 lg:pt-36 lg:pb-24 bg-[#FAF8F5] border-b border-slate-900/[0.07]">
|
||||
<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-5xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<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-6 flex items-center justify-center gap-2 text-xs font-medium text-slate-500">
|
||||
<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>
|
||||
@@ -109,36 +128,137 @@ export function HeroSection({
|
||||
</nav>
|
||||
|
||||
{/* Centered Tool Header */}
|
||||
<div className="text-center max-w-3xl mx-auto">
|
||||
<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-4 text-3xl sm:text-5xl lg:text-6xl font-display font-black tracking-tight text-slate-900 leading-[1.08]">
|
||||
<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-4 text-base sm:text-lg leading-relaxed text-slate-600 max-w-2xl mx-auto">
|
||||
<p className="mt-3 text-sm sm:text-base leading-relaxed text-slate-600 max-w-2xl mx-auto">
|
||||
{resolvedSubtitle}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Single Big Upload Image Option */}
|
||||
<div className="mt-8 sm:mt-10 max-w-3xl mx-auto" id="tool-tryit">
|
||||
<div className="relative rounded-[2rem] border border-slate-900/[0.1] bg-white p-1 sm:p-2 shadow-cinematic-3d">
|
||||
<TryItWidget tool={tool} homeApp={homeApp} variants={variants} locale={locale} />
|
||||
{/* 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 & 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 & 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-6 flex flex-wrap items-center justify-center gap-x-6 gap-y-2 text-xs font-medium text-slate-500">
|
||||
<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 output</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" /> Also in {appName} App
|
||||
<Smartphone className="h-4 w-4" /> Available in {appName} App
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user