diff --git a/src/components/sections/CinematicHorizontalScrollSection.tsx b/src/components/sections/CinematicHorizontalScrollSection.tsx index e5eac82..9efd94c 100644 --- a/src/components/sections/CinematicHorizontalScrollSection.tsx +++ b/src/components/sections/CinematicHorizontalScrollSection.tsx @@ -39,280 +39,180 @@ export function CinematicHorizontalScrollSection({ subtitle = 'Browse the flagship tools with native cinematic pan controls.', items = [], }: CinematicHorizontalProps) { - const sectionRef = useRef(null); - const railRef = useRef(null); - const activeIndexRef = useRef(0); - const lastWheelTimeRef = useRef(0); - + const containerRef = useRef(null); + const trackRef = useRef(null); + const [translateX, setTranslateX] = useState(0); + const [activeIndex, setActiveIndex] = useState(0); const [canScrollLeft, setCanScrollLeft] = useState(false); const [canScrollRight, setCanScrollRight] = useState(true); - // Helper to compute snap-center targets for all cards - const getCardPositions = useCallback(() => { - const rail = railRef.current; - if (!rail) return []; - const cards = Array.from(rail.querySelectorAll('article')); - if (!cards.length) return []; + // Synchronize horizontal track position with vertical scroll progress through sticky section + const updateTranslation = useCallback(() => { + const container = containerRef.current; + const track = trackRef.current; + if (!container || !track) return; - const halfView = rail.clientWidth / 2; - const maxScroll = Math.max(0, rail.scrollWidth - rail.clientWidth); + const rect = container.getBoundingClientRect(); + const totalScrollable = container.offsetHeight - window.innerHeight; + if (totalScrollable <= 0) return; - return cards.map((c) => { - const center = c.offsetLeft + c.offsetWidth / 2; - return Math.max(0, Math.min(maxScroll, Math.round(center - halfView))); - }); + // Progress: 0.0 when section top hits viewport top, 1.0 when bottom unpins + const progress = Math.max(0, Math.min(1, -rect.top / totalScrollable)); + + const cards = Array.from(track.querySelectorAll('article')); + if (cards.length <= 1) return; + + const firstCenter = cards[0].offsetLeft + cards[0].offsetWidth / 2; + const lastCenter = cards[cards.length - 1].offsetLeft + cards[cards.length - 1].offsetWidth / 2; + const maxDistance = lastCenter - firstCenter; + + const targetX = progress * maxDistance; + setTranslateX(targetX); + + const active = Math.min( + cards.length - 1, + Math.max(0, Math.round(progress * (cards.length - 1))) + ); + setActiveIndex(active); + + setCanScrollLeft(progress > 0.02); + setCanScrollRight(progress < 0.98); }, []); - // Update bounds and sync active card index on scroll - const checkScrollBounds = useCallback(() => { - const rail = railRef.current; - if (!rail) return; - const maxScroll = rail.scrollWidth - rail.clientWidth; - const current = rail.scrollLeft; - - setCanScrollLeft(current > 8); - setCanScrollRight(current < maxScroll - 8); - - // Sync active index with nearest card - const positions = getCardPositions(); - if (positions.length > 0) { - let closest = 0; - let minDiff = Infinity; - positions.forEach((pos, idx) => { - const diff = Math.abs(pos - current); - if (diff < minDiff) { - minDiff = diff; - closest = idx; - } - }); - activeIndexRef.current = closest; - } - }, [getCardPositions]); - - // Update on mount, resize, and scroll useEffect(() => { - const rail = railRef.current; - if (!rail) return; - - checkScrollBounds(); - + let ticking = false; const handleScroll = () => { - checkScrollBounds(); + if (!ticking) { + requestAnimationFrame(() => { + updateTranslation(); + ticking = false; + }); + ticking = true; + } }; - rail.addEventListener('scroll', handleScroll, { passive: true }); - window.addEventListener('resize', checkScrollBounds); + updateTranslation(); + window.addEventListener('scroll', handleScroll, { passive: true }); + window.addEventListener('resize', handleScroll); return () => { - rail.removeEventListener('scroll', handleScroll); - window.removeEventListener('resize', checkScrollBounds); + window.removeEventListener('scroll', handleScroll); + window.removeEventListener('resize', handleScroll); }; - }, [checkScrollBounds, items.length]); + }, [updateTranslation, items.length]); - // Mandatory Horizontal Scroll Lock: - // Visitor cannot scroll down past this section until the horizontal scroll is completely finished. - useEffect(() => { - const rail = railRef.current; - const section = sectionRef.current; - if (!rail || !section) return; - - const WHEEL_COOLDOWN = 450; // Smooth glide cooldown between cards - - const handleWheel = (e: WheelEvent) => { - // Allow native 2-finger horizontal trackpad gestures - if (Math.abs(e.deltaX) >= Math.abs(e.deltaY)) { - return; - } - - // Ignore micro-jitters - if (Math.abs(e.deltaY) < 8) { - return; - } - - const sectionRect = section.getBoundingClientRect(); - const railRect = rail.getBoundingClientRect(); - const vh = window.innerHeight; - - // If the showcase section is completely outside the viewport, do nothing - if (sectionRect.bottom < 0 || sectionRect.top > vh) { - return; - } - - const railCenter = railRect.top + railRect.height / 2; - const isDown = e.deltaY > 0; - const isUp = e.deltaY < 0; - const currentIndex = activeIndexRef.current; - const positions = getCardPositions(); - if (positions.length <= 1) return; - - const lastIndex = positions.length - 1; - - // 1. Approaching from above: allow normal page scroll until cards align in the middle of the screen - if (currentIndex === 0 && isDown && railCenter > vh * 0.65) { - return; - } - - // 2. Approaching from below: allow normal page scroll up until cards align in the middle of the screen - if (currentIndex === lastIndex && isUp && railCenter < vh * 0.35) { - return; - } - - const now = Date.now(); - - // 3. Mandatory completion release & momentum absorption: - // At last card scrolling down: - if (isDown && currentIndex >= lastIndex) { - // If we just glided to the last card, absorb residual wheel burst so visitor doesn't skip seeing it - if (now - lastWheelTimeRef.current < WHEEL_COOLDOWN + 150) { - e.preventDefault(); - return; - } - // Horizontal scroll is complete! Release lock and allow visitor to scroll down the page - return; - } - - // At first card scrolling up: - if (isUp && currentIndex <= 0) { - // If we just glided to the first card, absorb residual wheel burst - if (now - lastWheelTimeRef.current < WHEEL_COOLDOWN + 150) { - e.preventDefault(); - return; - } - // At first card scrolling up -> release lock and allow visitor to scroll up the page - return; - } - - // 4. In all other cases while showcase is aligned in middle and horizontal cards are incomplete: - // LOCK VERTICAL PAGE SCROLL (Visitor CANNOT scroll down past the section until horizontal scroll is finished) - e.preventDefault(); - - // Absorb rapid wheel bursts during active glide transition - if (now - lastWheelTimeRef.current < WHEEL_COOLDOWN) { - return; - } - lastWheelTimeRef.current = now; - - // Glide smoothly to next or previous card - if (isDown && currentIndex < lastIndex) { - const nextIndex = currentIndex + 1; - activeIndexRef.current = nextIndex; - rail.scrollTo({ - left: positions[nextIndex], - behavior: 'smooth', - }); - } else if (isUp && currentIndex > 0) { - const prevIndex = currentIndex - 1; - activeIndexRef.current = prevIndex; - rail.scrollTo({ - left: positions[prevIndex], - behavior: 'smooth', - }); - } - }; - - window.addEventListener('wheel', handleWheel, { passive: false }); - return () => { - window.removeEventListener('wheel', handleWheel); - }; - }, [getCardPositions]); - - // Slide precisely between cards using side arrows + // Slide between cards using side arrows const scrollDirection = (direction: 'left' | 'right') => { - const rail = railRef.current; - if (!rail) return; + const container = containerRef.current; + if (!container) return; + const totalScrollable = container.offsetHeight - window.innerHeight; + if (totalScrollable <= 0) return; - const positions = getCardPositions(); - if (positions.length <= 1) return; + const cardsCount = items.length; + if (cardsCount <= 1) return; - const current = rail.scrollLeft; - let targetIndex = activeIndexRef.current; + const rect = container.getBoundingClientRect(); + const containerTopInDoc = window.scrollY + rect.top; + const currentProgress = Math.max(0, Math.min(1, -rect.top / totalScrollable)); + const currentCardIndex = Math.min( + cardsCount - 1, + Math.max(0, Math.round(currentProgress * (cardsCount - 1))) + ); + let targetIndex = currentCardIndex; if (direction === 'right') { - const nextIdx = positions.findIndex((pos) => pos > current + 15); - targetIndex = nextIdx !== -1 ? nextIdx : positions.length - 1; - } else { - let prevIdx = -1; - for (let i = positions.length - 1; i >= 0; i--) { - if (positions[i] < current - 15) { - prevIdx = i; - break; - } - } - targetIndex = prevIdx !== -1 ? prevIdx : 0; + targetIndex = Math.min(cardsCount - 1, currentCardIndex + 1); + } else if (direction === 'left') { + targetIndex = Math.max(0, currentCardIndex - 1); } - activeIndexRef.current = targetIndex; - rail.scrollTo({ - left: positions[targetIndex], + const targetProgress = targetIndex / (cardsCount - 1); + const targetScrollY = Math.round(containerTopInDoc + targetProgress * totalScrollable); + + window.scrollTo({ + top: targetScrollY, behavior: 'smooth', }); }; if (!items.length) return null; + // Vertical scroll distance: 100vh base + 85vh per additional card + const containerHeightVh = 100 + (items.length - 1) * 85; + return (
-
-
-
-

{badge}

-

{title}

-

{subtitle}

+
+ {/* Section Header */} +
+
+
+

{badge}

+

{title}

+

{subtitle}

+
+

Scroll down to explore models

-

Scroll cards vertically, swipe, or use side arrows

-
-
- -
- {/* Soft edge fades for polished visual boundary */} -
); @@ -322,9 +222,9 @@ function ShowcaseCard({ item }: { item: ShowcaseItem }) { const comparison = item.variant !== 'banner' && item.beforeUrl && item.afterUrl; return ( -
+
-
+
{comparison ? ( ) : ( -
+
{/* eslint-disable-next-line @next/next/no-img-element */} -
+
{item.index} {item.latency}
-

{item.category}

-

{item.title}

-

{item.description}

-
    +

    {item.category}

    +

    {item.title}

    +

    {item.description}

    +
      {item.specs.slice(0, 3).map((spec) => (
    • @@ -369,11 +269,11 @@ function ShowcaseCard({ item }: { item: ShowcaseItem }) {
    • ))}
    -
    - +
    + Try online - + App
    diff --git a/src/components/sections/HeroSection.tsx b/src/components/sections/HeroSection.tsx index a074056..fe05a8b 100644 --- a/src/components/sections/HeroSection.tsx +++ b/src/components/sections/HeroSection.tsx @@ -2,13 +2,13 @@ import React from 'react'; import Link from 'next/link'; -import { Sparkles, ArrowRight, Smartphone, Layers, ShieldCheck, LockKeyhole, ImagePlus } from 'lucide-react'; +import { Sparkles, ArrowRight, Smartphone, Layers, ShieldCheck, LockKeyhole, ImagePlus, Check, Zap } from 'lucide-react'; import { resolveLocalised, ToolItem, AppItem, VariantSpec } from '@/types'; import { TryItWidget } from './TryItWidget'; -import { Hero3DCanvas } from '@/components/3d/Hero3DCanvas'; +import { HeroPrism } from '@/components/3d/HeroPrism'; import { Kinetic3DText } from '@/components/ui/Kinetic3DText'; import { ShimmerBadge } from '@/components/animate-ui/ShimmerBadge'; -import { BorderBeam } from '@/components/animate-ui/BorderBeam'; +import { DeferredComparison } from '@/components/ui/DeferredComparison'; interface HeroSectionProps { title?: any; @@ -43,7 +43,7 @@ export function HeroSection({
    @@ -78,8 +78,7 @@ export function HeroSection({
    -
    -
    +
    @@ -89,6 +88,114 @@ 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 ( +
    + {/* Ambient subtle warm gradient */} +
    + +
    + {/* Breadcrumb Navigation */} + + +
    + {/* Left Column: Value Proposition & Actions */} +
    +
    + + {categoryName} • NEURAL MODEL +
    + +

    + {resolvedTitle} +

    + +

    + {resolvedSubtitle} +

    + + {/* Key Feature Specs */} +
    + + Lossless 4K Output + + + Instant Processing + + + 100% Free Online + +
    + + {/* CTAs */} +
    + + Try with your photo + + {homeApp && ( + + {appName} App + + )} +
    + + {/* Trust Badges */} +
    + No account needed + Photos never stored + Instant preview +
    +
    + + {/* Right Column: Hero Interactive Transformation Showcase */} +
    +
    +
    + {example?.before && example?.after ? ( +
    + + {example.caption && ( +

    + {example.caption} +

    + )} +
    + ) : ( +
    + Interactive transformation preview +
    + )} +
    +
    +
    +
    +
    + ); + } + // Centered Hero for Tools/Apps/Pricing pages return (
    diff --git a/src/components/sections/VerticalToolStackSection.tsx b/src/components/sections/VerticalToolStackSection.tsx index 11fefdd..93ff95c 100644 --- a/src/components/sections/VerticalToolStackSection.tsx +++ b/src/components/sections/VerticalToolStackSection.tsx @@ -1,388 +1,139 @@ 'use client'; -import React, { useState } from 'react'; +import { useMemo, useState } from 'react'; +import type { ElementType } from 'react'; import Link from 'next/link'; -import { - Smile, - Sparkles, - Scissors, - Palette, - Layers, - ArrowRight, - CheckCircle2, - Zap, - ShieldCheck, - Cpu, - Smartphone, -} from 'lucide-react'; -import { resolveLocalised, ToolItem, CategoryItem, AppItem } from '@/types'; -import { BeforeAfterSlider } from '@/components/ui/BeforeAfterSlider'; -import { SpotlightCard } from '@/components/animate-ui/SpotlightCard'; -import { ShimmerBadge } from '@/components/animate-ui/ShimmerBadge'; -import { MotionTextReveal } from '@/components/animate-ui/MotionTextReveal'; -import { AnimatedGradientText } from '@/components/animate-ui/AnimatedGradientText'; +import { ArrowRight, Layers, Palette, Scissors, Smile, Sparkles } from 'lucide-react'; +import { AppItem, CategoryItem, resolveLocalised, ToolItem } from '@/types'; +import { DeferredComparison } from '@/components/ui/DeferredComparison'; -export interface VerticalToolStackProps { - context: { - tools: ToolItem[]; - categories: CategoryItem[]; - apps: AppItem[]; - locale: string; - }; +interface VerticalToolStackProps { + context: { tools: ToolItem[]; categories: CategoryItem[]; apps: AppItem[]; locale: string }; } -const ICON_MAP: Record = { - Smile, - Sparkles, - Scissors, - Palette, - Layers, -}; +const icons: Record = { Smile, Sparkles, Scissors, Palette, Layers }; -// Architecture badges mapped by tool id -const MODEL_BADGES: Record = { - 'face.blemish.remove': { model: 'RetouchGAN v2.1', latency: '< 380ms', chip: 'Sub-Pore Texture' }, - 'face.teeth.whitener': { model: 'DentiClear AI', latency: '< 290ms', chip: 'Enamel Lustre Preservation' }, - 'cutout.p3m.bg': { model: 'P3M-Net Alpha', latency: '< 520ms', chip: 'Hair-Strand Precision' }, - 'restore.enhancer': { model: 'GFPGAN + RealESRGAN', latency: '< 460ms', chip: '4K Super-Resolution' }, - 'restore.oldphoto': { model: 'ScratchDeNet Pro', latency: '< 490ms', chip: 'Crack & Tear Inpainting' }, - 'restore.colorization': { model: 'DeOldify Chroma', latency: '< 420ms', chip: 'Historical Palette AI' }, - 'art.cartoon.gan': { model: 'AnimeGAN v3 Core', latency: '< 350ms', chip: 'Vector Line Art' }, - 'art.polaroid.film': { model: 'AnalogFilm Studio', latency: '< 240ms', chip: 'Halide Grain Synthesis' }, -}; - -const ACCENT_STYLES: Record = { - 'background-cutout': { - badge: 'bg-blue-50 border-blue-200 text-blue-700', - text: 'text-blue-600', - }, - 'restoration': { - badge: 'bg-emerald-50 border-emerald-200 text-emerald-700', - text: 'text-emerald-600', - }, - 'creative-art': { - badge: 'bg-purple-50 border-purple-200 text-purple-700', - text: 'text-purple-600', - }, - 'portrait-retouch': { - badge: 'bg-amber-50 border-amber-200 text-amber-700', - text: 'text-amber-600', - }, -}; +const fallbackImage = 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=720&auto=format&fit=crop&q=76'; export function VerticalToolStackSection({ context }: VerticalToolStackProps) { const { tools, categories, apps, locale } = context; - const [selectedCategory, setSelectedCategory] = useState('all'); - - const filteredCategories = selectedCategory === 'all' - ? categories - : categories.filter((c) => c.slug === selectedCategory); + const [category, setCategory] = useState('all'); + const visibleCategories = useMemo( + () => category === 'all' ? categories : categories.filter((item) => item.slug === category), + [categories, category] + ); return ( -
    - {/* Anchor alias for backwards compatibility */} -
    +
    +
    +
    +
    +

    THE CREATIVE STUDIO SUITE

    +

    Find the right tool, fast.

    +

    Choose a creative task, see a real preview, and start your edit in one tap.

    +
    - {/* Subtle ambient light gradient */} -
    - - {/* Full-width expansive container spanning the entire page */} -
    - {/* Section Header: Centered & Balanced with Animate UI Text Motion */} -
    -
    - - - THE CREATIVE STUDIO SUITE - -
    -

    - {' '} - Vision Tools -

    -

    - Precision deep learning models organized by creative discipline. Test sub-millimeter skin pore retouching, fine hair alpha matting, and 4K super-resolution directly in your browser. -

    -
    - - {/* Centered Symmetrical Category Filter Rail */} -
    - - - {categories.map((cat) => { - const catTools = tools.filter((t) => t.category === cat.slug); - const active = selectedCategory === cat.slug; - const Icon = ICON_MAP[cat.icon || 'Sparkles'] || Sparkles; - - return ( - - ); +
    + setCategory('all')} label="All tools" count={tools.length} icon={Layers} /> + {categories.map((item) => { + const Icon = icons[item.icon || 'Sparkles'] || Sparkles; + return setCategory(item.slug)} label={resolveLocalised(item.name, locale)} count={tools.filter((tool) => tool.category === item.slug).length} icon={Icon} />; })}
    - {/* Expansive Full-Width Vertical Tool Stack */} -
    - {filteredCategories.map((category) => { - const catTools = tools.filter((t) => t.category === category.slug); - if (catTools.length === 0) return null; - const Icon = ICON_MAP[category.icon || 'Sparkles'] || Sparkles; - +
    + {visibleCategories.map((item) => { + const categoryTools = tools.filter((tool) => tool.category === item.slug); + if (!categoryTools.length) return null; + const Icon = icons[item.icon || 'Sparkles'] || Sparkles; return ( -
    - {/* Category Section Header */} -
    -
    -
    - -
    +
    +
    +
    +
    -

    - {resolveLocalised(category.name, locale)} -

    -

    - {resolveLocalised(category.description, locale)} -

    +

    {resolveLocalised(item.name, locale)}

    +

    {resolveLocalised(item.description, locale)}

    - - {catTools.length} {catTools.length === 1 ? 'Production Tool' : 'Production Tools'} - + {categoryTools.length} tools
    - - {/* Dynamic Multi-Format Tool Cards with Alternating Layouts */} -
    - {catTools.map((tool, toolIdx) => { - const homeApp = apps.find((app) => app.id === tool.homeApp); - const badgeInfo = MODEL_BADGES[tool.id] || { - model: 'Neural Vision v2.0', - latency: '< 450ms', - chip: 'Neural Precision', - }; - const example = 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-1517841905240-472988babdf9?w=800&auto=format&fit=crop&q=80', - caption: 'Interactive Before/After Preview', - }; - - const isZigZag = toolIdx % 2 === 1; - const isMattingTool = tool.id === 'cutout.p3m.bg'; - const isTeethTool = tool.id === 'face.teeth.whitener'; - const isArtTool = tool.category === 'creative-art' || tool.id === 'art.cartoon.gan'; - const isBanner = (tool as any).variant === 'banner' || (tool as any).previewType === 'banner' || isTeethTool || !example.after; - - // Category accent styles - const accent = ACCENT_STYLES[tool.category] || ACCENT_STYLES['portrait-retouch']; - - return ( - - {/* Top Metadata Row */} -
    -
    - - - {badgeInfo.model} - - - {badgeInfo.chip} - -
    - -
    - - {badgeInfo.latency} Stream -
    -
    - - {/* Symmetrical Two-Column Content Grid with Alternating Zig-Zag Flow */} -
    - {/* Visual Media Viewport */} -
    - {isMattingTool ? ( - /* VARIATION B: Side-by-Side Transparent Alpha Cutout Frame with Checkerboard */ -
    -
    - {/* eslint-disable-next-line @next/next/no-img-element */} - Source Portrait - - RAW PORTRAIT - -
    -
    - {/* eslint-disable-next-line @next/next/no-img-element */} - P3M Cutout - - ALPHA PNG STREAM - -
    -
    - ) : isBanner ? ( - /* VARIATION C: Editorial Studio Luminescence Banner */ -
    - {/* eslint-disable-next-line @next/next/no-img-element */} - {resolveLocalised(tool.name, -
    -
    - - STUDIO PRESET • {badgeInfo.model} - -
    -
    - Enamel Lustre Preservation - Lossless Output -
    -
    - ) : ( - /* VARIATION A: Interactive 3D Before/After Slider */ -
    - -
    - )} -
    - - {/* Editorial Details Column */} -
    -
    - - {badgeInfo.chip} - -

    - {resolveLocalised(tool.name, locale)} -

    -
    - -

    - {resolveLocalised(tool.summary, locale)} -

    - - {/* Features Checklist */} -
    -
    - - Sub-pixel edge and realistic texture preservation -
    -
    - - Studio-grade 4K lossless enhancement -
    -
    - - Full creative control in native iOS & Android apps -
    -
    - - {/* Action Buttons */} -
    - - Launch Tool Online - - - - - - Native App - -
    -
    -
    - - ); - })} +
    + {categoryTools.map((tool) => item.id === tool.homeApp)} locale={locale} />)}
    -
    +
    ); })}
    - - {/* Centered Symmetrical Bottom Banner (Expansive Width) */} -
    -
    -
    - -
    -
    -

    - Dedicated Mobile Creative Suites for iOS & Android -

    -

    - Batch enhancement, RAW camera file support, and instant offline exports across our native mobile app lineup. -

    -
    -
    - - Explore Mobile Apps - - -
    ); } + +function FilterButton({ active, onClick, label, count, icon: Icon }: { active: boolean; onClick: () => void; label: string; count: number; icon: ElementType }) { + return ( + + ); +} + +function ToolCard({ tool, app, locale }: { tool: ToolItem; app?: AppItem; locale: string }) { + const example = tool.content?.examples?.[0]; + const hasComparison = !!(example?.before && example?.after); + const image = example?.after || example?.before || fallbackImage; + + return ( +
    +
    + {hasComparison ? ( + + ) : ( + /* eslint-disable-next-line @next/next/no-img-element */ + {resolveLocalised(tool.name, + )} + + {tool.category.replace('-', ' ')} + +
    +
    +

    + + {resolveLocalised(tool.name, locale)} + +

    +

    + {resolveLocalised(tool.summary, locale)} +

    +
    + + Try it + + {app && ( + + Get app + + )} +
    +
    +
    + ); +}