feat(tools): replace sticky category bar with in-header floating dock and introduce high-density 2-column mobile gallery

This commit is contained in:
2026-11-05 16:46:41 +05:30
parent 8137c05e53
commit b23bd8e066
+103 -239
View File
@@ -1,6 +1,6 @@
'use client'; 'use client';
import React, { useState, useMemo, useRef, useEffect, useCallback } from 'react'; import React, { useState, useMemo, useRef } from 'react';
import Link from 'next/link'; import Link from 'next/link';
import { import {
Search, Search,
@@ -10,8 +10,6 @@ import {
Smile, Smile,
Palette, Palette,
Sparkles, Sparkles,
ChevronLeft,
ChevronRight,
X, X,
Layers, Layers,
} from 'lucide-react'; } from 'lucide-react';
@@ -173,7 +171,7 @@ function ToolCardImage({ tool, toolName }: { tool: ToolItem; toolName: string })
if (media.type === 'single') { if (media.type === 'single') {
return ( return (
<div className="relative w-full aspect-[4/3] rounded-2xl overflow-hidden bg-slate-950 select-none group/img shadow-inner"> <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">
{/* eslint-disable-next-line @next/next/no-img-element */} {/* eslint-disable-next-line @next/next/no-img-element */}
<img <img
src={media.image} src={media.image}
@@ -183,10 +181,10 @@ function ToolCardImage({ tool, toolName }: { tool: ToolItem; toolName: string })
className="absolute inset-0 w-full h-full object-cover transition-transform duration-500 group-hover:scale-105" className="absolute inset-0 w-full h-full object-cover transition-transform duration-500 group-hover:scale-105"
/> />
{/* Floating badge */} {/* Floating badge */}
<span className="absolute bottom-2.5 right-2.5 bg-blue-600/90 backdrop-blur-md text-[9px] font-mono font-bold uppercase tracking-wider text-white px-2 py-0.5 rounded-md border border-white/20 pointer-events-none shadow-sm"> <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">
{media.badge} {media.badge}
</span> </span>
<span className="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"> <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">
Try Tool ↗ Try Tool ↗
</span> </span>
</div> </div>
@@ -197,7 +195,7 @@ function ToolCardImage({ tool, toolName }: { tool: ToolItem; toolName: string })
<div <div
onMouseMove={handleMouseMove} onMouseMove={handleMouseMove}
onMouseLeave={handleMouseLeave} onMouseLeave={handleMouseLeave}
className="relative w-full aspect-[4/3] rounded-2xl overflow-hidden bg-slate-950 select-none cursor-ew-resize group/img shadow-inner" 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"
> >
{/* Enhanced / After Image (Underneath) */} {/* Enhanced / After Image (Underneath) */}
{/* eslint-disable-next-line @next/next/no-img-element */} {/* eslint-disable-next-line @next/next/no-img-element */}
@@ -232,29 +230,29 @@ function ToolCardImage({ tool, toolName }: { tool: ToolItem; toolName: string })
style={{ left: `${splitPos}%`, transform: 'translateX(-50%)' }} style={{ left: `${splitPos}%`, transform: 'translateX(-50%)' }}
> >
{/* Sleek handle pill */} {/* Sleek handle pill */}
<div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-6 h-6 rounded-full bg-white/95 backdrop-blur-sm text-slate-800 shadow-md flex items-center justify-center border border-slate-300"> <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/95 backdrop-blur-sm text-slate-800 shadow-md flex items-center justify-center border border-slate-300">
<div className="flex items-center gap-[2px]"> <div className="flex items-center gap-[2px]">
<div className="w-0 h-0 border-y-[3px] border-y-transparent 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-r-[3px] sm:border-r-[4px] border-r-slate-700" />
<div className="w-0 h-0 border-y-[3px] border-y-transparent border-l-[4px] border-l-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" />
</div> </div>
</div> </div>
</div> </div>
{/* Floating badges */} {/* Floating badges */}
<span className="absolute bottom-2.5 left-2.5 bg-black/60 backdrop-blur-md text-[9px] font-mono font-bold uppercase tracking-wider text-white px-2 py-0.5 rounded-md border border-white/10 pointer-events-none shadow-sm"> <span className="absolute bottom-2 sm:bottom-2.5 left-2 sm:left-2.5 bg-black/60 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/10 pointer-events-none shadow-sm">
Before Before
</span> </span>
<span className="absolute bottom-2.5 right-2.5 bg-blue-600/90 backdrop-blur-md text-[9px] font-mono font-bold uppercase tracking-wider text-white px-2 py-0.5 rounded-md border border-white/20 pointer-events-none shadow-sm"> <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">
CRE AI CRE AI
</span> </span>
<span className="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"> <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">
Try Tool ↗ Try Tool ↗
</span> </span>
</div> </div>
); );
} }
// Single Image-Dominant Tool Card Component (~75% Image, Minimal Text) // Single Image-Dominant Tool Card Component
function ToolCard({ tool, locale }: { tool: ToolItem; locale: string }) { function ToolCard({ tool, locale }: { tool: ToolItem; locale: string }) {
const toolName = resolveLocalised(tool.name, locale); const toolName = resolveLocalised(tool.name, locale);
const toolSummary = resolveLocalised(tool.summary, locale); const toolSummary = resolveLocalised(tool.summary, locale);
@@ -262,23 +260,23 @@ function ToolCard({ tool, locale }: { tool: ToolItem; locale: string }) {
return ( return (
<Link <Link
href={`/tools/${tool.slug}`} href={`/tools/${tool.slug}`}
className="group block bg-white rounded-3xl p-3 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" 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"
> >
{/* Image Dominant Preview (~75% of visual area) */} {/* Image Dominant Preview (~85% on phone, ~75% on desktop) */}
<ToolCardImage tool={tool} toolName={toolName} /> <ToolCardImage tool={tool} toolName={toolName} />
{/* Minimalist Info Area: Only Title & Subtitle */} {/* Minimalist Info Area: Only Title & Subtitle */}
<div className="mt-3.5 px-1 pb-1"> <div className="mt-2 sm:mt-3.5 px-0.5 pb-0.5">
<div className="flex items-center justify-between gap-2"> <div className="flex items-center justify-between gap-1.5">
<h4 className="text-base sm:text-lg font-display font-bold text-slate-900 group-hover:text-blue-600 transition-colors truncate"> <h4 className="text-xs sm:text-base font-display font-bold text-slate-900 group-hover:text-blue-600 transition-colors truncate">
{toolName} {toolName}
</h4> </h4>
<div className="w-6 h-6 rounded-full bg-slate-100 flex items-center justify-center text-slate-400 group-hover:bg-blue-600 group-hover:text-white transition-all duration-200 shrink-0 shadow-sm"> <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">
<ArrowRight className="w-3.5 h-3.5 group-hover:translate-x-0.5 transition-transform" /> <ArrowRight className="w-3.5 h-3.5 group-hover:translate-x-0.5 transition-transform" />
</div> </div>
</div> </div>
<p className="mt-1 text-xs sm:text-sm text-slate-500 line-clamp-2 leading-relaxed"> <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">
{toolSummary} {toolSummary}
</p> </p>
</div> </div>
@@ -297,9 +295,6 @@ export function ToolGridSection({
}: ToolGridSectionProps) { }: ToolGridSectionProps) {
const [selectedCategory, setSelectedCategory] = useState<string>('all'); const [selectedCategory, setSelectedCategory] = useState<string>('all');
const [searchQuery, setSearchQuery] = useState<string>(''); const [searchQuery, setSearchQuery] = useState<string>('');
const railRef = useRef<HTMLDivElement>(null);
const buttonRefs = useRef<Record<string, HTMLButtonElement | null>>({});
const isClickScrollingRef = useRef(false);
// Group all tools by category // Group all tools by category
const categorizedTools = useMemo(() => { const categorizedTools = useMemo(() => {
@@ -337,159 +332,78 @@ export function ToolGridSection({
}); });
}, [tools, searchQuery, locale]); }, [tools, searchQuery, locale]);
// Center a pill smoothly in the horizontal top rail // Categories to display based on selectedCategory
const centerPillInRail = useCallback((catId: string) => { const displayedCategories = useMemo(() => {
const pill = buttonRefs.current[catId]; if (selectedCategory === 'all') {
const rail = railRef.current; return categorizedTools;
if (pill && rail) {
const pillLeft = pill.offsetLeft;
const pillWidth = pill.offsetWidth;
const railWidth = rail.offsetWidth;
rail.scrollTo({
left: Math.max(0, pillLeft - railWidth / 2 + pillWidth / 2),
behavior: 'smooth',
});
} }
}, []); return categorizedTools.filter((group) => group.id === selectedCategory);
}, [categorizedTools, selectedCategory]);
// Smooth scroll rail for manual chevron arrows
const scrollRail = (direction: 'left' | 'right') => {
if (railRef.current) {
railRef.current.scrollBy({
left: direction === 'left' ? -220 : 220,
behavior: 'smooth',
});
}
};
// Fluid click handler: scrolls to category section on page and centers pill in rail
const handleCategoryClick = (catId: string) => {
setSelectedCategory(catId);
if (searchQuery) setSearchQuery('');
centerPillInRail(catId);
isClickScrollingRef.current = true;
if (catId === 'all') {
const el = document.getElementById('tools-catalog');
if (el) {
const y = el.getBoundingClientRect().top + window.pageYOffset - 90;
window.scrollTo({ top: Math.max(0, y), behavior: 'smooth' });
}
} else {
const el = document.getElementById(`category-${catId}`);
if (el) {
const headerOffset = 145; // Space for navbar + sticky category rail
const y = el.getBoundingClientRect().top + window.pageYOffset - headerOffset;
window.scrollTo({ top: Math.max(0, y), behavior: 'smooth' });
}
}
setTimeout(() => {
isClickScrollingRef.current = false;
}, 850);
};
// Synchronized Scroll-Spy: Top slider slides itself as categories slide into view
useEffect(() => {
if (searchQuery) return;
const handleScroll = () => {
if (isClickScrollingRef.current) return;
const headerOffset = 180;
const categoryIds = categorizedTools.map((g) => g.id);
// Check if at the top before the categories start
const catalogEl = document.getElementById('tools-catalog');
if (catalogEl) {
const catalogTop = catalogEl.getBoundingClientRect().top;
if (catalogTop > 100) {
if (selectedCategory !== 'all') {
setSelectedCategory('all');
centerPillInRail('all');
}
return;
}
}
// Check each category section in chronological order
let matchedCategory = 'all';
for (const catId of categoryIds) {
const el = document.getElementById(`category-${catId}`);
if (el) {
const rect = el.getBoundingClientRect();
if (rect.top <= headerOffset + 50 && rect.bottom >= 100) {
matchedCategory = catId;
}
}
}
if (matchedCategory !== selectedCategory) {
setSelectedCategory(matchedCategory);
centerPillInRail(matchedCategory);
}
};
window.addEventListener('scroll', handleScroll, { passive: true });
return () => window.removeEventListener('scroll', handleScroll);
}, [categorizedTools, searchQuery, selectedCategory, centerPillInRail]);
return ( return (
<section id="tools-catalog" className="py-10 sm:py-16 bg-[#FAF8F5]"> <section id="tools-catalog" className="py-8 sm:py-16 bg-[#FAF8F5]">
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"> <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
{/* Section Heading */} {/* Section Heading */}
{(title || subtitle) && ( {(title || subtitle) && (
<div className="text-center max-w-3xl mx-auto mb-8 sm:mb-12 space-y-3"> <div className="text-center max-w-3xl mx-auto mb-6 sm:mb-10 space-y-2 sm:space-y-3">
{title && ( {title && (
<h2 className="text-3xl sm:text-4xl lg:text-5xl font-display font-black text-slate-900 tracking-tight"> <h2 className="text-2xl sm:text-4xl lg:text-5xl font-display font-black text-slate-900 tracking-tight">
{resolveLocalised(title, locale)} {resolveLocalised(title, locale)}
</h2> </h2>
)} )}
{subtitle && ( {subtitle && (
<p className="text-base sm:text-lg text-slate-600 font-normal"> <p className="text-xs sm:text-base lg:text-lg text-slate-600 font-normal">
{resolveLocalised(subtitle, locale)} {resolveLocalised(subtitle, locale)}
</p> </p>
)} )}
</div> </div>
)} )}
{/* Sticky Solid Category Bar & Search (Immune to topbar blur, solid bg-[#FAF8F5], z-40) */} {/* Elegant Non-Sticky Category Hub & Search (Zero obstruction, no sticky bar under topbar) */}
{(showCategoryFilter || showSearch) && ( {(showCategoryFilter || showSearch) && (
<div className="sticky top-[64px] sm:top-[72px] z-40 mb-10 -mx-4 sm:-mx-6 lg:-mx-8 px-4 sm:px-6 lg:px-8 py-3 bg-[#FAF8F5] border-y border-slate-200/90 shadow-sm"> <div className="mb-8 sm:mb-12 space-y-4">
<div className="max-w-7xl mx-auto flex flex-col md:flex-row items-stretch md:items-center justify-between gap-3 sm:gap-4"> {/* Search Bar - Center Aligned */}
{/* Category Rail that slides itself smoothly */} {showSearch && (
{showCategoryFilter && ( <div className="max-w-md mx-auto relative px-1">
<div className="relative flex-1 flex items-center min-w-0"> <Search className="w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-slate-400 pointer-events-none" />
{/* Left Scroll Arrow */} <input
type="text"
placeholder="Search AI photo tools..."
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
className="w-full pl-10 pr-9 py-2.5 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 <button
onClick={() => scrollRail('left')} onClick={() => setSearchQuery('')}
aria-label="Scroll categories left" className="absolute right-4 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600 cursor-pointer"
className="hidden sm:flex items-center justify-center w-8 h-8 rounded-full bg-white border border-slate-200 text-slate-600 hover:text-slate-900 shadow-sm shrink-0 mr-1.5 transition-colors cursor-pointer"
> >
<ChevronLeft className="w-4 h-4" /> <X className="w-3.5 h-3.5" />
</button> </button>
)}
</div>
)}
{/* Horizontal Scrollable Categories Container */} {/* Category Navigation Dock:
<div - On desktop: Centered floating glass pill capsule dock
ref={railRef} - On mobile: Smooth edge-padded horizontal touch rail */}
style={{ WebkitOverflowScrolling: 'touch' }} {showCategoryFilter && (
className="flex items-center gap-2 overflow-x-auto no-scrollbar scroll-smooth py-1 w-full touch-pan-x" <div className="flex items-center justify-center">
> <div className="flex items-center gap-1.5 sm:gap-2 overflow-x-auto no-scrollbar scroll-smooth py-1 px-2 max-w-full touch-pan-x sm:p-1.5 sm:bg-white/80 sm:backdrop-blur-md sm:rounded-full sm:border sm:border-slate-200/90 sm:shadow-sm">
{/* All Categories Pill */} {/* All Categories Pill */}
<button <button
ref={(el) => { onClick={() => {
buttonRefs.current['all'] = el; setSelectedCategory('all');
if (searchQuery) setSearchQuery('');
}} }}
onClick={() => handleCategoryClick('all')} className={`shrink-0 flex items-center gap-1.5 sm:gap-2 px-3.5 sm:px-4 py-2 rounded-full text-xs font-bold transition-all duration-200 shadow-sm cursor-pointer ${
className={`shrink-0 flex items-center gap-2 px-4 py-2 rounded-full text-xs font-bold transition-all duration-200 shadow-sm cursor-pointer ${
selectedCategory === 'all' && !searchQuery selectedCategory === 'all' && !searchQuery
? 'bg-blue-600 text-white shadow-blue-500/25 ring-2 ring-blue-500/30 scale-[1.02]' ? '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' : 'bg-white text-slate-700 hover:text-slate-900 hover:bg-slate-50 border border-slate-200/90 sm:border-transparent'
}`} }`}
> >
<Layers className="w-3.5 h-3.5" /> <Layers className="w-3.5 h-3.5" />
<span>All Categories</span> <span>All Tools</span>
<span <span
className={`text-[10px] font-mono px-1.5 py-0.2 rounded-full ${ className={`text-[10px] font-mono px-1.5 py-0.2 rounded-full ${
selectedCategory === 'all' && !searchQuery selectedCategory === 'all' && !searchQuery
@@ -501,7 +415,7 @@ export function ToolGridSection({
</span> </span>
</button> </button>
{/* Individual Category Pills */} {/* Category Pills */}
{categorizedTools.map((group) => { {categorizedTools.map((group) => {
const isSelected = const isSelected =
selectedCategory === group.id && !searchQuery; selectedCategory === group.id && !searchQuery;
@@ -513,14 +427,14 @@ export function ToolGridSection({
return ( return (
<button <button
key={group.id} key={group.id}
ref={(el) => { onClick={() => {
buttonRefs.current[group.id] = el; setSelectedCategory(group.id);
if (searchQuery) setSearchQuery('');
}} }}
onClick={() => handleCategoryClick(group.id)} className={`shrink-0 flex items-center gap-1.5 sm:gap-2 px-3 sm:px-3.5 py-2 rounded-full text-xs font-bold transition-all duration-200 shadow-sm cursor-pointer ${
className={`shrink-0 flex items-center gap-2 px-3.5 py-2 rounded-full text-xs font-bold transition-all duration-200 shadow-sm cursor-pointer ${
isSelected isSelected
? 'bg-blue-600 text-white shadow-blue-500/25 ring-2 ring-blue-500/30 scale-[1.02]' ? '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' : 'bg-white text-slate-700 hover:text-slate-900 hover:bg-slate-50 border border-slate-200/90 sm:border-transparent'
}`} }`}
> >
<span className={isSelected ? 'text-white' : ''}> <span className={isSelected ? 'text-white' : ''}>
@@ -540,49 +454,17 @@ export function ToolGridSection({
); );
})} })}
</div> </div>
{/* Right Scroll Arrow */}
<button
onClick={() => scrollRail('right')}
aria-label="Scroll categories right"
className="hidden sm:flex items-center justify-center w-8 h-8 rounded-full bg-white border border-slate-200 text-slate-600 hover:text-slate-900 shadow-sm shrink-0 ml-1.5 transition-colors cursor-pointer"
>
<ChevronRight className="w-4 h-4" />
</button>
</div> </div>
)} )}
{/* Integrated Search Input */}
{showSearch && (
<div className="relative w-full md:w-72 shrink-0">
<Search className="w-4 h-4 absolute left-3.5 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-10 pr-9 py-2 rounded-full text-xs sm:text-sm border border-slate-200 bg-white text-slate-900 placeholder-slate-400 focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 shadow-sm"
/>
{searchQuery && (
<button
onClick={() => setSearchQuery('')}
className="absolute right-3 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>
</div> </div>
)} )}
{/* Content: Search Results or Categorized Sections */} {/* Content: Search Results or Categorized Sections */}
{searchResults ? ( {searchResults ? (
/* Search Results View */ /* Search Results View */
<div className="space-y-6"> <div className="space-y-5 sm:space-y-6">
<div className="flex items-center justify-between pb-3 border-b border-slate-200"> <div className="flex items-center justify-between pb-3 border-b border-slate-200">
<h3 className="text-xl font-display font-bold text-slate-900"> <h3 className="text-base sm:text-xl font-display font-bold text-slate-900">
Found {searchResults.length}{' '} Found {searchResults.length}{' '}
{searchResults.length === 1 ? 'tool' : 'tools'} matching &quot; {searchResults.length === 1 ? 'tool' : 'tools'} matching &quot;
{searchQuery}&quot; {searchQuery}&quot;
@@ -596,26 +478,12 @@ export function ToolGridSection({
</div> </div>
{searchResults.length > 0 ? ( {searchResults.length > 0 ? (
<> /* High-Density 2-Col Grid on Phones, Responsive 3-Col Grid on Web */
{/* Mobile Scroller */} <div className="grid grid-cols-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-3 gap-3 sm:gap-7">
<div className="sm:hidden -mx-4 px-4 overflow-x-auto no-scrollbar scroll-smooth snap-x snap-mandatory flex gap-4 pb-4 pt-1 touch-pan-x">
{searchResults.map((tool) => (
<div
key={tool.id}
className="w-[84vw] max-w-[320px] shrink-0 snap-start"
>
<ToolCard tool={tool} locale={locale} />
</div>
))}
</div>
{/* Web Grid View: Keeps filling naturally */}
<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) => ( {searchResults.map((tool) => (
<ToolCard key={tool.id} tool={tool} locale={locale} /> <ToolCard key={tool.id} tool={tool} locale={locale} />
))} ))}
</div> </div>
</>
) : ( ) : (
<div className="text-center py-16 text-slate-500 space-y-3 font-mono"> <div className="text-center py-16 text-slate-500 space-y-3 font-mono">
<p className="font-bold text-slate-800 text-base"> <p className="font-bold text-slate-800 text-base">
@@ -636,10 +504,25 @@ export function ToolGridSection({
</div> </div>
) : ( ) : (
/* Categorized Sections: /* Categorized Sections:
- On phones (< sm): Each section has a smooth horizontal scroller - Beautiful 2-Column Visual Gallery on Phones (< sm)
- On web (>= sm): Grid that keeps filling naturally as tools are added */ - Rich Responsive Grid that fills naturally on Web (>= sm) */
<div className="space-y-12 sm:space-y-16"> <div className="space-y-10 sm:space-y-16">
{categorizedTools.map((group) => { {/* 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) => {
const theme = CATEGORY_THEMES[group.id]; const theme = CATEGORY_THEMES[group.id];
const catName = group.category const catName = group.category
? resolveLocalised(group.category.name, locale) ? resolveLocalised(group.category.name, locale)
@@ -652,23 +535,23 @@ export function ToolGridSection({
<div <div
key={group.id} key={group.id}
id={`category-${group.id}`} id={`category-${group.id}`}
className="scroll-mt-36 space-y-5 sm:space-y-6" className="space-y-4 sm:space-y-6"
> >
{/* Category Header */} {/* Category Header */}
<div className="flex flex-col sm:flex-row sm:items-end justify-between gap-3 pb-3 sm:pb-4 border-b border-slate-200/90"> <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-3"> <div className="flex items-center gap-2.5 sm:gap-3">
<div <div
className={`w-10 h-10 sm:w-11 sm:h-11 rounded-2xl flex items-center justify-center bg-white shadow-sm border border-slate-200/80 shrink-0`} 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`}
> >
{theme?.icon || <Wand2 className="w-5 h-5 text-blue-600" />} {theme?.icon || <Wand2 className="w-4 h-4 sm:w-5 sm:h-5 text-blue-600" />}
</div> </div>
<div> <div>
<div className="flex items-center gap-2.5"> <div className="flex items-center gap-2">
<h3 className="text-lg sm:text-2xl font-display font-black text-slate-900 tracking-tight"> <h3 className="text-base sm:text-2xl font-display font-black text-slate-900 tracking-tight">
{catName} {catName}
</h3> </h3>
<span <span
className={`text-xs font-mono font-bold px-2.5 py-0.5 rounded-full border ${ className={`text-[10px] sm:text-xs font-mono font-bold px-2 sm:px-2.5 py-0.5 rounded-full border ${
theme?.badgeBg || theme?.badgeBg ||
'bg-slate-100 text-slate-700 border-slate-200' 'bg-slate-100 text-slate-700 border-slate-200'
}`} }`}
@@ -678,7 +561,7 @@ export function ToolGridSection({
</span> </span>
</div> </div>
{catDesc && ( {catDesc && (
<p className="text-xs sm:text-sm text-slate-500 mt-0.5"> <p className="text-[11px] sm:text-sm text-slate-500 mt-0.5 line-clamp-1 sm:line-clamp-none">
{catDesc} {catDesc}
</p> </p>
)} )}
@@ -686,29 +569,10 @@ export function ToolGridSection({
</div> </div>
</div> </div>
{/* 1. Phone View (< sm): Horizontal Scroller for this particular section */} {/* Responsive Visual Grid:
<div className="sm:hidden relative"> - 2-Column High-Density Visual Gallery on Phones (< sm)
<div className="-mx-4 px-4 overflow-x-auto no-scrollbar scroll-smooth snap-x snap-mandatory flex gap-4 pb-4 pt-1 touch-pan-x"> - 3-Column Responsive Grid on Web/Desktop (>= sm) that continuously fills as tools are added */}
{group.tools.map((tool) => ( <div className="grid grid-cols-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-3 gap-3 sm:gap-7">
<div
key={tool.id}
className="w-[84vw] max-w-[320px] shrink-0 snap-start"
>
<ToolCard tool={tool} locale={locale} />
</div>
))}
</div>
{/* Swipe hint */}
{group.tools.length > 1 && (
<div className="flex items-center justify-between text-[11px] font-mono text-slate-600 px-1 mt-1">
<span>Swipe to see all {group.tools.length} tools</span>
<span className="font-bold">→</span>
</div>
)}
</div>
{/* 2. Web View (>= sm): Grid that keeps filling naturally as tools are added */}
<div className="hidden sm:grid sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-3 gap-6 sm:gap-7">
{group.tools.map((tool) => ( {group.tools.map((tool) => (
<ToolCard key={tool.id} tool={tool} locale={locale} /> <ToolCard key={tool.id} tool={tool} locale={locale} />
))} ))}