diff --git a/src/components/sections/ToolGridSection.tsx b/src/components/sections/ToolGridSection.tsx
index 206e54a..dc3359d 100644
--- a/src/components/sections/ToolGridSection.tsx
+++ b/src/components/sections/ToolGridSection.tsx
@@ -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 (
-
+
{/* eslint-disable-next-line @next/next/no-img-element */}
{/* Floating badge */}
-
+
{media.badge}
-
+
Try Tool ↗
@@ -197,7 +195,7 @@ function ToolCardImage({ tool, toolName }: { tool: ToolItem; toolName: string })
{/* 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 */}
-
{/* Floating badges */}
-
+
Before
-
+
CRE AI
-
+
Try Tool ↗
);
}
-// 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 (
- {/* Image Dominant Preview (~75% of visual area) */}
+ {/* Image Dominant Preview (~85% on phone, ~75% on desktop) */}
{/* Minimalist Info Area: Only Title & Subtitle */}
-
-
-
+
+
+
{toolName}
-
-
+
{toolSummary}
@@ -297,9 +295,6 @@ export function ToolGridSection({
}: ToolGridSectionProps) {
const [selectedCategory, setSelectedCategory] = useState
('all');
const [searchQuery, setSearchQuery] = useState('');
- const railRef = useRef(null);
- const buttonRefs = useRef>({});
- 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 (
-