+ {/* Left Column: Interactive Before/After Transformation Preview */}
+
+
+
+ Real AI Transformation Output
+
+
+ Auto-sliding & scrubber
+
-
- Drag & drop your photo here, or browse file
-
-
- Supports JPG, PNG, WEBP up to {tool.tryIt?.limits?.maxMB || 12}MB
-
+
+ {tool.content?.examples?.[0]?.before && tool.content?.examples?.[0]?.after ? (
+
+
+
+ ) : (
+
+ Transformation preview
+
+ )}
+
+ {tool.content?.examples?.[0]?.caption && (
+
+ {tool.content.examples[0].caption}
+
+ )}
-
- Or inspect with an instant sample photo:
-
-
- {samplePresets.map((preset, idx) => (
-
- ))}
+ {/* Right Column: Upload Zone & Instant Samples */}
+
+
+
+ Try with your photo
+
+
+ Test {resolveLocalised(tool.name, locale)} in your browser with zero setup or sign-in.
+
+
+
+ {/* Drag & Drop Upload Zone */}
+
{
+ e.preventDefault();
+ setIsDragOver(true);
+ }}
+ onDragLeave={() => setIsDragOver(false)}
+ onClick={() => fileInputRef.current?.click()}
+ onKeyDown={(e) => {
+ if (e.key === 'Enter' || e.key === ' ') {
+ e.preventDefault();
+ fileInputRef.current?.click();
+ }
+ }}
+ role="button"
+ tabIndex={0}
+ aria-label="Choose a JPG, PNG, or WebP photo to edit"
+ className={`border-2 border-dashed rounded-2xl p-6 sm:p-8 text-center cursor-pointer transition-all duration-300 group ${
+ isDragOver
+ ? 'border-blue-500 bg-blue-50/50 scale-[1.01]'
+ : 'border-slate-300 hover:border-blue-500 bg-slate-50/60 hover:bg-blue-50/30'
+ }`}
+ >
+
e.target.files?.[0] && handleFileChange(e.target.files[0])}
+ />
+
+
+
+
+ Drop your photo here, or browse
+
+
+ JPG, PNG, WebP up to {tool.tryIt?.limits?.maxMB || 12}MB
+
+
+
+ {/* Quick Sample Presets */}
+
+
+ Or test instantly with a sample photo:
+
+
+ {samplePresets.map((preset, idx) => (
+
+ ))}
+
diff --git a/src/components/sections/VerticalToolStackSection.tsx b/src/components/sections/VerticalToolStackSection.tsx
index 93ff95c..a5008ca 100644
--- a/src/components/sections/VerticalToolStackSection.tsx
+++ b/src/components/sections/VerticalToolStackSection.tsx
@@ -5,7 +5,7 @@ import type { ElementType } from 'react';
import Link from 'next/link';
import { ArrowRight, Layers, Palette, Scissors, Smile, Sparkles } from 'lucide-react';
import { AppItem, CategoryItem, resolveLocalised, ToolItem } from '@/types';
-import { DeferredComparison } from '@/components/ui/DeferredComparison';
+import { CardBeforeAfterSlider } from '@/components/ui/CardBeforeAfterSlider';
interface VerticalToolStackProps {
context: { tools: ToolItem[]; categories: CategoryItem[]; apps: AppItem[]; locale: string };
@@ -87,7 +87,7 @@ function ToolCard({ tool, app, locale }: { tool: ToolItem; app?: AppItem; locale
{hasComparison ? (
-
)}
-
+
{tool.category.replace('-', ' ')}
diff --git a/src/components/ui/CardBeforeAfterSlider.tsx b/src/components/ui/CardBeforeAfterSlider.tsx
new file mode 100644
index 0000000..7cd8768
--- /dev/null
+++ b/src/components/ui/CardBeforeAfterSlider.tsx
@@ -0,0 +1,177 @@
+'use client';
+
+import React, { useRef, useEffect, useCallback } from 'react';
+
+interface CardBeforeAfterSliderProps {
+ beforeUrl: string;
+ afterUrl: string;
+ beforeLabel?: string;
+ afterLabel?: string;
+ aspectRatio?: string;
+}
+
+export function CardBeforeAfterSlider({
+ beforeUrl,
+ afterUrl,
+ beforeLabel = 'BEFORE',
+ afterLabel = 'AFTER',
+ aspectRatio = 'aspect-[16/10]',
+}: CardBeforeAfterSliderProps) {
+ const containerRef = useRef(null);
+ const isHoveredRef = useRef(false);
+ const animIdRef = useRef(0);
+
+ const setSplit = useCallback((percent: number) => {
+ const clamped = Math.max(3, Math.min(97, percent));
+ if (containerRef.current) {
+ containerRef.current.style.setProperty('--split', `${clamped}%`);
+ containerRef.current.setAttribute('aria-valuenow', `${Math.round(clamped)}`);
+ }
+ }, []);
+
+ // Continuous auto-sliding animation when not actively hovered
+ useEffect(() => {
+ let startTime: number | null = null;
+ let isVisible = true;
+
+ const animate = (time: number) => {
+ if (!isVisible) return;
+ if (!isHoveredRef.current) {
+ if (startTime === null) startTime = time;
+ const elapsed = time - startTime;
+ // Smooth sine wave between 28% and 72% over a 3.4-second cycle
+ const currentSplit = 50 + 22 * Math.sin((elapsed / 3400) * 2 * Math.PI);
+ setSplit(currentSplit);
+ } else {
+ startTime = null;
+ }
+ animIdRef.current = requestAnimationFrame(animate);
+ };
+
+ const observer = new IntersectionObserver(
+ ([entry]) => {
+ isVisible = entry.isIntersecting;
+ if (isVisible) {
+ startTime = null;
+ animIdRef.current = requestAnimationFrame(animate);
+ } else {
+ cancelAnimationFrame(animIdRef.current);
+ }
+ },
+ { threshold: 0.05 }
+ );
+
+ if (containerRef.current) {
+ observer.observe(containerRef.current);
+ }
+
+ animIdRef.current = requestAnimationFrame(animate);
+
+ return () => {
+ cancelAnimationFrame(animIdRef.current);
+ observer.disconnect();
+ };
+ }, [setSplit]);
+
+ // Mouse move scrubber
+ const handleMouseMove = useCallback(
+ (e: React.MouseEvent) => {
+ isHoveredRef.current = true;
+ if (!containerRef.current) return;
+ const rect = containerRef.current.getBoundingClientRect();
+ const x = Math.max(0, Math.min(e.clientX - rect.left, rect.width));
+ const percent = (x / rect.width) * 100;
+ setSplit(percent);
+ },
+ [setSplit]
+ );
+
+ // Touch move scrubber
+ const handleTouchMove = useCallback(
+ (e: React.TouchEvent) => {
+ isHoveredRef.current = true;
+ if (!containerRef.current || !e.touches[0]) return;
+ const rect = containerRef.current.getBoundingClientRect();
+ const x = Math.max(0, Math.min(e.touches[0].clientX - rect.left, rect.width));
+ const percent = (x / rect.width) * 100;
+ setSplit(percent);
+ },
+ [setSplit]
+ );
+
+ const handlePointerLeave = useCallback(() => {
+ isHoveredRef.current = false;
+ }, []);
+
+ return (
+ { isHoveredRef.current = true; }}
+ onMouseLeave={handlePointerLeave}
+ onMouseMove={handleMouseMove}
+ onTouchStart={() => { isHoveredRef.current = true; }}
+ onTouchMove={handleTouchMove}
+ onTouchEnd={handlePointerLeave}
+ role="slider"
+ aria-label="Before and after transformation slider"
+ aria-valuenow={50}
+ tabIndex={0}
+ style={{ '--split': '50%' } as React.CSSProperties}
+ className={`relative w-full ${aspectRatio} overflow-hidden cursor-ew-resize select-none bg-slate-900 group/slider`}
+ >
+ {/* Layer 1: After Image (Transformed Neural Result) */}
+ {/* eslint-disable-next-line @next/next/no-img-element */}
+

+
+ {/* Layer 2: Before Image (Clipped Left by CSS variable --split) */}
+
+ {/* eslint-disable-next-line @next/next/no-img-element */}
+

+
+
+ {/* Layer 3: Vertical Split Divider Line */}
+
+ {/* Glowing Aura */}
+
+
+ {/* Center Pill Handle with Left/Right Arrows */}
+
+
+
+ {/* Floating Corner Badges */}
+
+ {beforeLabel}
+
+
+ {afterLabel}
+
+
+ {/* Scrub Hint */}
+
+ Scrub to compare
+
+
+ );
+}