feat(homepage+tools): tools page card refinement and homepage fixes
This commit is contained in:
@@ -4,6 +4,8 @@ import React, { useState, useRef, useEffect, useCallback } from 'react';
|
||||
import Link from 'next/link';
|
||||
import { ArrowRight } from 'lucide-react';
|
||||
import { ToolItem } from '@/types';
|
||||
import { KineticText } from '@/components/magicui/kinetic-text';
|
||||
import { AnimatedShinyText } from '@/components/magicui/animated-shiny-text';
|
||||
|
||||
export interface ToolMediaItem {
|
||||
id: string;
|
||||
@@ -30,7 +32,7 @@ export const DEFAULT_TOOL_ITEMS: ToolMediaItem[] = [
|
||||
{
|
||||
id: 'tool-blemish',
|
||||
slug: 'blemish-remover',
|
||||
title: 'Skin & blemish retoucher',
|
||||
title: 'AI Blemish Remover',
|
||||
mediaType: 'comparison',
|
||||
beforeUrl: '/management/pages/home/sections/our-tools/blemish-remover/before.jpg',
|
||||
afterUrl: '/management/pages/home/sections/our-tools/blemish-remover/after.jpg',
|
||||
@@ -38,7 +40,7 @@ export const DEFAULT_TOOL_ITEMS: ToolMediaItem[] = [
|
||||
{
|
||||
id: 'tool-bg-remover',
|
||||
slug: 'background-remover',
|
||||
title: 'Background remover (alpha matting)',
|
||||
title: 'AI Background Remover',
|
||||
mediaType: 'video',
|
||||
videoUrl: '/management/pages/home/sections/our-tools/background-remover/sample_reel.mp4',
|
||||
poster: '/management/pages/home/sections/our-tools/background-remover/poster.jpg',
|
||||
@@ -46,7 +48,7 @@ export const DEFAULT_TOOL_ITEMS: ToolMediaItem[] = [
|
||||
{
|
||||
id: 'tool-enhancer',
|
||||
slug: 'photo-enhancer',
|
||||
title: 'Photo enhancer 4K',
|
||||
title: 'Ultra HD AI Photo Enhancer',
|
||||
mediaType: 'comparison',
|
||||
beforeUrl: '/management/pages/home/sections/our-tools/photo-enhancer/before.jpg',
|
||||
afterUrl: '/management/pages/home/sections/our-tools/photo-enhancer/after.jpg',
|
||||
@@ -54,7 +56,7 @@ export const DEFAULT_TOOL_ITEMS: ToolMediaItem[] = [
|
||||
{
|
||||
id: 'tool-restorer',
|
||||
slug: 'old-photo-restorer',
|
||||
title: 'Vintage photo restorer',
|
||||
title: 'Vintage Photo Restorer',
|
||||
mediaType: 'comparison',
|
||||
beforeUrl: '/management/pages/home/sections/our-tools/old-photo-restorer/before.jpg',
|
||||
afterUrl: '/management/pages/home/sections/our-tools/old-photo-restorer/after.jpg',
|
||||
@@ -64,7 +66,7 @@ export const DEFAULT_TOOL_ITEMS: ToolMediaItem[] = [
|
||||
{
|
||||
id: 'tool-colorization',
|
||||
slug: 'colorization',
|
||||
title: 'Photo colorizer',
|
||||
title: 'Black & White Photo Colorizer',
|
||||
mediaType: 'comparison',
|
||||
beforeUrl: '/management/pages/home/sections/our-tools/colorization/before.jpg',
|
||||
afterUrl: '/management/pages/home/sections/our-tools/colorization/after.jpg',
|
||||
@@ -72,7 +74,7 @@ export const DEFAULT_TOOL_ITEMS: ToolMediaItem[] = [
|
||||
{
|
||||
id: 'tool-teeth',
|
||||
slug: 'teeth-whitener',
|
||||
title: 'Teeth whitener & brightener',
|
||||
title: 'AI Teeth Whitener & Smile Glow',
|
||||
mediaType: 'comparison',
|
||||
beforeUrl: '/management/pages/home/sections/our-tools/teeth-whitener/before.jpg',
|
||||
afterUrl: '/management/pages/home/sections/our-tools/teeth-whitener/after.jpg',
|
||||
@@ -80,7 +82,7 @@ export const DEFAULT_TOOL_ITEMS: ToolMediaItem[] = [
|
||||
{
|
||||
id: 'tool-cartoon',
|
||||
slug: 'cartoon-avatar',
|
||||
title: 'Cartoon & anime avatar',
|
||||
title: 'CartoonGAN & Anime Avatar',
|
||||
mediaType: 'comparison',
|
||||
beforeUrl: '/management/pages/home/sections/our-tools/cartoon-avatar/before.jpg',
|
||||
afterUrl: '/management/pages/home/sections/our-tools/cartoon-avatar/after.jpg',
|
||||
@@ -88,7 +90,7 @@ export const DEFAULT_TOOL_ITEMS: ToolMediaItem[] = [
|
||||
{
|
||||
id: 'tool-polaroid',
|
||||
slug: 'polaroid-maker',
|
||||
title: 'Vintage polaroid maker',
|
||||
title: 'Vintage Polaroid & Film Filter',
|
||||
mediaType: 'photo',
|
||||
imageUrl: '/management/pages/home/sections/our-tools/polaroid-maker/image.jpg',
|
||||
},
|
||||
@@ -103,33 +105,27 @@ export function ShiftableToolsGridSection({
|
||||
const row1 = displayItems.slice(0, 4);
|
||||
const row2 = displayItems.slice(4, 8);
|
||||
|
||||
const [isMiddleReached, setIsMiddleReached] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const checkPosition = () => {
|
||||
const section = document.getElementById('our-tools');
|
||||
if (!section) return;
|
||||
const rect = section.getBoundingClientRect();
|
||||
const inMiddle = rect.top <= window.innerHeight * 0.5 && rect.bottom >= window.innerHeight * 0.15;
|
||||
setIsMiddleReached(inMiddle);
|
||||
};
|
||||
|
||||
checkPosition();
|
||||
window.addEventListener('scroll', checkPosition, { passive: true });
|
||||
window.addEventListener('resize', checkPosition, { passive: true });
|
||||
return () => {
|
||||
window.removeEventListener('scroll', checkPosition);
|
||||
window.removeEventListener('resize', checkPosition);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<section id="our-tools" className="py-16 sm:py-24 px-4 sm:px-6 md:px-8 lg:px-10 bg-paper border-b border-rule relative overflow-hidden">
|
||||
<div className="max-w-container mx-auto space-y-10">
|
||||
{/* Section Header - Clean editorial layout without eyebrows */}
|
||||
{/* Studio Lighting Ambient Glow */}
|
||||
<div
|
||||
className="pointer-events-none absolute top-10 left-10 w-[550px] h-[350px] [background:radial-gradient(circle_at_center,color-mix(in_oklab,var(--color-accent)_10%,transparent)_0%,transparent_70%)]"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<div
|
||||
className="pointer-events-none absolute bottom-10 right-10 w-[550px] h-[350px] [background:radial-gradient(circle_at_center,color-mix(in_oklab,var(--color-ink)_6%,transparent)_0%,transparent_70%)]"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<div
|
||||
className="pointer-events-none absolute inset-0 opacity-20 studio-proof-grid"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
|
||||
<div className="max-w-container mx-auto space-y-10 relative z-10">
|
||||
{/* Section Header - Clean editorial layout with kinetic typography */}
|
||||
<div className="max-w-2xl space-y-2 border-b border-rule pb-5">
|
||||
<h2 className="text-3xl sm:text-4xl font-display font-bold text-ink tracking-tight">
|
||||
{title}
|
||||
<KineticText>{title}</KineticText>
|
||||
</h2>
|
||||
<p className="text-sm sm:text-base text-ink-2 font-body text-pretty">
|
||||
{subtitle}
|
||||
@@ -138,8 +134,8 @@ export function ShiftableToolsGridSection({
|
||||
|
||||
{/* Desktop View (md and up): 2-Row Shiftable Expansion Grid */}
|
||||
<div className="hidden md:block space-y-8">
|
||||
<ShiftableRow items={row1} isEnabled={isMiddleReached} />
|
||||
<ShiftableRow items={row2} isEnabled={isMiddleReached} />
|
||||
<ShiftableRow items={row1} />
|
||||
<ShiftableRow items={row2} />
|
||||
</div>
|
||||
|
||||
{/* Mobile / Phone View (<md): Pure Vertical Stack */}
|
||||
@@ -165,83 +161,76 @@ export function ShiftableToolsGridSection({
|
||||
|
||||
function MobileVerticalToolsList({ items }: { items: ToolMediaItem[] }) {
|
||||
return (
|
||||
<div className="flex flex-col gap-6 w-full">
|
||||
<div className="flex flex-col gap-8 w-full">
|
||||
{items.map((item) => (
|
||||
<div key={item.id} className="w-full flex flex-col">
|
||||
<div className="studio-sheet p-3 crop-marked">
|
||||
<div className="relative w-full h-[220px] rounded-card overflow-hidden bg-paper-2">
|
||||
<ToolWindowMedia item={item} isHovered={false} />
|
||||
<Link
|
||||
href={`/tools/${item.slug}`}
|
||||
className="absolute top-2.5 right-2.5 z-30 inline-flex items-center gap-1 px-2.5 py-1 rounded-card text-xs font-body bg-paper-hi/90 text-ink border border-rule hover:border-ink transition-colors shadow-sm"
|
||||
aria-label={`Open ${item.title}`}
|
||||
>
|
||||
<span>Try tool</span>
|
||||
<ArrowRight className="w-3 h-3" aria-hidden="true" />
|
||||
</Link>
|
||||
</div>
|
||||
<div className="relative w-full h-[230px] rounded-2xl overflow-hidden bg-paper-2 border border-rule/80 hover:border-accent transition-[border-color,box-shadow]">
|
||||
<ToolWindowMedia item={item} isHovered={false} />
|
||||
<Link
|
||||
href={`/tools/${item.slug}`}
|
||||
className="mt-2.5 flex items-center justify-between text-sm font-body font-semibold text-ink hover:text-accent transition-colors"
|
||||
className="absolute top-3 right-3 z-30 inline-flex items-center gap-1.5 px-3.5 py-1.5 rounded-full text-xs font-body font-bold bg-paper-hi text-ink border border-rule hover:border-accent hover:text-accent transition-colors duration-150 shadow-sm active:scale-95"
|
||||
aria-label={`Open ${item.title}`}
|
||||
>
|
||||
<span>{item.title}</span>
|
||||
<ArrowRight className="w-3.5 h-3.5 text-muted" aria-hidden="true" />
|
||||
<span>Try tool</span>
|
||||
<ArrowRight className="w-3 h-3 text-accent" aria-hidden="true" />
|
||||
</Link>
|
||||
</div>
|
||||
<Link
|
||||
href={`/tools/${item.slug}`}
|
||||
className="mt-2.5 flex items-center justify-between text-base font-body font-semibold text-ink hover:text-accent transition-colors px-1"
|
||||
>
|
||||
<span>{item.title}</span>
|
||||
<ArrowRight className="w-4 h-4 text-accent" aria-hidden="true" />
|
||||
</Link>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ShiftableRow({ items, isEnabled = true }: { items: ToolMediaItem[]; isEnabled?: boolean }) {
|
||||
function ShiftableRow({ items }: { items: ToolMediaItem[] }) {
|
||||
const [hoveredId, setHoveredId] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isEnabled) {
|
||||
setHoveredId(null);
|
||||
}
|
||||
}, [isEnabled]);
|
||||
|
||||
return (
|
||||
<div className="flex flex-row gap-5 w-full items-start overflow-visible">
|
||||
{items.map((item) => {
|
||||
const isHovered = isEnabled && hoveredId === item.id;
|
||||
const hasOtherHovered = isEnabled && hoveredId !== null && !isHovered;
|
||||
const flexGrowValue = isHovered ? 1.25 : hasOtherHovered ? 0.916 : 1;
|
||||
const isHovered = hoveredId === item.id;
|
||||
const hasOtherHovered = hoveredId !== null && !isHovered;
|
||||
// Subtle and gentle sideways expansion (~25-30% wider on hover, no drastic jumping or zoom)
|
||||
const flexGrowValue = isHovered ? 1.25 : hasOtherHovered ? 0.915 : 1;
|
||||
|
||||
return (
|
||||
<div
|
||||
key={item.id}
|
||||
onMouseEnter={() => {
|
||||
if (isEnabled) setHoveredId(item.id);
|
||||
}}
|
||||
onMouseEnter={() => setHoveredId(item.id)}
|
||||
onMouseLeave={() => setHoveredId(null)}
|
||||
className="flex-1 transition-[flex-grow] duration-300 ease-out flex flex-col min-w-0"
|
||||
className="flex-1 transition-[flex-grow] duration-500 ease-[cubic-bezier(0.16,1,0.3,1)] flex flex-col min-w-0"
|
||||
style={{ flexGrow: flexGrowValue }}
|
||||
>
|
||||
<div className="studio-sheet p-3 crop-marked">
|
||||
<div className="relative w-full h-[200px] lg:h-[220px] rounded-card overflow-hidden bg-paper-2">
|
||||
<ToolWindowMedia item={item} isHovered={isHovered} />
|
||||
|
||||
<Link
|
||||
href={`/tools/${item.slug}`}
|
||||
className="absolute top-2.5 right-2.5 z-30 inline-flex items-center gap-1 px-2.5 py-1 rounded-card text-xs font-body bg-paper-hi/90 text-ink border border-rule hover:border-ink transition-colors shadow-sm"
|
||||
aria-label={`Open ${item.title}`}
|
||||
>
|
||||
<span>Try tool</span>
|
||||
<ArrowRight className="w-3 h-3" aria-hidden="true" />
|
||||
</Link>
|
||||
</div>
|
||||
<div className={`relative w-full h-[220px] lg:h-[240px] rounded-2xl overflow-hidden bg-paper-2 border transition-[border-color,box-shadow] duration-500 ease-[cubic-bezier(0.16,1,0.3,1)] ${
|
||||
isHovered ? 'border-accent shadow-glow' : 'border-rule/80 hover:border-accent/60'
|
||||
}`}>
|
||||
<ToolWindowMedia item={item} isHovered={isHovered} />
|
||||
|
||||
<Link
|
||||
href={`/tools/${item.slug}`}
|
||||
className="mt-2.5 flex items-center justify-between text-sm font-body font-medium text-ink hover:text-accent transition-colors"
|
||||
className="absolute top-3 right-3 z-30 inline-flex items-center gap-1.5 px-3.5 py-1.5 rounded-full text-xs font-body font-bold bg-paper-hi text-ink border border-rule hover:border-accent hover:text-accent transition-colors duration-150 shadow-sm active:scale-95"
|
||||
aria-label={`Open ${item.title}`}
|
||||
>
|
||||
<span className="truncate">{item.title}</span>
|
||||
<ArrowRight className="w-3.5 h-3.5 text-muted ml-1 shrink-0" aria-hidden="true" />
|
||||
<span>Try tool</span>
|
||||
<ArrowRight className="w-3 h-3 text-accent" aria-hidden="true" />
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<Link
|
||||
href={`/tools/${item.slug}`}
|
||||
className="mt-2.5 flex items-center justify-between text-sm font-body font-semibold text-ink hover:text-accent transition-colors px-1"
|
||||
>
|
||||
<span className="font-semibold text-ink line-clamp-1">
|
||||
<AnimatedShinyText>{item.title}</AnimatedShinyText>
|
||||
</span>
|
||||
<ArrowRight className="w-3.5 h-3.5 text-accent ml-1 shrink-0" aria-hidden="true" />
|
||||
</Link>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
@@ -440,12 +429,11 @@ function ToolWindowMedia({ item, isHovered }: { item: ToolMediaItem; isHovered:
|
||||
ref={videoRef}
|
||||
src={item.videoUrl}
|
||||
poster={item.poster}
|
||||
autoPlay
|
||||
muted
|
||||
loop
|
||||
playsInline
|
||||
preload="auto"
|
||||
className="absolute inset-0 w-full h-full object-cover pointer-events-none"
|
||||
preload="none"
|
||||
className="absolute top-0 bottom-0 left-1/2 -translate-x-1/2 h-full w-[440px] min-w-full max-w-none object-cover pointer-events-none"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
@@ -469,7 +457,7 @@ function ToolWindowMedia({ item, isHovered }: { item: ToolMediaItem; isHovered:
|
||||
<img
|
||||
src={item.afterUrl}
|
||||
alt={`${item.title} - enhanced`}
|
||||
className="absolute inset-0 w-full h-full object-cover pointer-events-none"
|
||||
className="absolute top-0 bottom-0 left-1/2 -translate-x-1/2 h-full w-[440px] min-w-full max-w-none object-cover pointer-events-none"
|
||||
loading="lazy"
|
||||
/>
|
||||
|
||||
@@ -482,7 +470,7 @@ function ToolWindowMedia({ item, isHovered }: { item: ToolMediaItem; isHovered:
|
||||
<img
|
||||
src={item.beforeUrl}
|
||||
alt={`${item.title} - original`}
|
||||
className="absolute inset-0 w-full h-full object-cover pointer-events-none"
|
||||
className="absolute top-0 bottom-0 left-1/2 -translate-x-1/2 h-full w-[440px] min-w-full max-w-none object-cover pointer-events-none"
|
||||
loading="lazy"
|
||||
/>
|
||||
</div>
|
||||
@@ -515,12 +503,12 @@ function ToolWindowMedia({ item, isHovered }: { item: ToolMediaItem; isHovered:
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Badges in sentence case body face */}
|
||||
<div className="absolute bottom-2 inset-x-2 flex justify-between pointer-events-none z-20 text-xs font-body text-ink">
|
||||
<span className="bg-paper-hi/90 px-1.5 py-0.5 rounded border border-rule shadow-xs">
|
||||
{/* Badges in colored pills */}
|
||||
<div className="absolute bottom-2.5 inset-x-2.5 flex justify-between pointer-events-none z-20 font-body">
|
||||
<span className="bg-ink/80 backdrop-blur-md text-paper-hi text-[10px] font-semibold px-2.5 py-0.5 rounded-full border border-white/20 shadow-xs">
|
||||
Original
|
||||
</span>
|
||||
<span className="bg-paper-hi/90 px-1.5 py-0.5 rounded border border-rule shadow-xs">
|
||||
<span className="bg-accent backdrop-blur-md text-paper-hi text-[10px] font-bold px-2.5 py-0.5 rounded-full border border-white/25 shadow-xs">
|
||||
Enhanced
|
||||
</span>
|
||||
</div>
|
||||
@@ -534,7 +522,7 @@ function ToolWindowMedia({ item, isHovered }: { item: ToolMediaItem; isHovered:
|
||||
<img
|
||||
src={item.imageUrl || item.afterUrl || item.beforeUrl || '/brand/og-default.png'}
|
||||
alt={item.title}
|
||||
className="absolute inset-0 w-full h-full object-cover pointer-events-none"
|
||||
className="absolute top-0 bottom-0 left-1/2 -translate-x-1/2 h-full w-[440px] min-w-full max-w-none object-cover pointer-events-none"
|
||||
loading="lazy"
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user