2026-11-04 17:55:18 +05:30
|
|
|
'use client';
|
|
|
|
|
|
|
|
|
|
import React, { useState, useRef, useEffect } from 'react';
|
|
|
|
|
import Link from 'next/link';
|
|
|
|
|
import { ArrowRight, Sparkles, Video, Sliders, Image as ImageIcon } from 'lucide-react';
|
|
|
|
|
import { TextAnimate } from '@/components/magicui/text-animate';
|
|
|
|
|
import { ToolItem } from '@/types';
|
|
|
|
|
|
|
|
|
|
export interface ToolMediaItem {
|
|
|
|
|
id: string;
|
|
|
|
|
slug: string;
|
|
|
|
|
title: string;
|
|
|
|
|
mediaType: 'video' | 'photo' | 'comparison';
|
|
|
|
|
videoUrl?: string;
|
|
|
|
|
poster?: string;
|
|
|
|
|
imageUrl?: string;
|
|
|
|
|
beforeUrl?: string;
|
|
|
|
|
afterUrl?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface ShiftableToolsGridProps {
|
|
|
|
|
title?: string;
|
|
|
|
|
subtitle?: string;
|
|
|
|
|
tools?: ToolItem[];
|
|
|
|
|
items?: ToolMediaItem[];
|
|
|
|
|
locale?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const DEFAULT_TOOL_ITEMS: ToolMediaItem[] = [
|
|
|
|
|
// ROW 1 (4 items)
|
|
|
|
|
{
|
|
|
|
|
id: 'tool-blemish',
|
|
|
|
|
slug: 'blemish-remover',
|
|
|
|
|
title: 'Blemish & Acne Remover',
|
|
|
|
|
mediaType: 'comparison',
|
|
|
|
|
beforeUrl: '/management/pages/tools/blemish-remover/media/before.jpg',
|
|
|
|
|
afterUrl: '/management/pages/tools/blemish-remover/media/after.jpg',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'tool-bg-remover',
|
|
|
|
|
slug: 'background-remover',
|
|
|
|
|
title: 'Background Remover (Alpha Matting)',
|
|
|
|
|
mediaType: 'video',
|
|
|
|
|
videoUrl: '/management/pages/home/media/sample_reel.mp4',
|
|
|
|
|
poster: '/management/pages/home/media/reel_video_poster.jpg',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'tool-enhancer',
|
|
|
|
|
slug: 'photo-enhancer',
|
|
|
|
|
title: 'Photo Enhancer 4K',
|
|
|
|
|
mediaType: 'comparison',
|
|
|
|
|
beforeUrl: '/management/pages/tools/photo-enhancer/media/before.jpg',
|
|
|
|
|
afterUrl: '/management/pages/tools/photo-enhancer/media/after.jpg',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'tool-restorer',
|
|
|
|
|
slug: 'old-photo-restorer',
|
|
|
|
|
title: 'Vintage Photo Restorer',
|
|
|
|
|
mediaType: 'photo',
|
|
|
|
|
imageUrl: '/management/pages/home/media/reel_restore_after.jpg',
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// ROW 2 (4 items)
|
|
|
|
|
{
|
|
|
|
|
id: 'tool-colorization',
|
|
|
|
|
slug: 'colorization',
|
|
|
|
|
title: 'AI Colorizer',
|
|
|
|
|
mediaType: 'comparison',
|
|
|
|
|
beforeUrl: '/management/pages/tools/colorization/media/before.jpg',
|
|
|
|
|
afterUrl: '/management/pages/tools/colorization/media/after.jpg',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'tool-teeth',
|
|
|
|
|
slug: 'teeth-whitener',
|
|
|
|
|
title: 'Teeth Whitener & Brightener',
|
|
|
|
|
mediaType: 'photo',
|
|
|
|
|
imageUrl: '/management/pages/tools/teeth-whitener/media/after.jpg',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'tool-cartoon',
|
|
|
|
|
slug: 'cartoon-avatar',
|
|
|
|
|
title: 'Cartoon & Anime Avatar',
|
|
|
|
|
mediaType: 'comparison',
|
|
|
|
|
beforeUrl: '/management/pages/tools/cartoon-avatar/media/before.jpg',
|
|
|
|
|
afterUrl: '/management/pages/tools/cartoon-avatar/media/after.jpg',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'tool-polaroid',
|
|
|
|
|
slug: 'polaroid-maker',
|
|
|
|
|
title: 'Vintage Polaroid Maker',
|
|
|
|
|
mediaType: 'photo',
|
|
|
|
|
imageUrl: '/management/pages/tools/polaroid-maker/media/after.jpg',
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
export function ShiftableToolsGridSection({
|
|
|
|
|
title = 'Our Tools',
|
|
|
|
|
subtitle = 'Click on any tool window to try with your own photos in seconds.',
|
|
|
|
|
items,
|
|
|
|
|
}: ShiftableToolsGridProps) {
|
|
|
|
|
const displayItems = items && items.length >= 8 ? items : DEFAULT_TOOL_ITEMS;
|
|
|
|
|
const row1 = displayItems.slice(0, 4);
|
|
|
|
|
const row2 = displayItems.slice(4, 8);
|
|
|
|
|
|
|
|
|
|
return (
|
2026-11-04 18:05:26 +05:30
|
|
|
<section id="our-tools" className="py-20 sm:py-28 px-4 sm:px-6 md:px-8 lg:px-10 bg-[#FAF8F5] relative overflow-hidden">
|
|
|
|
|
<div className="max-w-[1640px] mx-auto space-y-12">
|
2026-11-04 17:55:18 +05:30
|
|
|
{/* Header */}
|
|
|
|
|
<div className="text-center max-w-3xl mx-auto space-y-4">
|
|
|
|
|
<div className="inline-flex items-center gap-2 px-3.5 py-1 rounded-full text-xs font-mono font-semibold tracking-wider uppercase text-blue-700 bg-blue-50 border border-blue-200">
|
|
|
|
|
<Sparkles className="w-3.5 h-3.5 text-blue-600" />
|
|
|
|
|
<span>AI Creative Tools</span>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<h2 className="text-3xl sm:text-5xl font-display font-extrabold text-slate-900 tracking-tight">
|
2026-11-04 18:05:26 +05:30
|
|
|
<TextAnimate animation="slideLeft" by="character">
|
2026-11-04 17:55:18 +05:30
|
|
|
{title}
|
|
|
|
|
</TextAnimate>
|
|
|
|
|
</h2>
|
|
|
|
|
|
2026-11-04 18:05:26 +05:30
|
|
|
<p className="text-sm sm:text-base text-slate-600 font-sans text-pretty">
|
2026-11-04 17:55:18 +05:30
|
|
|
<TextAnimate animation="fadeIn" by="word" delay={0.2}>
|
|
|
|
|
{subtitle}
|
|
|
|
|
</TextAnimate>
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* 2-Row Shiftable Grid Container (Pure Horizontal Expansion, Fixed Height, No Vertical Shifts) */}
|
|
|
|
|
<div className="space-y-6 sm:space-y-8">
|
|
|
|
|
<ShiftableRow items={row1} />
|
|
|
|
|
<ShiftableRow items={row2} />
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* See More Section Button Redirecting to /tools */}
|
|
|
|
|
<div className="pt-6 text-center">
|
|
|
|
|
<Link
|
|
|
|
|
href="/tools"
|
2026-11-04 18:05:26 +05:30
|
|
|
className="group inline-flex items-center gap-2.5 px-8 py-4 rounded-full font-bold text-xs sm:text-sm text-white bg-gradient-to-r from-slate-950 via-slate-900 to-indigo-950 hover:from-blue-600 hover:to-indigo-600 border border-white/10 shadow-lg shadow-slate-900/15 transition-all duration-300 hover:scale-105 active:scale-95"
|
2026-11-04 17:55:18 +05:30
|
|
|
>
|
|
|
|
|
<span>See More Tools</span>
|
|
|
|
|
<ArrowRight className="w-4 h-4 transition-transform group-hover:translate-x-1" />
|
|
|
|
|
</Link>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ShiftableRow({ items }: { items: ToolMediaItem[] }) {
|
|
|
|
|
const [hoveredId, setHoveredId] = useState<string | null>(null);
|
|
|
|
|
|
|
|
|
|
return (
|
2026-11-04 18:05:26 +05:30
|
|
|
<div className="flex flex-col md:flex-row gap-4 sm:gap-6 w-full items-start">
|
2026-11-04 17:55:18 +05:30
|
|
|
{items.map((item) => {
|
|
|
|
|
const isHovered = hoveredId === item.id;
|
|
|
|
|
const hasOtherHovered = hoveredId !== null && !isHovered;
|
|
|
|
|
|
|
|
|
|
// Luxurious, slow, and smooth horizontal expansion (flex weighting)
|
|
|
|
|
// No vertical scaling, no height changes, purely horizontal shift
|
|
|
|
|
const flexClass = isHovered
|
|
|
|
|
? 'md:flex-[1.75]'
|
|
|
|
|
: hasOtherHovered
|
|
|
|
|
? 'md:flex-[0.75]'
|
|
|
|
|
: 'md:flex-1';
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
key={item.id}
|
|
|
|
|
onMouseEnter={() => setHoveredId(item.id)}
|
|
|
|
|
onMouseLeave={() => setHoveredId(null)}
|
|
|
|
|
className={`w-full ${flexClass} transition-[flex-grow,flex-basis] duration-700 ease-[cubic-bezier(0.25,1,0.5,1)] flex flex-col flex-shrink-0 min-w-0`}
|
|
|
|
|
>
|
|
|
|
|
{/* Window Container with strictly locked pixel height to eliminate any vertical resizing */}
|
|
|
|
|
<Link
|
|
|
|
|
href={`/tools/${item.slug}`}
|
2026-11-04 18:05:26 +05:30
|
|
|
className="group block relative w-full h-[280px] sm:h-[320px] lg:h-[340px] rounded-2xl sm:rounded-3xl overflow-hidden bg-slate-950 border border-slate-900/[0.08] shadow-cream-sm hover:shadow-cream-lg transition-shadow duration-500"
|
2026-11-04 17:55:18 +05:30
|
|
|
>
|
|
|
|
|
{/* Media Renderer */}
|
|
|
|
|
<ToolWindowMedia item={item} isHovered={isHovered} />
|
|
|
|
|
|
|
|
|
|
{/* Hover Media Type Pill */}
|
|
|
|
|
<div className="absolute top-3 left-3 z-20 pointer-events-none opacity-0 group-hover:opacity-100 transition-opacity duration-500">
|
|
|
|
|
<span className="inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[10px] font-mono font-bold tracking-wider uppercase bg-slate-950/85 backdrop-blur-md text-white border border-white/20">
|
|
|
|
|
{item.mediaType === 'video' && <Video className="w-3 h-3 text-cyan-400" />}
|
|
|
|
|
{item.mediaType === 'comparison' && <Sliders className="w-3 h-3 text-amber-400" />}
|
|
|
|
|
{item.mediaType === 'photo' && <ImageIcon className="w-3 h-3 text-emerald-400" />}
|
|
|
|
|
<span>{item.mediaType}</span>
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
</Link>
|
|
|
|
|
|
|
|
|
|
{/* Little Title Below Window (Fixed height, no vertical jumping) */}
|
|
|
|
|
<Link
|
|
|
|
|
href={`/tools/${item.slug}`}
|
|
|
|
|
className="mt-2.5 h-6 px-1 flex items-center justify-between text-xs sm:text-sm font-display font-semibold text-slate-800 hover:text-blue-600 transition-colors group"
|
|
|
|
|
>
|
|
|
|
|
<span className="truncate">{item.title}</span>
|
|
|
|
|
<ArrowRight className="w-3.5 h-3.5 text-slate-400 group-hover:text-blue-600 group-hover:translate-x-0.5 transition-all flex-shrink-0 ml-1.5" />
|
|
|
|
|
</Link>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ToolWindowMedia({ item, isHovered }: { item: ToolMediaItem; isHovered: boolean }) {
|
|
|
|
|
const videoRef = useRef<HTMLVideoElement>(null);
|
|
|
|
|
const [sliderPos, setSliderPos] = useState<number>(50);
|
|
|
|
|
const [isManualHover, setIsManualHover] = useState(false);
|
|
|
|
|
const animFrameRef = useRef<number | null>(null);
|
|
|
|
|
|
|
|
|
|
// Video Autoplay Muted Loop only on Hover (No zoom, no scale)
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (item.mediaType === 'video' && videoRef.current) {
|
|
|
|
|
if (isHovered) {
|
|
|
|
|
videoRef.current.play().catch(() => {});
|
|
|
|
|
} else {
|
|
|
|
|
videoRef.current.pause();
|
|
|
|
|
videoRef.current.currentTime = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, [isHovered, item.mediaType]);
|
|
|
|
|
|
|
|
|
|
// Before/After Smooth Automatic Oscillating Scan when hovered
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (item.mediaType !== 'comparison') return;
|
|
|
|
|
|
|
|
|
|
if (!isHovered) {
|
|
|
|
|
setSliderPos(50);
|
|
|
|
|
setIsManualHover(false);
|
|
|
|
|
if (animFrameRef.current) cancelAnimationFrame(animFrameRef.current);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If hovered and user is not manually dragging/scrubbing, smoothly oscillate slider
|
|
|
|
|
let startTime = Date.now();
|
|
|
|
|
const sweep = () => {
|
|
|
|
|
if (!isManualHover) {
|
|
|
|
|
const elapsed = (Date.now() - startTime) / 1000;
|
|
|
|
|
// Smooth sine wave between 28% and 72%
|
|
|
|
|
const pos = 50 + Math.sin(elapsed * 2.2) * 24;
|
|
|
|
|
setSliderPos(pos);
|
|
|
|
|
}
|
|
|
|
|
animFrameRef.current = requestAnimationFrame(sweep);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
animFrameRef.current = requestAnimationFrame(sweep);
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
if (animFrameRef.current) cancelAnimationFrame(animFrameRef.current);
|
|
|
|
|
};
|
|
|
|
|
}, [isHovered, isManualHover, item.mediaType]);
|
|
|
|
|
|
|
|
|
|
// Pointer position tracking when mouse moves over the comparison window
|
|
|
|
|
const handleMouseMove = (e: React.MouseEvent<HTMLDivElement>) => {
|
|
|
|
|
if (item.mediaType !== 'comparison') return;
|
|
|
|
|
setIsManualHover(true);
|
|
|
|
|
const rect = e.currentTarget.getBoundingClientRect();
|
|
|
|
|
const x = Math.max(0, Math.min(e.clientX - rect.left, rect.width));
|
|
|
|
|
const percent = Math.max(10, Math.min(90, (x / rect.width) * 100));
|
|
|
|
|
setSliderPos(percent);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleMouseLeave = () => {
|
|
|
|
|
setIsManualHover(false);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 1. VIDEO (Strictly locked to 100% width and height without any zooming or scaling)
|
|
|
|
|
if (item.mediaType === 'video' && item.videoUrl) {
|
|
|
|
|
return (
|
|
|
|
|
<div className="relative w-full h-full overflow-hidden">
|
|
|
|
|
<video
|
|
|
|
|
ref={videoRef}
|
|
|
|
|
src={item.videoUrl}
|
|
|
|
|
poster={item.poster}
|
|
|
|
|
muted
|
|
|
|
|
loop
|
|
|
|
|
playsInline
|
|
|
|
|
className="w-full h-full object-cover"
|
|
|
|
|
/>
|
|
|
|
|
<div className="absolute inset-0 bg-slate-950/10 group-hover:bg-transparent transition-colors duration-500" />
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 2. COMPARISON: Pixel-perfect clip-path slider (ZERO distortion, real slider animation)
|
|
|
|
|
if (item.mediaType === 'comparison' && item.beforeUrl && item.afterUrl) {
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
onMouseMove={handleMouseMove}
|
|
|
|
|
onMouseLeave={handleMouseLeave}
|
|
|
|
|
className="relative w-full h-full select-none cursor-ew-resize overflow-hidden"
|
|
|
|
|
>
|
|
|
|
|
{/* BEFORE Image (Base layer, 100% full cover, zero stretch) */}
|
|
|
|
|
<img
|
|
|
|
|
src={item.beforeUrl}
|
|
|
|
|
alt="Before"
|
|
|
|
|
className="absolute inset-0 w-full h-full object-cover pointer-events-none"
|
|
|
|
|
loading="lazy"
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
{/* AFTER Image (Top layer clipped via CSS clip-path inset - NO SQUISHING OR RESIZING) */}
|
|
|
|
|
<img
|
|
|
|
|
src={item.afterUrl}
|
|
|
|
|
alt="After"
|
|
|
|
|
className="absolute inset-0 w-full h-full object-cover pointer-events-none"
|
|
|
|
|
style={{
|
|
|
|
|
clipPath: `inset(0 ${100 - sliderPos}% 0 0)`,
|
|
|
|
|
}}
|
|
|
|
|
loading="lazy"
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
{/* Glowing Slider Divider Line */}
|
|
|
|
|
<div
|
|
|
|
|
className="absolute top-0 bottom-0 w-[2px] bg-white shadow-[0_0_10px_rgba(255,255,255,0.95)] pointer-events-none z-10"
|
|
|
|
|
style={{ left: `${sliderPos}%` }}
|
|
|
|
|
>
|
|
|
|
|
{/* Circular Grab Handle with Before/After Arrow Cue */}
|
|
|
|
|
<div className="absolute top-1/2 -translate-y-1/2 -translate-x-1/2 w-7 h-7 rounded-full bg-white shadow-lg border border-slate-200/90 flex items-center justify-center text-[10px] font-bold text-slate-900 pointer-events-none">
|
|
|
|
|
↔
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Clean Badges Visible on Hover */}
|
|
|
|
|
{isHovered && (
|
|
|
|
|
<div className="absolute bottom-3 inset-x-3 flex justify-between pointer-events-none z-20 text-[9px] font-mono font-bold uppercase tracking-wider text-white">
|
|
|
|
|
<span className="bg-slate-950/80 px-2 py-0.5 rounded backdrop-blur border border-white/10">
|
|
|
|
|
AFTER
|
|
|
|
|
</span>
|
|
|
|
|
<span className="bg-slate-950/80 px-2 py-0.5 rounded backdrop-blur border border-white/10">
|
|
|
|
|
BEFORE
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 3. PHOTO (Clean unscaled presentation)
|
|
|
|
|
return (
|
|
|
|
|
<div className="relative w-full h-full overflow-hidden">
|
|
|
|
|
<img
|
|
|
|
|
src={item.imageUrl || item.afterUrl || item.beforeUrl || '/brand/og-default.png'}
|
|
|
|
|
alt={item.title}
|
|
|
|
|
className="w-full h-full object-cover"
|
|
|
|
|
loading="lazy"
|
|
|
|
|
/>
|
|
|
|
|
<div className="absolute inset-0 bg-slate-950/10 group-hover:bg-transparent transition-colors duration-500" />
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|