2026-11-03 12:24:43 +05:30
|
|
|
'use client';
|
|
|
|
|
|
|
|
|
|
import React, { useState, useMemo } from 'react';
|
|
|
|
|
import Link from 'next/link';
|
2026-11-03 13:02:29 +05:30
|
|
|
import { Search, ArrowRight, Wand2, Scissors, Smile, Palette, RefreshCcw } 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function ToolGridSection({
|
|
|
|
|
title,
|
|
|
|
|
subtitle,
|
|
|
|
|
tools = [],
|
|
|
|
|
categories = [],
|
|
|
|
|
apps = [],
|
|
|
|
|
showSearch = false,
|
|
|
|
|
showCategoryFilter = false,
|
|
|
|
|
limit,
|
|
|
|
|
locale = 'en',
|
|
|
|
|
}: ToolGridSectionProps) {
|
|
|
|
|
const [selectedCategory, setSelectedCategory] = useState<string>('all');
|
|
|
|
|
const [searchQuery, setSearchQuery] = useState<string>('');
|
|
|
|
|
|
|
|
|
|
const appMap = useMemo(() => new Map(apps.map((a) => [a.id, a])), [apps]);
|
|
|
|
|
|
|
|
|
|
const filteredTools = useMemo(() => {
|
|
|
|
|
let list = tools;
|
|
|
|
|
if (selectedCategory !== 'all') {
|
|
|
|
|
list = list.filter((t) => t.category === selectedCategory);
|
|
|
|
|
}
|
|
|
|
|
if (searchQuery.trim()) {
|
|
|
|
|
const q = searchQuery.toLowerCase();
|
|
|
|
|
list = list.filter((t) => {
|
|
|
|
|
const name = resolveLocalised(t.name, locale).toLowerCase();
|
|
|
|
|
const summary = resolveLocalised(t.summary, locale).toLowerCase();
|
|
|
|
|
return name.includes(q) || summary.includes(q);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (limit && limit > 0) {
|
|
|
|
|
list = list.slice(0, limit);
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
}, [tools, selectedCategory, searchQuery, limit, locale]);
|
|
|
|
|
|
2026-11-03 12:31:06 +05:30
|
|
|
const getCategoryIcon = (catId: string) => {
|
|
|
|
|
switch (catId) {
|
|
|
|
|
case 'portrait-retouch':
|
2026-11-03 13:02:29 +05:30
|
|
|
return <Smile className="w-4 h-4 text-cyan-400" />;
|
2026-11-03 12:31:06 +05:30
|
|
|
case 'restoration':
|
2026-11-03 13:02:29 +05:30
|
|
|
return <RefreshCcw className="w-4 h-4 text-purple-400" />;
|
2026-11-03 12:31:06 +05:30
|
|
|
case 'background-cutout':
|
2026-11-03 13:02:29 +05:30
|
|
|
return <Scissors className="w-4 h-4 text-emerald-400" />;
|
2026-11-03 12:31:06 +05:30
|
|
|
case 'creative-art':
|
2026-11-03 13:02:29 +05:30
|
|
|
return <Palette className="w-4 h-4 text-pink-400" />;
|
2026-11-03 12:31:06 +05:30
|
|
|
default:
|
2026-11-03 13:02:29 +05:30
|
|
|
return <Wand2 className="w-4 h-4 text-cyan-400" />;
|
2026-11-03 12:31:06 +05:30
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2026-11-03 12:24:43 +05:30
|
|
|
return (
|
2026-11-03 13:02:29 +05:30
|
|
|
<section className="py-16 sm:py-20 lg:py-24 bg-[#05070B] border-t border-white/[0.08]">
|
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-03 13:02:29 +05:30
|
|
|
<div className="text-center max-w-3xl mx-auto mb-12 space-y-3">
|
2026-11-03 12:24:43 +05:30
|
|
|
{title && (
|
2026-11-03 13:02:29 +05:30
|
|
|
<h2 className="text-3xl sm:text-4xl lg:text-5xl font-display font-black text-white tracking-tight">
|
2026-11-03 12:24:43 +05:30
|
|
|
{resolveLocalised(title, locale)}
|
|
|
|
|
</h2>
|
|
|
|
|
)}
|
|
|
|
|
{subtitle && (
|
2026-11-03 13:02:29 +05:30
|
|
|
<p className="text-sm sm:text-base text-slate-400">
|
2026-11-03 12:24:43 +05:30
|
|
|
{resolveLocalised(subtitle, locale)}
|
|
|
|
|
</p>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{/* Search & Filters */}
|
|
|
|
|
{(showSearch || showCategoryFilter) && (
|
2026-11-03 12:31:06 +05:30
|
|
|
<div className="mb-10 flex flex-col md:flex-row items-stretch md:items-center justify-between gap-4">
|
2026-11-03 12:24:43 +05:30
|
|
|
{showCategoryFilter && categories.length > 0 && (
|
|
|
|
|
<div className="flex flex-wrap items-center gap-2">
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => setSelectedCategory('all')}
|
2026-11-03 12:31:06 +05:30
|
|
|
className={`px-4 py-2 rounded-xl text-xs font-bold transition-all duration-200 ${
|
2026-11-03 12:24:43 +05:30
|
|
|
selectedCategory === 'all'
|
2026-11-03 13:02:29 +05:30
|
|
|
? 'bg-cyan-500 text-black shadow-lg shadow-cyan-500/25 scale-105'
|
|
|
|
|
: 'bg-white/[0.04] text-slate-300 border border-white/[0.08] hover:bg-white/[0.08]'
|
2026-11-03 12:24:43 +05:30
|
|
|
}`}
|
|
|
|
|
>
|
|
|
|
|
All Tools
|
|
|
|
|
</button>
|
|
|
|
|
{categories.map((cat) => (
|
|
|
|
|
<button
|
|
|
|
|
key={cat.id}
|
|
|
|
|
onClick={() => setSelectedCategory(cat.id)}
|
2026-11-03 13:02:29 +05:30
|
|
|
className={`flex items-center gap-1.5 px-3.5 py-2 rounded-xl text-xs font-bold transition-all duration-200 ${
|
2026-11-03 12:24:43 +05:30
|
|
|
selectedCategory === cat.id
|
2026-11-03 13:02:29 +05:30
|
|
|
? 'bg-cyan-500 text-black shadow-lg shadow-cyan-500/25 scale-105'
|
|
|
|
|
: 'bg-white/[0.04] text-slate-300 border border-white/[0.08] hover:bg-white/[0.08]'
|
2026-11-03 12:24:43 +05:30
|
|
|
}`}
|
|
|
|
|
>
|
2026-11-03 12:31:06 +05:30
|
|
|
<span>{getCategoryIcon(cat.id)}</span>
|
|
|
|
|
<span>{resolveLocalised(cat.name, locale)}</span>
|
2026-11-03 12:24:43 +05:30
|
|
|
</button>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{showSearch && (
|
2026-11-03 12:31:06 +05:30
|
|
|
<div className="relative w-full md:w-80">
|
|
|
|
|
<Search className="w-4 h-4 absolute left-3.5 top-1/2 -translate-y-1/2 text-slate-400" />
|
2026-11-03 12:24:43 +05:30
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
placeholder="Search AI photo tools..."
|
|
|
|
|
value={searchQuery}
|
|
|
|
|
onChange={(e) => setSearchQuery(e.target.value)}
|
2026-11-03 13:02:29 +05:30
|
|
|
className="w-full pl-10 pr-4 py-2.5 rounded-2xl text-xs sm:text-sm border border-white/[0.1] bg-[#0B0F17] text-white placeholder-slate-400 focus:outline-none focus:border-cyan-400 focus:ring-1 focus:ring-cyan-400 shadow-sm"
|
2026-11-03 12:24:43 +05:30
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
2026-11-03 12:43:34 +05:30
|
|
|
{/* Tools Cards Grid with Visual Image Previews */}
|
|
|
|
|
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6 sm:gap-7">
|
2026-11-03 12:24:43 +05:30
|
|
|
{filteredTools.map((tool) => {
|
|
|
|
|
const homeApp = appMap.get(tool.homeApp);
|
2026-11-03 12:43:34 +05:30
|
|
|
const example = tool.content?.examples?.[0];
|
|
|
|
|
|
2026-11-03 12:24:43 +05:30
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
key={tool.id}
|
2026-11-03 13:02:29 +05:30
|
|
|
className="group relative glass-card rounded-3xl p-5 sm:p-6 border border-white/[0.08] hover:border-cyan-500/30 transition-all duration-300 flex flex-col justify-between"
|
2026-11-03 12:24:43 +05:30
|
|
|
>
|
|
|
|
|
<div>
|
2026-11-03 12:43:34 +05:30
|
|
|
{/* Visual Before/After Preview Card */}
|
|
|
|
|
{example ? (
|
2026-11-03 13:02:29 +05:30
|
|
|
<div className="relative aspect-[16/10] rounded-2xl overflow-hidden mb-4 bg-[#05070B] border border-white/[0.08] shadow-inner group/thumb">
|
2026-11-03 12:43:34 +05:30
|
|
|
<div className="grid grid-cols-2 h-full w-full">
|
|
|
|
|
<div className="relative h-full overflow-hidden border-r border-white/20">
|
|
|
|
|
{/* eslint-disable-next-line @next/next/no-img-element */}
|
|
|
|
|
<img
|
|
|
|
|
src={example.before}
|
|
|
|
|
alt="Before preview"
|
|
|
|
|
loading="lazy"
|
|
|
|
|
className="h-full w-full object-cover"
|
|
|
|
|
/>
|
2026-11-03 13:02:29 +05:30
|
|
|
<span className="absolute bottom-1.5 left-1.5 bg-black/80 backdrop-blur-md px-1.5 py-0.5 rounded text-[8.5px] font-mono font-bold text-slate-300 border border-white/10">
|
2026-11-03 12:43:34 +05:30
|
|
|
Before
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="relative h-full overflow-hidden">
|
|
|
|
|
{/* eslint-disable-next-line @next/next/no-img-element */}
|
|
|
|
|
<img
|
|
|
|
|
src={example.after}
|
|
|
|
|
alt="After preview"
|
|
|
|
|
loading="lazy"
|
2026-11-03 13:02:29 +05:30
|
|
|
className="h-full w-full object-cover group-hover:scale-105 transition-transform duration-500"
|
2026-11-03 12:43:34 +05:30
|
|
|
/>
|
2026-11-03 13:02:29 +05:30
|
|
|
<span className="absolute bottom-1.5 right-1.5 bg-gradient-to-r from-cyan-500 to-purple-600 backdrop-blur-md px-1.5 py-0.5 rounded text-[8.5px] font-mono font-bold text-white shadow-sm border border-white/20">
|
|
|
|
|
CRE AI
|
2026-11-03 12:43:34 +05:30
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
) : null}
|
|
|
|
|
|
2026-11-03 12:24:43 +05:30
|
|
|
{/* Category Tag & Icon */}
|
2026-11-03 12:43:34 +05:30
|
|
|
<div className="flex items-center justify-between mb-3">
|
2026-11-03 13:02:29 +05:30
|
|
|
<span className="text-[10.5px] font-mono font-bold uppercase tracking-wider text-cyan-400 bg-cyan-950/60 px-2.5 py-0.5 rounded-lg border border-cyan-500/30">
|
2026-11-03 12:24:43 +05:30
|
|
|
{tool.category}
|
|
|
|
|
</span>
|
2026-11-03 13:02:29 +05:30
|
|
|
<div className="w-8 h-8 rounded-xl bg-white/[0.04] border border-white/[0.08] flex items-center justify-center text-slate-300 group-hover:scale-110 group-hover:border-cyan-500/30 transition-all duration-200">
|
2026-11-03 12:31:06 +05:30
|
|
|
{getCategoryIcon(tool.category)}
|
2026-11-03 12:24:43 +05:30
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-11-03 13:02:29 +05:30
|
|
|
<h3 className="text-lg font-display font-bold text-white group-hover:text-cyan-300 transition-colors">
|
2026-11-03 12:24:43 +05:30
|
|
|
{resolveLocalised(tool.name, locale)}
|
|
|
|
|
</h3>
|
|
|
|
|
|
2026-11-03 13:02:29 +05:30
|
|
|
<p className="mt-2 text-xs text-slate-400 line-clamp-2 leading-relaxed">
|
2026-11-03 12:24:43 +05:30
|
|
|
{resolveLocalised(tool.summary, locale)}
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-11-03 13:02:29 +05:30
|
|
|
<div className="mt-5 pt-4 border-t border-white/[0.08] space-y-3">
|
2026-11-03 12:24:43 +05:30
|
|
|
{homeApp && (
|
2026-11-03 13:02:29 +05:30
|
|
|
<div className="text-[11px] font-mono text-slate-400 flex items-center justify-between">
|
|
|
|
|
<span>Home App:</span>
|
|
|
|
|
<span className="font-bold text-slate-300 truncate max-w-[140px]">
|
2026-11-03 12:24:43 +05:30
|
|
|
{resolveLocalised(homeApp.name, locale)}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
<Link
|
|
|
|
|
href={`/tools/${tool.slug}`}
|
2026-11-03 13:02:29 +05:30
|
|
|
className="w-full inline-flex items-center justify-center gap-2 py-3 rounded-2xl text-xs font-bold text-black bg-gradient-to-r from-cyan-400 to-teal-300 hover:from-cyan-300 hover:to-teal-200 shadow-md transition-all duration-200"
|
2026-11-03 12:24:43 +05:30
|
|
|
>
|
|
|
|
|
<span>Try Free Online</span>
|
2026-11-03 12:31:06 +05:30
|
|
|
<ArrowRight className="w-3.5 h-3.5 group-hover:translate-x-1 transition-transform" />
|
2026-11-03 12:24:43 +05:30
|
|
|
</Link>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{filteredTools.length === 0 && (
|
2026-11-03 13:02:29 +05:30
|
|
|
<div className="text-center py-16 text-slate-400 space-y-2 font-mono">
|
2026-11-03 12:31:06 +05:30
|
|
|
<p className="font-bold">No photo tools found matching "{searchQuery}"</p>
|
|
|
|
|
<p className="text-xs">Try searching for "blemish", "background", "photo", or clear filters.</p>
|
2026-11-03 12:24:43 +05:30
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
);
|
|
|
|
|
}
|