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
+151 -287
View File
@@ -1,6 +1,6 @@
'use client';
import React, { useState, useMemo, useRef, useEffect, useCallback } from 'react';
import React, { useState, useMemo, useRef } from 'react';
import Link from 'next/link';
import {
Search,
@@ -10,8 +10,6 @@ import {
Smile,
Palette,
Sparkles,
ChevronLeft,
ChevronRight,
X,
Layers,
} from 'lucide-react';
@@ -173,7 +171,7 @@ function ToolCardImage({ tool, toolName }: { tool: ToolItem; toolName: string })
if (media.type === 'single') {
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 */}
<img
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"
/>
{/* 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}
</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 ↗
</span>
</div>
@@ -197,7 +195,7 @@ function ToolCardImage({ tool, toolName }: { tool: ToolItem; toolName: string })
<div
onMouseMove={handleMouseMove}
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) */}
{/* 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%)' }}
>
{/* 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="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-[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-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" />
</div>
</div>
</div>
{/* 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
</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
</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 ↗
</span>
</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 }) {
const toolName = resolveLocalised(tool.name, locale);
const toolSummary = resolveLocalised(tool.summary, locale);
@@ -262,23 +260,23 @@ function ToolCard({ tool, locale }: { tool: ToolItem; locale: string }) {
return (
<Link
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} />
{/* Minimalist Info Area: Only Title & Subtitle */}
<div className="mt-3.5 px-1 pb-1">
<div className="flex items-center justify-between gap-2">
<h4 className="text-base sm:text-lg font-display font-bold text-slate-900 group-hover:text-blue-600 transition-colors truncate">
<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">
{toolName}
</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" />
</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}
</p>
</div>
@@ -297,9 +295,6 @@ export function ToolGridSection({
}: ToolGridSectionProps) {
const [selectedCategory, setSelectedCategory] = useState<string>('all');
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
const categorizedTools = useMemo(() => {
@@ -337,252 +332,139 @@ export function ToolGridSection({
});
}, [tools, searchQuery, locale]);
// Center a pill smoothly in the horizontal top rail
const centerPillInRail = useCallback((catId: string) => {
const pill = buttonRefs.current[catId];
const rail = railRef.current;
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',
});
// Categories to display based on selectedCategory
const displayedCategories = useMemo(() => {
if (selectedCategory === 'all') {
return categorizedTools;
}
}, []);
// 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 categorizedTools.filter((group) => group.id === selectedCategory);
}, [categorizedTools, selectedCategory]);
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">
{/* Section Heading */}
{(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 && (
<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)}
</h2>
)}
{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)}
</p>
)}
</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) && (
<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="max-w-7xl mx-auto flex flex-col md:flex-row items-stretch md:items-center justify-between gap-3 sm:gap-4">
{/* Category Rail that slides itself smoothly */}
{showCategoryFilter && (
<div className="relative flex-1 flex items-center min-w-0">
{/* Left Scroll Arrow */}
<div className="mb-8 sm:mb-12 space-y-4">
{/* Search Bar - Center Aligned */}
{showSearch && (
<div className="max-w-md mx-auto relative px-1">
<Search className="w-4 h-4 absolute left-4 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.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
onClick={() => scrollRail('left')}
aria-label="Scroll categories left"
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"
onClick={() => setSearchQuery('')}
className="absolute right-4 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600 cursor-pointer"
>
<ChevronLeft className="w-4 h-4" />
<X className="w-3.5 h-3.5" />
</button>
)}
</div>
)}
{/* Horizontal Scrollable Categories Container */}
<div
ref={railRef}
style={{ WebkitOverflowScrolling: 'touch' }}
className="flex items-center gap-2 overflow-x-auto no-scrollbar scroll-smooth py-1 w-full touch-pan-x"
{/* Category Navigation Dock:
- On desktop: Centered floating glass pill capsule dock
- On mobile: Smooth edge-padded horizontal touch rail */}
{showCategoryFilter && (
<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 */}
<button
onClick={() => {
setSelectedCategory('all');
if (searchQuery) setSearchQuery('');
}}
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 ${
selectedCategory === 'all' && !searchQuery
? '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 sm:border-transparent'
}`}
>
{/* All Categories Pill */}
<button
ref={(el) => {
buttonRefs.current['all'] = el;
}}
onClick={() => handleCategoryClick('all')}
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 ${
<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-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/20 text-white'
: 'bg-slate-100 text-slate-600'
}`}
>
<Layers className="w-3.5 h-3.5" />
<span>All Categories</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'
{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-2 rounded-full text-xs font-bold transition-all duration-200 shadow-sm cursor-pointer ${
isSelected
? '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 sm:border-transparent'
}`}
>
{tools.length}
</span>
</button>
{/* Individual 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}
ref={(el) => {
buttonRefs.current[group.id] = el;
}}
onClick={() => handleCategoryClick(group.id)}
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 ${
<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-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/20 text-white'
: 'bg-slate-100 text-slate-600'
}`}
>
<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>
{/* 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>
{group.tools.length}
</span>
</button>
);
})}
</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 */}
{searchResults ? (
/* 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">
<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}{' '}
{searchResults.length === 1 ? 'tool' : 'tools'} matching &quot;
{searchQuery}&quot;
@@ -596,26 +478,12 @@ export function ToolGridSection({
</div>
{searchResults.length > 0 ? (
<>
{/* Mobile Scroller */}
<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) => (
<ToolCard key={tool.id} tool={tool} locale={locale} />
))}
</div>
</>
/* High-Density 2-Col Grid on Phones, Responsive 3-Col Grid on Web */
<div className="grid grid-cols-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-3 gap-3 sm:gap-7">
{searchResults.map((tool) => (
<ToolCard key={tool.id} tool={tool} locale={locale} />
))}
</div>
) : (
<div className="text-center py-16 text-slate-500 space-y-3 font-mono">
<p className="font-bold text-slate-800 text-base">
@@ -636,10 +504,25 @@ export function ToolGridSection({
</div>
) : (
/* Categorized Sections:
- On phones (< sm): Each section has a smooth horizontal scroller
- On web (>= sm): Grid that keeps filling naturally as tools are added */
<div className="space-y-12 sm:space-y-16">
{categorizedTools.map((group) => {
- 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) => {
const theme = CATEGORY_THEMES[group.id];
const catName = group.category
? resolveLocalised(group.category.name, locale)
@@ -652,23 +535,23 @@ export function ToolGridSection({
<div
key={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 */}
<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 items-center gap-3">
<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">
<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 className="flex items-center gap-2.5">
<h3 className="text-lg sm:text-2xl font-display font-black text-slate-900 tracking-tight">
<div className="flex items-center gap-2">
<h3 className="text-base sm:text-2xl font-display font-black text-slate-900 tracking-tight">
{catName}
</h3>
<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 ||
'bg-slate-100 text-slate-700 border-slate-200'
}`}
@@ -678,7 +561,7 @@ export function ToolGridSection({
</span>
</div>
{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}
</p>
)}
@@ -686,29 +569,10 @@ export function ToolGridSection({
</div>
</div>
{/* 1. Phone View (< sm): Horizontal Scroller for this particular section */}
<div className="sm:hidden relative">
<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">
{group.tools.map((tool) => (
<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">
{/* Responsive Visual Grid:
- 2-Column High-Density Visual Gallery on Phones (< sm)
- 3-Column Responsive Grid on Web/Desktop (>= sm) that continuously fills as tools are added */}
<div className="grid grid-cols-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-3 gap-3 sm:gap-7">
{group.tools.map((tool) => (
<ToolCard key={tool.id} tool={tool} locale={locale} />
))}