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

270 lines
12 KiB
TypeScript
Raw Normal View History

'use client';
import React, { useRef, useState, useEffect } from 'react';
import Link from 'next/link';
import { Sparkles, ArrowRight, Smartphone, Zap, Shield, Layers } from 'lucide-react';
import { Cinematic3DComparison } from '@/components/ui/Cinematic3DComparison';
interface ShowcaseCard {
id: string;
index: string;
category: string;
model: string;
latency: string;
title: string;
tagline: string;
description: string;
toolSlug: string;
appSlug: string;
appName: string;
beforeUrl: string;
afterUrl: string;
specs: string[];
}
const showcaseCards: ShowcaseCard[] = [
{
id: 'matting',
index: '01 / 03',
category: 'ALPHA MATTING ARCHIVE',
model: 'P3M-Net Dual-Stream Alpha',
latency: '< 520ms Stream',
title: 'Hair-Strand Matting & Alpha Isolation',
tagline: 'Sub-pixel edge detection with microscopic flyaway hair preservation.',
description: 'Trained on high-resolution studio portraits, P3M-Net isolates individual flyaway hair strands, fur, and translucent fabrics without halo artifacts or jagged edges. Streams transparent alpha PNGs in real-time.',
toolSlug: 'background-remover',
appSlug: 'bg-cleaner-app',
appName: 'Magic Cutout Studio',
beforeUrl: 'https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=800&auto=format&fit=crop&q=80',
afterUrl: 'https://images.unsplash.com/photo-1500648767791-00dcc994a43e?w=800&auto=format&fit=crop&q=80',
specs: ['Sub-pixel flyaway detection', 'Lossless alpha PNG export', 'Zero edge halo bleeding'],
},
{
id: 'retouch',
index: '02 / 03',
category: 'DERMAL RESTORATION',
model: 'RetouchGAN v2.1 Micro-Pore',
latency: '< 380ms Stream',
title: 'Sub-Pore Skin Retouching & Blemish Removal',
tagline: 'Authentic microscopic texture preservation without plastic smoothing.',
description: 'Unlike standard beauty filters that smear your face into plastic, RetouchGAN operates at the dermal level—erasing acne, blemishes, and under-eye redness while reconstructing microscopic skin pore geometry.',
toolSlug: 'blemish-remover',
appSlug: 'portrait-app',
appName: 'Portrait Studio AI',
beforeUrl: 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=800&auto=format&fit=crop&q=80',
afterUrl: 'https://images.unsplash.com/photo-1517841905240-472988babdf9?w=800&auto=format&fit=crop&q=80',
specs: ['Microscopic pore geometry', 'Instant scar & redness repair', 'True-to-life dermal tones'],
},
{
id: 'enhancer',
index: '03 / 03',
category: '4K SUPER-RESOLUTION',
model: 'GFPGAN + RealESRGAN Ultra',
latency: '< 460ms Stream',
title: '4K Super-Resolution & Facial Deblurring',
tagline: 'Transform low-resolution snapshots into crystal-clear 4K portraits.',
description: 'Deep neural priors restore authentic iris sharpness, eyelash detail, and facial contours on blurry, out-of-focus, or highly compressed photos, yielding gallery-ready clarity with zero guesswork.',
toolSlug: 'photo-enhancer',
appSlug: 'photo-enhancer-pro',
appName: 'Enhance Ultra AI',
beforeUrl: 'https://images.unsplash.com/photo-1544005313-94ddf0286df2?w=800&auto=format&fit=crop&q=80',
afterUrl: 'https://images.unsplash.com/photo-1494790108377-be9c29b29330?w=800&auto=format&fit=crop&q=80',
specs: ['Iris & eyelash synthesis', '400% lossless super-resolution', 'Studio-grade crispness'],
},
];
export function CinematicHorizontalScrollSection() {
const containerRef = useRef<HTMLDivElement>(null);
const trackRef = useRef<HTMLDivElement>(null);
const [scrollProgress, setScrollProgress] = useState(0);
useEffect(() => {
let rafId: number;
const handleScroll = () => {
if (!containerRef.current || !trackRef.current) return;
const rect = containerRef.current.getBoundingClientRect();
const totalScrollable = containerRef.current.offsetHeight - window.innerHeight;
if (totalScrollable <= 0) return;
// Calculate progress 0 to 1
const progress = Math.min(Math.max(-rect.top / totalScrollable, 0), 1);
setScrollProgress(progress);
// Translate track horizontally
const maxTranslate = trackRef.current.scrollWidth - window.innerWidth;
if (maxTranslate > 0) {
trackRef.current.style.transform = `translate3d(-${progress * maxTranslate}px, 0, 0)`;
}
};
const onScroll = () => {
cancelAnimationFrame(rafId);
rafId = requestAnimationFrame(handleScroll);
};
window.addEventListener('scroll', onScroll, { passive: true });
window.addEventListener('touchmove', onScroll, { passive: true });
window.addEventListener('resize', onScroll, { passive: true });
handleScroll();
let boundLenis: any = null;
const bindLenisInterval = setInterval(() => {
const lenis = (window as any).lenis;
if (lenis && typeof lenis.on === 'function') {
boundLenis = lenis;
lenis.on('scroll', onScroll);
clearInterval(bindLenisInterval);
}
}, 50);
return () => {
clearInterval(bindLenisInterval);
window.removeEventListener('scroll', onScroll);
window.removeEventListener('touchmove', onScroll);
window.removeEventListener('resize', onScroll);
if (boundLenis && typeof boundLenis.off === 'function') {
boundLenis.off('scroll', onScroll);
}
cancelAnimationFrame(rafId);
};
}, []);
return (
<section
id="flagship-models"
ref={containerRef}
className="relative h-[280vh] sm:h-[340vh] bg-[#FAF8F5] border-t border-slate-900/[0.08]"
>
{/* Sticky Fullscreen Camera Viewport */}
<div className="sticky top-0 h-screen w-full overflow-hidden flex flex-col justify-between py-12 sm:py-16">
{/* Background Subtle Ambient Gradients */}
<div className="absolute top-1/4 left-1/3 w-[500px] h-[500px] bg-blue-500/[0.03] rounded-full blur-3xl pointer-events-none -z-10" />
<div className="absolute bottom-1/4 right-1/4 w-[450px] h-[450px] bg-amber-500/[0.025] rounded-full blur-3xl pointer-events-none -z-10" />
{/* Section Top Header & Navigation Telemetry */}
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 w-full z-10 flex flex-col sm:flex-row sm:items-end justify-between gap-4">
<div>
<div className="inline-flex items-center gap-2 px-3.5 py-1 rounded-full bg-blue-50/80 border border-blue-200/80 text-[11px] font-mono font-semibold text-blue-700 mb-2">
<Sparkles className="w-3.5 h-3.5 text-blue-600" />
<span>HORIZONTAL 3D CINEMATIC ARCHIVE</span>
</div>
<h2 className="text-2xl sm:text-4xl lg:text-5xl font-display font-black text-slate-900 tracking-tight">
Flagship Transformations <span className="text-transparent bg-clip-text bg-gradient-to-r from-blue-700 via-indigo-600 to-amber-600">In Real-Time</span>
</h2>
</div>
<div className="flex items-center gap-3">
<span className="text-xs font-mono font-bold text-slate-500 uppercase tracking-widest">
SCROLL DOWN TO PAN HORIZONTALLY
</span>
<div className="hidden sm:flex items-center gap-1.5 px-3 py-1 rounded-lg bg-white/70 backdrop-blur-sm border border-slate-900/[0.06] text-xs font-mono font-bold text-slate-700">
<span className="w-2 h-2 rounded-full bg-blue-600 animate-ping inline-block" />
<span>PROGRESS {Math.round(scrollProgress * 100)}%</span>
</div>
</div>
</div>
{/* Horizontal Sliding Filmstrip Track */}
<div className="relative w-full my-auto overflow-visible py-4">
<div
ref={trackRef}
className="flex items-center gap-8 sm:gap-14 px-6 sm:px-12 lg:px-20 w-max will-change-transform preserve-3d transition-transform duration-75 ease-out"
>
{showcaseCards.map((card, idx) => (
<div
key={card.id}
className="w-[85vw] sm:w-[620px] lg:w-[740px] shrink-0 bg-white/90 backdrop-blur-xl rounded-3xl p-5 sm:p-8 border border-slate-900/[0.08] shadow-cinematic-3d hover:shadow-cinematic-hover transition-all duration-300 preserve-3d group"
style={{
transform: `perspective(1200px) rotateY(${(scrollProgress - idx / (showcaseCards.length - 1)) * -12}deg)`,
}}
>
{/* Card Top Metadata Bar */}
<div className="flex items-center justify-between pb-4 border-b border-slate-900/[0.06] mb-5">
<div className="flex items-center gap-3">
<span className="font-mono text-xs font-black text-blue-700 tracking-wider">
{card.index}
</span>
<span className="h-3 w-px bg-slate-300" />
<span className="font-mono text-[10px] sm:text-xs font-bold text-slate-500 uppercase tracking-widest">
{card.category}
</span>
</div>
<div className="flex items-center gap-2">
<span className="px-2.5 py-1 rounded-md bg-amber-50 border border-amber-200/60 text-[10px] font-mono font-semibold text-amber-800">
{card.latency}
</span>
</div>
</div>
{/* 3D Cinematic Comparison Viewport */}
<div className="mb-6 relative z-10">
<Cinematic3DComparison
beforeUrl={card.beforeUrl}
afterUrl={card.afterUrl}
beforeLabel="RAW SOURCE"
afterLabel={card.model}
aspectRatio="aspect-[16/10]"
/>
</div>
{/* Card Editorial Info */}
<div className="space-y-3">
<h3 className="text-xl sm:text-2xl font-display font-bold text-slate-900 tracking-tight">
{card.title}
</h3>
<p className="text-sm text-slate-600 leading-relaxed font-normal">
{card.description}
</p>
{/* Specs Chips */}
<div className="flex flex-wrap gap-2 pt-2">
{card.specs.map((spec, i) => (
<span
key={i}
className="px-2.5 py-1 rounded-lg bg-slate-100 text-slate-700 text-xs font-mono font-medium border border-slate-200/60"
>
✓ {spec}
</span>
))}
</div>
{/* Actions */}
<div className="pt-4 flex flex-wrap items-center justify-between gap-3 border-t border-slate-900/[0.06]">
<Link
href={`/tools/${card.toolSlug}`}
className="inline-flex items-center gap-2 text-xs font-bold text-blue-700 hover:text-blue-900 group/link"
>
<span>Launch Interactive Studio</span>
<ArrowRight className="w-3.5 h-3.5 group-hover/link:translate-x-1 transition-transform" />
</Link>
<Link
href={`/apps/${card.appSlug}`}
className="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-slate-900 text-white text-xs font-bold hover:bg-blue-700 transition-colors shadow-sm"
>
<Smartphone className="w-3.5 h-3.5" />
<span>{card.appName}</span>
</Link>
</div>
</div>
</div>
))}
</div>
</div>
{/* Section Bottom Progress Indicator Bar */}
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 w-full z-10">
<div className="w-full bg-slate-200/80 h-1.5 rounded-full overflow-hidden shadow-inner">
<div
className="h-full bg-gradient-to-r from-blue-600 via-indigo-600 to-amber-500 rounded-full transition-all duration-100 ease-out"
style={{ width: `${Math.max(scrollProgress * 100, 3)}%` }}
/>
</div>
</div>
</div>
</section>
);
}