fix: streamline tool page to single upload and single compare, make vertical-horizontal transitions fluid and seamless
This commit is contained in:
@@ -40,7 +40,7 @@ export function BeforeAfterSection({
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className={`grid grid-cols-1 ${items.length > 1 ? 'md:grid-cols-2' : 'max-w-2xl mx-auto'} gap-8 sm:gap-10`}>
|
||||
<div className={`grid grid-cols-1 ${items.length > 1 ? 'md:grid-cols-2' : 'max-w-3xl mx-auto'} gap-8 sm:gap-10`}>
|
||||
{items.map((item, idx) => (
|
||||
<div key={idx} className="space-y-2 bg-white rounded-3xl p-4 sm:p-5 border border-slate-900/[0.08] shadow-cream-sm">
|
||||
<BeforeAfterSlider
|
||||
|
||||
@@ -41,12 +41,46 @@ export function CinematicHorizontalScrollSection({
|
||||
}: CinematicHorizontalProps) {
|
||||
const containerRef = useRef<HTMLElement>(null);
|
||||
const trackRef = useRef<HTMLDivElement>(null);
|
||||
const [translateX, setTranslateX] = useState(0);
|
||||
|
||||
const targetXRef = useRef(0);
|
||||
const currentXRef = useRef(0);
|
||||
const animFrameRef = useRef<number>(0);
|
||||
const isLoopRunningRef = useRef(false);
|
||||
|
||||
const [activeIndex, setActiveIndex] = useState(0);
|
||||
const [canScrollLeft, setCanScrollLeft] = useState(false);
|
||||
const [canScrollRight, setCanScrollRight] = useState(true);
|
||||
|
||||
// Synchronize horizontal track position with vertical scroll progress through sticky section
|
||||
// High-performance, responsive LERP animation loop to smooth wheel notches into liquid momentum
|
||||
const startLerpLoop = useCallback(() => {
|
||||
if (isLoopRunningRef.current) return;
|
||||
isLoopRunningRef.current = true;
|
||||
|
||||
const loop = () => {
|
||||
const track = trackRef.current;
|
||||
if (!track) {
|
||||
isLoopRunningRef.current = false;
|
||||
return;
|
||||
}
|
||||
|
||||
const diff = targetXRef.current - currentXRef.current;
|
||||
|
||||
if (Math.abs(diff) > 0.4) {
|
||||
// Responsive 0.28 damping factor: silky smoothing with zero perceptible lag
|
||||
currentXRef.current += diff * 0.28;
|
||||
track.style.transform = `translate3d(-${currentXRef.current.toFixed(2)}px, 0, 0)`;
|
||||
animFrameRef.current = requestAnimationFrame(loop);
|
||||
} else {
|
||||
currentXRef.current = targetXRef.current;
|
||||
track.style.transform = `translate3d(-${currentXRef.current.toFixed(2)}px, 0, 0)`;
|
||||
isLoopRunningRef.current = false;
|
||||
}
|
||||
};
|
||||
|
||||
animFrameRef.current = requestAnimationFrame(loop);
|
||||
}, []);
|
||||
|
||||
// Compute fluid horizontal translation directly from vertical scroll progress
|
||||
const updateTranslation = useCallback(() => {
|
||||
const container = containerRef.current;
|
||||
const track = trackRef.current;
|
||||
@@ -56,7 +90,9 @@ export function CinematicHorizontalScrollSection({
|
||||
const totalScrollable = container.offsetHeight - window.innerHeight;
|
||||
if (totalScrollable <= 0) return;
|
||||
|
||||
// Progress: 0.0 when section top hits viewport top, 1.0 when bottom unpins
|
||||
// Direct proportional progress through the sticky section [0.0, 1.0]
|
||||
// 0.0: Card 0 centered, exactly as section pins
|
||||
// 1.0: Final card centered, seamlessly unpins into vertical scroll
|
||||
const progress = Math.max(0, Math.min(1, -rect.top / totalScrollable));
|
||||
|
||||
const cards = Array.from(track.querySelectorAll('article'));
|
||||
@@ -66,9 +102,10 @@ export function CinematicHorizontalScrollSection({
|
||||
const lastCenter = cards[cards.length - 1].offsetLeft + cards[cards.length - 1].offsetWidth / 2;
|
||||
const maxDistance = lastCenter - firstCenter;
|
||||
|
||||
const targetX = progress * maxDistance;
|
||||
setTranslateX(targetX);
|
||||
targetXRef.current = progress * maxDistance;
|
||||
startLerpLoop();
|
||||
|
||||
// Sync active card index and button states
|
||||
const active = Math.min(
|
||||
cards.length - 1,
|
||||
Math.max(0, Math.round(progress * (cards.length - 1)))
|
||||
@@ -77,18 +114,11 @@ export function CinematicHorizontalScrollSection({
|
||||
|
||||
setCanScrollLeft(progress > 0.02);
|
||||
setCanScrollRight(progress < 0.98);
|
||||
}, []);
|
||||
}, [startLerpLoop]);
|
||||
|
||||
useEffect(() => {
|
||||
let ticking = false;
|
||||
const handleScroll = () => {
|
||||
if (!ticking) {
|
||||
requestAnimationFrame(() => {
|
||||
updateTranslation();
|
||||
ticking = false;
|
||||
});
|
||||
ticking = true;
|
||||
}
|
||||
updateTranslation();
|
||||
};
|
||||
|
||||
updateTranslation();
|
||||
@@ -98,10 +128,11 @@ export function CinematicHorizontalScrollSection({
|
||||
return () => {
|
||||
window.removeEventListener('scroll', handleScroll);
|
||||
window.removeEventListener('resize', handleScroll);
|
||||
if (animFrameRef.current) cancelAnimationFrame(animFrameRef.current);
|
||||
};
|
||||
}, [updateTranslation, items.length]);
|
||||
|
||||
// Slide between cards using side arrows
|
||||
// Slide smoothly between cards using side arrows
|
||||
const scrollDirection = (direction: 'left' | 'right') => {
|
||||
const container = containerRef.current;
|
||||
if (!container) return;
|
||||
@@ -113,10 +144,11 @@ export function CinematicHorizontalScrollSection({
|
||||
|
||||
const rect = container.getBoundingClientRect();
|
||||
const containerTopInDoc = window.scrollY + rect.top;
|
||||
const currentProgress = Math.max(0, Math.min(1, -rect.top / totalScrollable));
|
||||
const progress = Math.max(0, Math.min(1, -rect.top / totalScrollable));
|
||||
|
||||
const currentCardIndex = Math.min(
|
||||
cardsCount - 1,
|
||||
Math.max(0, Math.round(currentProgress * (cardsCount - 1)))
|
||||
Math.max(0, Math.round(progress * (cardsCount - 1)))
|
||||
);
|
||||
|
||||
let targetIndex = currentCardIndex;
|
||||
@@ -137,7 +169,7 @@ export function CinematicHorizontalScrollSection({
|
||||
|
||||
if (!items.length) return null;
|
||||
|
||||
// Vertical scroll distance: 100vh base + 85vh per additional card
|
||||
// Fluid vertical scroll distance: 100vh base + 85vh per additional card
|
||||
const containerHeightVh = 100 + (items.length - 1) * 85;
|
||||
|
||||
return (
|
||||
@@ -176,7 +208,7 @@ export function CinematicHorizontalScrollSection({
|
||||
}`}
|
||||
/>
|
||||
|
||||
{/* Left Side Arrow Button (Always visible on left side) */}
|
||||
{/* Left Side Arrow Button */}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => scrollDirection('left')}
|
||||
@@ -194,7 +226,7 @@ export function CinematicHorizontalScrollSection({
|
||||
style={{
|
||||
paddingLeft: 'calc((100vw - min(780px, 88vw)) / 2)',
|
||||
paddingRight: 'calc((100vw - min(780px, 88vw)) / 2)',
|
||||
transform: `translate3d(-${translateX}px, 0, 0)`,
|
||||
transform: 'translate3d(0px, 0px, 0px)',
|
||||
}}
|
||||
>
|
||||
{items.map((item) => (
|
||||
@@ -202,7 +234,7 @@ export function CinematicHorizontalScrollSection({
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Right Side Arrow Button (Always visible on right side) */}
|
||||
{/* Right Side Arrow Button */}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => scrollDirection('right')}
|
||||
|
||||
@@ -90,18 +90,17 @@ export function HeroSection({
|
||||
|
||||
// Dedicated Tool Landing Hero (for Google Search / Direct Traffic SEO)
|
||||
if (variant === 'toolHero' && tool) {
|
||||
const example = tool.content?.examples?.[0];
|
||||
const categoryName = tool.category?.replace('-', ' ').toUpperCase() || 'AI TOOL';
|
||||
const appName = homeApp ? resolveLocalised(homeApp.name, locale) : 'Mobile App';
|
||||
|
||||
return (
|
||||
<section className="relative isolate overflow-hidden pt-28 pb-16 sm:pt-36 sm:pb-20 lg:pt-40 lg:pb-24 bg-[#FAF8F5] border-b border-slate-900/[0.07]">
|
||||
<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]">
|
||||
{/* 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">
|
||||
<div className="relative z-10 max-w-5xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
{/* Breadcrumb Navigation */}
|
||||
<nav aria-label="Breadcrumb" className="mb-6 flex items-center gap-2 text-xs font-medium text-slate-500">
|
||||
<nav aria-label="Breadcrumb" className="mb-6 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,63 +108,40 @@ export function HeroSection({
|
||||
<span className="text-slate-900 font-semibold">{resolvedTitle}</span>
|
||||
</nav>
|
||||
|
||||
<div className="grid lg:grid-cols-[1fr_1.1fr] gap-10 xl:gap-14 items-center">
|
||||
{/* Left Column: Value Proposition & Actions */}
|
||||
<div className="max-w-xl">
|
||||
<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} • NEURAL MODEL</span>
|
||||
</div>
|
||||
|
||||
<h1 className="mt-5 text-3xl sm:text-4xl lg:text-5xl font-display font-black tracking-tight text-slate-900 leading-[1.08]">
|
||||
{resolvedTitle}
|
||||
</h1>
|
||||
|
||||
<p className="mt-4 text-base sm:text-lg leading-relaxed text-slate-600">
|
||||
{resolvedSubtitle}
|
||||
</p>
|
||||
|
||||
{/* Key Feature Specs */}
|
||||
<div className="mt-6 flex flex-wrap gap-2.5">
|
||||
<span className="inline-flex items-center gap-1.5 rounded-lg border border-slate-900/10 bg-white px-3 py-1.5 text-xs font-semibold text-slate-700 shadow-sm">
|
||||
<Check className="h-3.5 w-3.5 text-blue-700" /> Lossless 4K Output
|
||||
</span>
|
||||
<span className="inline-flex items-center gap-1.5 rounded-lg border border-slate-900/10 bg-white px-3 py-1.5 text-xs font-semibold text-slate-700 shadow-sm">
|
||||
<Zap className="h-3.5 w-3.5 text-amber-600" /> Instant Processing
|
||||
</span>
|
||||
<span className="inline-flex items-center gap-1.5 rounded-lg border border-slate-900/10 bg-white px-3 py-1.5 text-xs font-semibold text-slate-700 shadow-sm">
|
||||
<ShieldCheck className="h-3.5 w-3.5 text-emerald-600" /> 100% Free Online
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* App Availability */}
|
||||
{homeApp && (
|
||||
<div className="mt-7">
|
||||
<Link
|
||||
href={`/apps/${homeApp.slug}`}
|
||||
className="inline-flex items-center gap-2 rounded-full border border-slate-300/80 bg-white/80 px-5 py-3 text-xs sm: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" /> Available in {appName} for iOS & Android
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Trust Badges */}
|
||||
<div className="mt-8 flex flex-wrap gap-x-5 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 needed</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"><ImagePlus className="h-4 w-4 text-emerald-600" /> Instant preview</span>
|
||||
</div>
|
||||
{/* Centered Tool Header */}
|
||||
<div className="text-center max-w-3xl mx-auto">
|
||||
<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>
|
||||
|
||||
{/* Right Column: Front Screen ONLY Upload Image Option (No before/after) */}
|
||||
<div className="relative min-w-0" id="tool-tryit">
|
||||
<div className="absolute -inset-4 rounded-[2.5rem] bg-gradient-to-br from-blue-200/40 via-white/30 to-amber-100/50 blur-2xl pointer-events-none" />
|
||||
<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} />
|
||||
</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]">
|
||||
{resolvedTitle}
|
||||
</h1>
|
||||
|
||||
<p className="mt-4 text-base sm:text-lg 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} />
|
||||
</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">
|
||||
<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>
|
||||
{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
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
|
||||
@@ -170,37 +170,22 @@ export function TryItWidget({
|
||||
return (
|
||||
<div className={`relative bg-white rounded-3xl p-5 sm:p-8 lg:p-10 border border-slate-900/[0.08] shadow-cream-md overflow-hidden ${className}`}>
|
||||
{/* Top Header & Tries Counter */}
|
||||
<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-4 pb-5 sm:pb-6 border-b border-slate-100">
|
||||
<div className="flex items-center gap-3 sm:gap-4 min-w-0">
|
||||
<div className="w-10 h-10 sm:w-11 sm:h-11 rounded-2xl bg-gradient-to-tr from-blue-600 via-indigo-600 to-blue-700 flex items-center justify-center text-white shadow-md shadow-blue-500/20 shrink-0">
|
||||
<Zap className="w-5 h-5" />
|
||||
</div>
|
||||
<div className="min-w-0">
|
||||
<div className="flex flex-wrap items-center gap-2 sm:gap-2.5">
|
||||
<h3 className="font-display font-bold text-slate-900 text-base sm:text-lg tracking-tight">
|
||||
{resolveLocalised(tool.name, locale)}
|
||||
</h3>
|
||||
<div className="inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-[11px] font-mono font-semibold text-blue-700 bg-gradient-to-r from-blue-50 via-indigo-50/60 to-blue-50 border border-blue-200/80 shadow-2xs whitespace-nowrap">
|
||||
<span className="relative flex h-2 w-2">
|
||||
<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>Free Browser Trial</span>
|
||||
</div>
|
||||
</div>
|
||||
<p className="text-xs text-slate-500 mt-1 font-normal flex items-center gap-1.5 flex-wrap">
|
||||
<span>Studio-Grade AI Enhancement</span>
|
||||
<span className="text-slate-300 hidden sm:inline">•</span>
|
||||
<span className="hidden sm:inline">Instant Visual Quality</span>
|
||||
</p>
|
||||
<div className="flex items-center justify-between gap-4 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-blue-50 border border-blue-200/80 flex items-center justify-center text-blue-600">
|
||||
<UploadCloud className="w-4 h-4" />
|
||||
</div>
|
||||
<span className="text-xs sm:text-sm font-display font-semibold text-slate-800">
|
||||
Try Online Free
|
||||
</span>
|
||||
<span className="hidden sm:inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-[10px] font-mono font-semibold text-blue-700 bg-blue-50 border border-blue-200/80">
|
||||
Lossless AI
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-between sm:justify-end gap-2 shrink-0 pt-2.5 sm:pt-0 border-t sm:border-t-0 border-slate-100">
|
||||
<div className="inline-flex items-center gap-2 bg-emerald-50 border border-emerald-200/90 px-3.5 py-1.5 rounded-full text-xs font-mono text-emerald-800 font-semibold shadow-2xs">
|
||||
<span className="w-2 h-2 rounded-full bg-emerald-500 animate-pulse"></span>
|
||||
<span>{remainingTries} free tries today</span>
|
||||
</div>
|
||||
<div className="inline-flex items-center gap-2 bg-emerald-50 border border-emerald-200/90 px-3.5 py-1 rounded-full text-xs font-mono text-emerald-800 font-semibold shadow-2xs">
|
||||
<span className="w-2 h-2 rounded-full bg-emerald-500 animate-pulse"></span>
|
||||
<span>{remainingTries} free tries today</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user