2026-11-03 12:24:43 +05:30
|
|
|
'use client';
|
|
|
|
|
|
2026-11-05 16:46:41 +05:30
|
|
|
import React, { useState, useMemo, useRef } from 'react';
|
2026-11-03 12:24:43 +05:30
|
|
|
import Link from 'next/link';
|
2026-11-05 16:23:52 +05:30
|
|
|
import {
|
|
|
|
|
Search,
|
|
|
|
|
ArrowRight,
|
|
|
|
|
Wand2,
|
|
|
|
|
Scissors,
|
|
|
|
|
Smile,
|
|
|
|
|
Palette,
|
|
|
|
|
Sparkles,
|
|
|
|
|
X,
|
2026-11-05 16:32:17 +05:30
|
|
|
Layers,
|
2026-11-05 16:23:52 +05:30
|
|
|
} from 'lucide-react';
|
2026-11-03 12:24:43 +05:30
|
|
|
import { ToolItem, CategoryItem, AppItem, resolveLocalised } from '@/types';
|
|
|
|
|
|
|
|
|
|
interface ToolGridSectionProps {
|
|
|
|
|
title?: any;
|
|
|
|
|
subtitle?: any;
|
|
|
|
|
tools?: ToolItem[];
|
|
|
|
|
categories?: CategoryItem[];
|
|
|
|
|
apps?: AppItem[];
|
|
|
|
|
showSearch?: boolean;
|
|
|
|
|
showCategoryFilter?: boolean;
|
|
|
|
|
limit?: number;
|
|
|
|
|
columns?: number;
|
|
|
|
|
locale?: string;
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-05 16:23:52 +05:30
|
|
|
type ToolMediaConfig =
|
|
|
|
|
| { type: 'comparison'; before: string; after: string }
|
|
|
|
|
| { type: 'single'; image: string; badge: string };
|
|
|
|
|
|
2026-11-05 16:32:17 +05:30
|
|
|
// Comprehensive media resolver for all tools
|
2026-11-05 16:23:52 +05:30
|
|
|
function getToolMedia(tool: ToolItem): ToolMediaConfig {
|
|
|
|
|
const example = tool.content?.examples?.[0];
|
|
|
|
|
|
2026-11-05 16:32:17 +05:30
|
|
|
const localDefaults: Record<string, ToolMediaConfig> = {
|
2026-11-05 16:23:52 +05:30
|
|
|
'blemish-remover': {
|
2026-11-05 16:32:17 +05:30
|
|
|
type: 'comparison',
|
2026-11-05 16:23:52 +05:30
|
|
|
before: '/management/pages/home/sections/our-tools/blemish-remover/before.jpg',
|
|
|
|
|
after: '/management/pages/home/sections/our-tools/blemish-remover/after.jpg',
|
|
|
|
|
},
|
|
|
|
|
'teeth-whitener': {
|
2026-11-05 16:32:17 +05:30
|
|
|
type: 'comparison',
|
2026-11-05 16:23:52 +05:30
|
|
|
before: '/management/pages/home/sections/our-tools/teeth-whitener/before.jpg',
|
|
|
|
|
after: '/management/pages/home/sections/our-tools/teeth-whitener/after.jpg',
|
|
|
|
|
},
|
2026-11-05 16:32:17 +05:30
|
|
|
'eye-redness-remover': {
|
|
|
|
|
type: 'comparison',
|
|
|
|
|
before: '/management/pages/home/sections/our-tools/eye-redness-remover/before.jpg',
|
|
|
|
|
after: '/management/pages/home/sections/our-tools/eye-redness-remover/after.jpg',
|
|
|
|
|
},
|
|
|
|
|
'eye-bag-remover': {
|
|
|
|
|
type: 'comparison',
|
|
|
|
|
before: '/management/pages/home/sections/our-tools/eye-bag-remover/before.jpg',
|
|
|
|
|
after: '/management/pages/home/sections/our-tools/eye-bag-remover/after.jpg',
|
|
|
|
|
},
|
|
|
|
|
'portrait-glow': {
|
|
|
|
|
type: 'comparison',
|
|
|
|
|
before: '/management/pages/home/sections/our-tools/portrait-glow/before.jpg',
|
|
|
|
|
after: '/management/pages/home/sections/our-tools/portrait-glow/after.jpg',
|
|
|
|
|
},
|
2026-11-05 16:23:52 +05:30
|
|
|
'photo-enhancer': {
|
2026-11-05 16:32:17 +05:30
|
|
|
type: 'comparison',
|
2026-11-05 16:23:52 +05:30
|
|
|
before: '/management/pages/home/sections/our-tools/photo-enhancer/before.jpg',
|
|
|
|
|
after: '/management/pages/home/sections/our-tools/photo-enhancer/after.jpg',
|
|
|
|
|
},
|
|
|
|
|
'old-photo-restorer': {
|
2026-11-05 16:32:17 +05:30
|
|
|
type: 'comparison',
|
2026-11-05 16:23:52 +05:30
|
|
|
before: '/management/pages/home/sections/our-tools/old-photo-restorer/before.jpg',
|
|
|
|
|
after: '/management/pages/home/sections/our-tools/old-photo-restorer/after.jpg',
|
|
|
|
|
},
|
|
|
|
|
'colorization': {
|
2026-11-05 16:32:17 +05:30
|
|
|
type: 'comparison',
|
2026-11-05 16:23:52 +05:30
|
|
|
before: '/management/pages/home/sections/our-tools/colorization/before.jpg',
|
|
|
|
|
after: '/management/pages/home/sections/our-tools/colorization/after.jpg',
|
|
|
|
|
},
|
|
|
|
|
'cartoon-avatar': {
|
2026-11-05 16:32:17 +05:30
|
|
|
type: 'comparison',
|
2026-11-05 16:23:52 +05:30
|
|
|
before: '/management/pages/home/sections/our-tools/cartoon-avatar/before.jpg',
|
|
|
|
|
after: '/management/pages/home/sections/our-tools/cartoon-avatar/after.jpg',
|
|
|
|
|
},
|
2026-11-05 16:32:17 +05:30
|
|
|
'object-eraser': {
|
|
|
|
|
type: 'comparison',
|
|
|
|
|
before: 'https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=800&auto=format&fit=crop&q=80',
|
|
|
|
|
after: 'https://images.unsplash.com/photo-1500648767791-00dcc994a43e?w=800&auto=format&fit=crop&q=80',
|
|
|
|
|
},
|
|
|
|
|
'background-remover': {
|
|
|
|
|
type: 'single',
|
|
|
|
|
image: '/management/pages/home/sections/our-tools/background-remover/poster.jpg',
|
|
|
|
|
badge: 'Alpha Matting',
|
|
|
|
|
},
|
|
|
|
|
'polaroid-maker': {
|
|
|
|
|
type: 'single',
|
|
|
|
|
image: '/management/pages/home/sections/our-tools/polaroid-maker/image.jpg',
|
|
|
|
|
badge: 'Vintage Polaroid',
|
|
|
|
|
},
|
2026-11-05 16:23:52 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const matched = localDefaults[tool.slug];
|
2026-11-05 16:32:17 +05:30
|
|
|
if (matched) return matched;
|
2026-11-05 16:23:52 +05:30
|
|
|
|
|
|
|
|
if (example && example.before && example.after) {
|
|
|
|
|
return {
|
|
|
|
|
type: 'comparison',
|
|
|
|
|
before: example.before,
|
|
|
|
|
after: example.after,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
type: 'single',
|
|
|
|
|
image: example?.after || '/management/pages/home/sections/our-tools/blemish-remover/after.jpg',
|
|
|
|
|
badge: 'AI Studio',
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Category design themes
|
|
|
|
|
const CATEGORY_THEMES: Record<
|
|
|
|
|
string,
|
|
|
|
|
{
|
|
|
|
|
icon: React.ReactNode;
|
|
|
|
|
color: string;
|
|
|
|
|
badgeBg: string;
|
|
|
|
|
border: string;
|
|
|
|
|
}
|
|
|
|
|
> = {
|
|
|
|
|
'portrait-retouch': {
|
|
|
|
|
icon: <Smile className="w-5 h-5 text-rose-500" />,
|
|
|
|
|
color: 'text-rose-600',
|
|
|
|
|
badgeBg: 'bg-rose-50 text-rose-700 border-rose-200',
|
|
|
|
|
border: 'border-rose-100',
|
|
|
|
|
},
|
|
|
|
|
'restoration': {
|
|
|
|
|
icon: <Sparkles className="w-5 h-5 text-indigo-500" />,
|
|
|
|
|
color: 'text-indigo-600',
|
|
|
|
|
badgeBg: 'bg-indigo-50 text-indigo-700 border-indigo-200',
|
|
|
|
|
border: 'border-indigo-100',
|
|
|
|
|
},
|
|
|
|
|
'background-cutout': {
|
|
|
|
|
icon: <Scissors className="w-5 h-5 text-emerald-500" />,
|
|
|
|
|
color: 'text-emerald-600',
|
|
|
|
|
badgeBg: 'bg-emerald-50 text-emerald-700 border-emerald-200',
|
|
|
|
|
border: 'border-emerald-100',
|
|
|
|
|
},
|
|
|
|
|
'creative-art': {
|
|
|
|
|
icon: <Palette className="w-5 h-5 text-amber-500" />,
|
|
|
|
|
color: 'text-amber-600',
|
|
|
|
|
badgeBg: 'bg-amber-50 text-amber-700 border-amber-200',
|
|
|
|
|
border: 'border-amber-100',
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Interactive Before/After Card Image Component
|
|
|
|
|
function ToolCardImage({ tool, toolName }: { tool: ToolItem; toolName: string }) {
|
|
|
|
|
const [splitPos, setSplitPos] = useState<number>(50);
|
|
|
|
|
const media = getToolMedia(tool);
|
|
|
|
|
|
|
|
|
|
const handleMouseMove = (e: React.MouseEvent<HTMLDivElement>) => {
|
|
|
|
|
const rect = e.currentTarget.getBoundingClientRect();
|
|
|
|
|
const x = e.clientX - rect.left;
|
|
|
|
|
const pct = Math.max(5, Math.min(95, (x / rect.width) * 100));
|
|
|
|
|
setSplitPos(pct);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleMouseLeave = () => {
|
|
|
|
|
setSplitPos(50);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (media.type === 'single') {
|
|
|
|
|
return (
|
2026-11-05 16:46:41 +05:30
|
|
|
<div className="relative w-full aspect-[4/5] sm:aspect-[4/3] rounded-xl sm:rounded-2xl overflow-hidden bg-slate-950 select-none group/img shadow-inner">
|
2026-11-05 16:23:52 +05:30
|
|
|
{/* eslint-disable-next-line @next/next/no-img-element */}
|
|
|
|
|
<img
|
|
|
|
|
src={media.image}
|
|
|
|
|
alt={toolName}
|
|
|
|
|
loading="lazy"
|
|
|
|
|
decoding="async"
|
|
|
|
|
className="absolute inset-0 w-full h-full object-cover transition-transform duration-500 group-hover:scale-105"
|
|
|
|
|
/>
|
|
|
|
|
{/* Floating badge */}
|
2026-11-05 16:46:41 +05:30
|
|
|
<span className="absolute bottom-2 sm:bottom-2.5 right-2 sm:right-2.5 bg-blue-600/90 backdrop-blur-md text-[8px] sm:text-[9px] font-mono font-bold uppercase tracking-wider text-white px-1.5 sm:px-2 py-0.5 rounded-md border border-white/20 pointer-events-none shadow-sm">
|
2026-11-05 16:23:52 +05:30
|
|
|
{media.badge}
|
|
|
|
|
</span>
|
2026-11-05 16:46:41 +05:30
|
|
|
<span className="hidden sm:inline-block absolute top-2.5 right-2.5 bg-white/90 backdrop-blur-md text-[9.5px] font-mono font-bold text-slate-800 px-2.5 py-0.5 rounded-full border border-slate-200 pointer-events-none shadow-sm opacity-0 group-hover:opacity-100 transition-opacity duration-200">
|
2026-11-05 16:23:52 +05:30
|
|
|
Try Tool ↗
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
onMouseMove={handleMouseMove}
|
|
|
|
|
onMouseLeave={handleMouseLeave}
|
2026-11-05 16:46:41 +05:30
|
|
|
className="relative w-full aspect-[4/5] sm:aspect-[4/3] rounded-xl sm:rounded-2xl overflow-hidden bg-slate-950 select-none sm:cursor-ew-resize group/img shadow-inner"
|
2026-11-05 16:23:52 +05:30
|
|
|
>
|
|
|
|
|
{/* Enhanced / After Image (Underneath) */}
|
|
|
|
|
{/* eslint-disable-next-line @next/next/no-img-element */}
|
|
|
|
|
<img
|
|
|
|
|
src={media.after}
|
|
|
|
|
alt={`${toolName} after`}
|
|
|
|
|
loading="lazy"
|
|
|
|
|
decoding="async"
|
|
|
|
|
className="absolute inset-0 w-full h-full object-cover transition-transform duration-500 group-hover:scale-105"
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
{/* Original / Before Image (Clipped overlay) */}
|
|
|
|
|
<div
|
|
|
|
|
className="absolute inset-0 overflow-hidden"
|
|
|
|
|
style={{
|
|
|
|
|
clipPath: `polygon(0 0, ${splitPos}% 0, ${splitPos}% 100%, 0 100%)`,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{/* eslint-disable-next-line @next/next/no-img-element */}
|
|
|
|
|
<img
|
|
|
|
|
src={media.before}
|
|
|
|
|
alt={`${toolName} before`}
|
|
|
|
|
loading="lazy"
|
|
|
|
|
decoding="async"
|
|
|
|
|
className="absolute inset-0 w-full h-full object-cover transition-transform duration-500 group-hover:scale-105"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Vertical Slider Divider */}
|
|
|
|
|
<div
|
|
|
|
|
className="absolute top-0 bottom-0 w-[2px] bg-white shadow-[0_0_8px_rgba(0,0,0,0.6)] pointer-events-none"
|
|
|
|
|
style={{ left: `${splitPos}%`, transform: 'translateX(-50%)' }}
|
|
|
|
|
>
|
|
|
|
|
{/* Sleek handle pill */}
|
2026-11-05 17:15:36 +05:30
|
|
|
<div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-5 h-5 sm:w-6 sm:h-6 rounded-full bg-white text-slate-800 shadow-md flex items-center justify-center border border-slate-300">
|
2026-11-05 16:23:52 +05:30
|
|
|
<div className="flex items-center gap-[2px]">
|
2026-11-05 16:46:41 +05:30
|
|
|
<div className="w-0 h-0 border-y-[2.5px] sm:border-y-[3px] border-y-transparent border-r-[3px] sm:border-r-[4px] border-r-slate-700" />
|
|
|
|
|
<div className="w-0 h-0 border-y-[2.5px] sm:border-y-[3px] border-y-transparent border-l-[3px] sm:border-l-[4px] border-l-slate-700" />
|
2026-11-05 16:23:52 +05:30
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-11-05 17:15:36 +05:30
|
|
|
{/* Floating badges (Hardware-accelerated, 0% CPU blur overhead) */}
|
|
|
|
|
<span className="absolute bottom-2 sm:bottom-2.5 left-2 sm:left-2.5 bg-black/80 text-[8px] sm:text-[9px] font-mono font-bold uppercase tracking-wider text-white px-1.5 sm:px-2 py-0.5 rounded-md border border-white/10 pointer-events-none shadow-sm">
|
2026-11-05 16:23:52 +05:30
|
|
|
Before
|
|
|
|
|
</span>
|
2026-11-05 17:15:36 +05:30
|
|
|
<span className="absolute bottom-2 sm:bottom-2.5 right-2 sm:right-2.5 bg-blue-600 text-[8px] sm:text-[9px] font-mono font-bold uppercase tracking-wider text-white px-1.5 sm:px-2 py-0.5 rounded-md border border-white/20 pointer-events-none shadow-sm">
|
2026-11-05 16:23:52 +05:30
|
|
|
CRE AI
|
|
|
|
|
</span>
|
2026-11-05 17:15:36 +05:30
|
|
|
<span className="hidden sm:inline-block absolute top-2.5 right-2.5 bg-white text-[9.5px] font-mono font-bold text-slate-800 px-2.5 py-0.5 rounded-full border border-slate-200 pointer-events-none shadow-sm opacity-0 group-hover:opacity-100 transition-opacity duration-150">
|
2026-11-05 16:23:52 +05:30
|
|
|
Try Tool ↗
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-05 16:46:41 +05:30
|
|
|
// Single Image-Dominant Tool Card Component
|
2026-11-05 16:23:52 +05:30
|
|
|
function ToolCard({ tool, locale }: { tool: ToolItem; locale: string }) {
|
|
|
|
|
const toolName = resolveLocalised(tool.name, locale);
|
|
|
|
|
const toolSummary = resolveLocalised(tool.summary, locale);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Link
|
|
|
|
|
href={`/tools/${tool.slug}`}
|
2026-11-05 16:46:41 +05:30
|
|
|
className="group block bg-white rounded-2xl sm:rounded-3xl p-2.5 sm:p-3.5 border border-slate-900/[0.08] hover:border-blue-400 shadow-cream-sm hover:shadow-cream-md transition-all duration-300 hover:-translate-y-1"
|
2026-11-05 16:23:52 +05:30
|
|
|
>
|
2026-11-05 16:46:41 +05:30
|
|
|
{/* Image Dominant Preview (~85% on phone, ~75% on desktop) */}
|
2026-11-05 16:23:52 +05:30
|
|
|
<ToolCardImage tool={tool} toolName={toolName} />
|
|
|
|
|
|
|
|
|
|
{/* Minimalist Info Area: Only Title & Subtitle */}
|
2026-11-05 16:46:41 +05:30
|
|
|
<div className="mt-2 sm:mt-3.5 px-0.5 pb-0.5">
|
|
|
|
|
<div className="flex items-center justify-between gap-1.5">
|
|
|
|
|
<h4 className="text-xs sm:text-base font-display font-bold text-slate-900 group-hover:text-blue-600 transition-colors truncate">
|
2026-11-05 16:23:52 +05:30
|
|
|
{toolName}
|
|
|
|
|
</h4>
|
2026-11-05 16:46:41 +05:30
|
|
|
<div className="hidden sm:flex w-6 h-6 rounded-full bg-slate-100 items-center justify-center text-slate-400 group-hover:bg-blue-600 group-hover:text-white transition-all duration-200 shrink-0 shadow-sm">
|
2026-11-05 16:23:52 +05:30
|
|
|
<ArrowRight className="w-3.5 h-3.5 group-hover:translate-x-0.5 transition-transform" />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-11-05 16:46:41 +05:30
|
|
|
<p className="mt-0.5 sm:mt-1 text-[10px] sm:text-xs text-slate-500 line-clamp-1 sm:line-clamp-2 leading-tight sm:leading-relaxed">
|
2026-11-05 16:23:52 +05:30
|
|
|
{toolSummary}
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
</Link>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-03 12:24:43 +05:30
|
|
|
export function ToolGridSection({
|
|
|
|
|
title,
|
|
|
|
|
subtitle,
|
|
|
|
|
tools = [],
|
|
|
|
|
categories = [],
|
2026-11-05 16:23:52 +05:30
|
|
|
showSearch = true,
|
|
|
|
|
showCategoryFilter = true,
|
2026-11-03 12:24:43 +05:30
|
|
|
locale = 'en',
|
|
|
|
|
}: ToolGridSectionProps) {
|
|
|
|
|
const [selectedCategory, setSelectedCategory] = useState<string>('all');
|
|
|
|
|
const [searchQuery, setSearchQuery] = useState<string>('');
|
|
|
|
|
|
2026-11-05 16:32:17 +05:30
|
|
|
// Group all tools by category
|
2026-11-05 16:23:52 +05:30
|
|
|
const categorizedTools = useMemo(() => {
|
|
|
|
|
const orderedCategoryIds = [
|
|
|
|
|
'portrait-retouch',
|
|
|
|
|
'restoration',
|
|
|
|
|
'background-cutout',
|
|
|
|
|
'creative-art',
|
|
|
|
|
];
|
2026-11-03 12:24:43 +05:30
|
|
|
|
2026-11-05 16:23:52 +05:30
|
|
|
const catMap = new Map<string, CategoryItem>();
|
|
|
|
|
categories.forEach((cat) => catMap.set(cat.id, cat));
|
|
|
|
|
|
|
|
|
|
return orderedCategoryIds
|
|
|
|
|
.map((catId) => {
|
|
|
|
|
const cat = catMap.get(catId);
|
|
|
|
|
const catTools = tools.filter((t) => t.category === catId);
|
|
|
|
|
return {
|
|
|
|
|
id: catId,
|
|
|
|
|
category: cat,
|
|
|
|
|
tools: catTools,
|
|
|
|
|
};
|
|
|
|
|
})
|
|
|
|
|
.filter((group) => group.tools.length > 0);
|
|
|
|
|
}, [categories, tools]);
|
|
|
|
|
|
|
|
|
|
// Filter tools when search query is active
|
|
|
|
|
const searchResults = useMemo(() => {
|
|
|
|
|
if (!searchQuery.trim()) return null;
|
|
|
|
|
const q = searchQuery.toLowerCase();
|
|
|
|
|
return tools.filter((t) => {
|
|
|
|
|
const name = resolveLocalised(t.name, locale).toLowerCase();
|
|
|
|
|
const summary = resolveLocalised(t.summary, locale).toLowerCase();
|
|
|
|
|
return name.includes(q) || summary.includes(q);
|
|
|
|
|
});
|
|
|
|
|
}, [tools, searchQuery, locale]);
|
|
|
|
|
|
2026-11-05 16:46:41 +05:30
|
|
|
// Categories to display based on selectedCategory
|
|
|
|
|
const displayedCategories = useMemo(() => {
|
|
|
|
|
if (selectedCategory === 'all') {
|
|
|
|
|
return categorizedTools;
|
2026-11-05 16:32:17 +05:30
|
|
|
}
|
2026-11-05 16:46:41 +05:30
|
|
|
return categorizedTools.filter((group) => group.id === selectedCategory);
|
|
|
|
|
}, [categorizedTools, selectedCategory]);
|
2026-11-05 16:38:59 +05:30
|
|
|
|
2026-11-03 12:24:43 +05:30
|
|
|
return (
|
2026-11-05 16:46:41 +05:30
|
|
|
<section id="tools-catalog" className="py-8 sm:py-16 bg-[#FAF8F5]">
|
2026-11-03 12:24:43 +05:30
|
|
|
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
|
|
|
|
{/* Section Heading */}
|
|
|
|
|
{(title || subtitle) && (
|
2026-11-05 16:46:41 +05:30
|
|
|
<div className="text-center max-w-3xl mx-auto mb-6 sm:mb-10 space-y-2 sm:space-y-3">
|
2026-11-03 12:24:43 +05:30
|
|
|
{title && (
|
2026-11-05 16:46:41 +05:30
|
|
|
<h2 className="text-2xl sm:text-4xl lg:text-5xl font-display font-black text-slate-900 tracking-tight">
|
2026-11-03 12:24:43 +05:30
|
|
|
{resolveLocalised(title, locale)}
|
|
|
|
|
</h2>
|
|
|
|
|
)}
|
|
|
|
|
{subtitle && (
|
2026-11-05 16:46:41 +05:30
|
|
|
<p className="text-xs sm:text-base lg:text-lg text-slate-600 font-normal">
|
2026-11-03 12:24:43 +05:30
|
|
|
{resolveLocalised(subtitle, locale)}
|
|
|
|
|
</p>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
2026-11-05 17:04:30 +05:30
|
|
|
{/* Persistent Sticky Search & Category Hub - Never disappears when scrolling */}
|
2026-11-05 16:23:52 +05:30
|
|
|
{(showCategoryFilter || showSearch) && (
|
2026-11-05 17:15:36 +05:30
|
|
|
<div className="sticky top-[52px] sm:top-[58px] z-30 -mx-4 sm:-mx-6 lg:-mx-8 px-4 sm:px-6 lg:px-8 py-2.5 sm:py-3 bg-[#FAF8F5]/98 border-b border-slate-200/90 shadow-2xs mb-8 sm:mb-12 will-change-transform">
|
2026-11-05 17:04:30 +05:30
|
|
|
<div className="max-w-7xl mx-auto flex flex-col md:flex-row items-center justify-between gap-2.5 sm:gap-4">
|
|
|
|
|
{/* Category Navigation Pills */}
|
|
|
|
|
{showCategoryFilter && (
|
|
|
|
|
<div className="w-full md:w-auto flex items-center justify-start md:justify-center overflow-x-auto no-scrollbar scroll-smooth py-0.5">
|
|
|
|
|
<div className="flex items-center gap-1.5 sm:gap-2">
|
|
|
|
|
{/* All Categories Pill */}
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => {
|
|
|
|
|
setSelectedCategory('all');
|
|
|
|
|
if (searchQuery) setSearchQuery('');
|
|
|
|
|
}}
|
|
|
|
|
className={`shrink-0 flex items-center gap-1.5 sm:gap-2 px-3 sm:px-3.5 py-1.5 sm:py-2 rounded-full text-xs font-bold transition-all duration-200 shadow-sm cursor-pointer ${
|
2026-11-05 16:23:52 +05:30
|
|
|
selectedCategory === 'all' && !searchQuery
|
2026-11-05 17:04:30 +05:30
|
|
|
? 'bg-blue-600 text-white shadow-blue-500/25 ring-2 ring-blue-500/30 scale-[1.02]'
|
|
|
|
|
: 'bg-white text-slate-700 hover:text-slate-900 hover:bg-slate-50 border border-slate-200/90'
|
2026-11-05 16:23:52 +05:30
|
|
|
}`}
|
|
|
|
|
>
|
2026-11-05 17:04:30 +05:30
|
|
|
<Layers className="w-3.5 h-3.5" />
|
|
|
|
|
<span>All Tools</span>
|
|
|
|
|
<span
|
|
|
|
|
className={`text-[10px] font-mono px-1.5 py-0.2 rounded-full ${
|
|
|
|
|
selectedCategory === 'all' && !searchQuery
|
|
|
|
|
? 'bg-white/20 text-white'
|
|
|
|
|
: 'bg-slate-100 text-slate-600'
|
2026-11-05 16:23:52 +05:30
|
|
|
}`}
|
|
|
|
|
>
|
2026-11-05 17:04:30 +05:30
|
|
|
{tools.length}
|
|
|
|
|
</span>
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
{/* Category Pills */}
|
|
|
|
|
{categorizedTools.map((group) => {
|
|
|
|
|
const isSelected =
|
|
|
|
|
selectedCategory === group.id && !searchQuery;
|
|
|
|
|
const catName = group.category
|
|
|
|
|
? resolveLocalised(group.category.name, locale)
|
|
|
|
|
: group.id;
|
|
|
|
|
const theme = CATEGORY_THEMES[group.id];
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<button
|
|
|
|
|
key={group.id}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
setSelectedCategory(group.id);
|
|
|
|
|
if (searchQuery) setSearchQuery('');
|
|
|
|
|
}}
|
|
|
|
|
className={`shrink-0 flex items-center gap-1.5 sm:gap-2 px-3 sm:px-3.5 py-1.5 sm:py-2 rounded-full text-xs font-bold transition-all duration-200 shadow-sm cursor-pointer ${
|
2026-11-05 16:23:52 +05:30
|
|
|
isSelected
|
2026-11-05 17:04:30 +05:30
|
|
|
? 'bg-blue-600 text-white shadow-blue-500/25 ring-2 ring-blue-500/30 scale-[1.02]'
|
|
|
|
|
: 'bg-white text-slate-700 hover:text-slate-900 hover:bg-slate-50 border border-slate-200/90'
|
2026-11-05 16:23:52 +05:30
|
|
|
}`}
|
|
|
|
|
>
|
2026-11-05 17:04:30 +05:30
|
|
|
<span className={isSelected ? 'text-white' : ''}>
|
|
|
|
|
{theme?.icon || <Wand2 className="w-4 h-4" />}
|
|
|
|
|
</span>
|
|
|
|
|
<span>{catName}</span>
|
|
|
|
|
<span
|
|
|
|
|
className={`text-[10px] font-mono px-1.5 py-0.2 rounded-full ${
|
|
|
|
|
isSelected
|
|
|
|
|
? 'bg-white/20 text-white'
|
|
|
|
|
: 'bg-slate-100 text-slate-600'
|
|
|
|
|
}`}
|
|
|
|
|
>
|
|
|
|
|
{group.tools.length}
|
|
|
|
|
</span>
|
|
|
|
|
</button>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
2026-11-05 16:23:52 +05:30
|
|
|
</div>
|
2026-11-05 17:04:30 +05:30
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{/* Search Bar */}
|
|
|
|
|
{showSearch && (
|
|
|
|
|
<div className="w-full md:w-64 lg:w-72 relative shrink-0">
|
|
|
|
|
<Search className="w-3.5 h-3.5 sm:w-4 sm:h-4 absolute left-3 top-1/2 -translate-y-1/2 text-slate-400 pointer-events-none" />
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
placeholder="Search AI photo tools..."
|
|
|
|
|
value={searchQuery}
|
|
|
|
|
onChange={(e) => setSearchQuery(e.target.value)}
|
|
|
|
|
className="w-full pl-8 sm:pl-9 pr-7 sm:pr-8 py-1.5 sm:py-2 rounded-full text-xs sm:text-sm border border-slate-200/90 bg-white text-slate-900 placeholder-slate-400 focus:outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500/20 shadow-sm"
|
|
|
|
|
/>
|
|
|
|
|
{searchQuery && (
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => setSearchQuery('')}
|
|
|
|
|
className="absolute right-2.5 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600 cursor-pointer"
|
|
|
|
|
>
|
|
|
|
|
<X className="w-3.5 h-3.5" />
|
|
|
|
|
</button>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
2026-11-03 12:24:43 +05:30
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
2026-11-05 16:38:59 +05:30
|
|
|
{/* Content: Search Results or Categorized Sections */}
|
2026-11-05 16:23:52 +05:30
|
|
|
{searchResults ? (
|
|
|
|
|
/* Search Results View */
|
2026-11-05 16:46:41 +05:30
|
|
|
<div className="space-y-5 sm:space-y-6">
|
2026-11-05 16:23:52 +05:30
|
|
|
<div className="flex items-center justify-between pb-3 border-b border-slate-200">
|
2026-11-05 16:46:41 +05:30
|
|
|
<h3 className="text-base sm:text-xl font-display font-bold text-slate-900">
|
2026-11-05 16:23:52 +05:30
|
|
|
Found {searchResults.length}{' '}
|
|
|
|
|
{searchResults.length === 1 ? 'tool' : 'tools'} matching "
|
|
|
|
|
{searchQuery}"
|
|
|
|
|
</h3>
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => setSearchQuery('')}
|
2026-11-05 16:32:17 +05:30
|
|
|
className="text-xs font-mono font-bold text-blue-600 hover:text-blue-700 underline cursor-pointer"
|
2026-11-03 12:24:43 +05:30
|
|
|
>
|
2026-11-05 16:23:52 +05:30
|
|
|
Clear Search
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
2026-11-03 12:43:34 +05:30
|
|
|
|
2026-11-05 16:23:52 +05:30
|
|
|
{searchResults.length > 0 ? (
|
2026-11-05 17:24:02 +05:30
|
|
|
<>
|
|
|
|
|
{/* Search Results Mobile Horizontal Scroller */}
|
|
|
|
|
<div className="flex sm:hidden overflow-x-auto gap-3.5 pb-3 -mx-4 px-4 no-scrollbar scroll-smooth snap-x snap-mandatory touch-pan-x">
|
|
|
|
|
{searchResults.map((tool) => (
|
|
|
|
|
<div key={tool.id} className="w-[74vw] max-w-[280px] shrink-0 snap-start">
|
|
|
|
|
<ToolCard tool={tool} locale={locale} />
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Search Results Web Responsive Grid */}
|
|
|
|
|
<div className="hidden sm:grid sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-3 gap-6 sm:gap-7">
|
|
|
|
|
{searchResults.map((tool) => (
|
|
|
|
|
<ToolCard key={tool.id} tool={tool} locale={locale} />
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
2026-11-05 16:23:52 +05:30
|
|
|
) : (
|
|
|
|
|
<div className="text-center py-16 text-slate-500 space-y-3 font-mono">
|
|
|
|
|
<p className="font-bold text-slate-800 text-base">
|
|
|
|
|
No photo tools found matching "{searchQuery}"
|
|
|
|
|
</p>
|
|
|
|
|
<p className="text-xs text-slate-500">
|
|
|
|
|
Try searching for "blemish", "restoration",
|
2026-11-05 16:32:17 +05:30
|
|
|
"cutout", or "avatar".
|
2026-11-05 16:23:52 +05:30
|
|
|
</p>
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => setSearchQuery('')}
|
2026-11-05 16:32:17 +05:30
|
|
|
className="mt-2 inline-flex items-center px-4 py-2 rounded-full bg-blue-600 text-white text-xs font-bold shadow-sm cursor-pointer"
|
2026-11-05 16:23:52 +05:30
|
|
|
>
|
|
|
|
|
View All Tools
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
) : (
|
2026-11-05 16:38:59 +05:30
|
|
|
/* Categorized Sections:
|
2026-11-05 16:46:41 +05:30
|
|
|
- Beautiful 2-Column Visual Gallery on Phones (< sm)
|
|
|
|
|
- Rich Responsive Grid that fills naturally on Web (>= sm) */
|
|
|
|
|
<div className="space-y-10 sm:space-y-16">
|
|
|
|
|
{/* Quick reset pill if filtered to single category */}
|
|
|
|
|
{selectedCategory !== 'all' && (
|
|
|
|
|
<div className="flex items-center justify-between pb-1">
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => setSelectedCategory('all')}
|
|
|
|
|
className="inline-flex items-center gap-1.5 text-xs font-mono font-bold text-blue-600 hover:text-blue-700 bg-blue-50 border border-blue-200 px-3.5 py-1.5 rounded-full transition-colors cursor-pointer shadow-sm"
|
|
|
|
|
>
|
|
|
|
|
<span>← Show All {tools.length} Tools</span>
|
|
|
|
|
</button>
|
|
|
|
|
<span className="text-xs text-slate-400 font-mono">
|
|
|
|
|
Filtered Category
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{displayedCategories.map((group) => {
|
2026-11-05 16:23:52 +05:30
|
|
|
const theme = CATEGORY_THEMES[group.id];
|
|
|
|
|
const catName = group.category
|
|
|
|
|
? resolveLocalised(group.category.name, locale)
|
|
|
|
|
: group.id;
|
|
|
|
|
const catDesc = group.category
|
|
|
|
|
? resolveLocalised(group.category.description, locale)
|
|
|
|
|
: '';
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
key={group.id}
|
|
|
|
|
id={`category-${group.id}`}
|
2026-11-05 16:46:41 +05:30
|
|
|
className="space-y-4 sm:space-y-6"
|
2026-11-05 16:23:52 +05:30
|
|
|
>
|
|
|
|
|
{/* Category Header */}
|
2026-11-05 16:46:41 +05:30
|
|
|
<div className="flex flex-col sm:flex-row sm:items-end justify-between gap-2 pb-3 sm:pb-4 border-b border-slate-200/90">
|
|
|
|
|
<div className="flex items-center gap-2.5 sm:gap-3">
|
2026-11-05 16:23:52 +05:30
|
|
|
<div
|
2026-11-05 16:46:41 +05:30
|
|
|
className={`w-9 h-9 sm:w-11 sm:h-11 rounded-xl sm:rounded-2xl flex items-center justify-center bg-white shadow-sm border border-slate-200/80 shrink-0`}
|
2026-11-05 16:23:52 +05:30
|
|
|
>
|
2026-11-05 16:46:41 +05:30
|
|
|
{theme?.icon || <Wand2 className="w-4 h-4 sm:w-5 sm:h-5 text-blue-600" />}
|
2026-11-05 16:23:52 +05:30
|
|
|
</div>
|
|
|
|
|
<div>
|
2026-11-05 16:46:41 +05:30
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
|
<h3 className="text-base sm:text-2xl font-display font-black text-slate-900 tracking-tight">
|
2026-11-05 16:23:52 +05:30
|
|
|
{catName}
|
|
|
|
|
</h3>
|
|
|
|
|
<span
|
2026-11-05 16:46:41 +05:30
|
|
|
className={`text-[10px] sm:text-xs font-mono font-bold px-2 sm:px-2.5 py-0.5 rounded-full border ${
|
2026-11-05 16:23:52 +05:30
|
|
|
theme?.badgeBg ||
|
|
|
|
|
'bg-slate-100 text-slate-700 border-slate-200'
|
|
|
|
|
}`}
|
|
|
|
|
>
|
|
|
|
|
{group.tools.length}{' '}
|
|
|
|
|
{group.tools.length === 1 ? 'tool' : 'tools'}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
{catDesc && (
|
2026-11-05 16:46:41 +05:30
|
|
|
<p className="text-[11px] sm:text-sm text-slate-500 mt-0.5 line-clamp-1 sm:line-clamp-none">
|
2026-11-05 16:23:52 +05:30
|
|
|
{catDesc}
|
|
|
|
|
</p>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
2026-11-03 12:24:43 +05:30
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-11-05 17:24:02 +05:30
|
|
|
{/* Category Tools Layout:
|
|
|
|
|
- Phones (< sm): Smooth horizontal scroller with prominent cards & snapping
|
|
|
|
|
- Web / Desktop (>= sm): Grid that keeps filling inside naturally */}
|
|
|
|
|
<div className="flex sm:hidden overflow-x-auto gap-3.5 pb-3 -mx-4 px-4 no-scrollbar scroll-smooth snap-x snap-mandatory touch-pan-x">
|
|
|
|
|
{group.tools.map((tool) => (
|
|
|
|
|
<div key={tool.id} className="w-[74vw] max-w-[280px] shrink-0 snap-start">
|
|
|
|
|
<ToolCard tool={tool} locale={locale} />
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="hidden sm:grid sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-3 gap-6 sm:gap-7">
|
2026-11-05 16:23:52 +05:30
|
|
|
{group.tools.map((tool) => (
|
|
|
|
|
<ToolCard key={tool.id} tool={tool} locale={locale} />
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
2026-11-03 12:24:43 +05:30
|
|
|
</div>
|
2026-11-05 16:23:52 +05:30
|
|
|
);
|
|
|
|
|
})}
|
2026-11-03 12:24:43 +05:30
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
);
|
|
|
|
|
}
|