143 lines
7.3 KiB
TypeScript
143 lines
7.3 KiB
TypeScript
'use client';
|
|
|
|
import { useMemo, useState } from 'react';
|
|
import type { ElementType } from 'react';
|
|
import Link from 'next/link';
|
|
import { ArrowRight, Layers, Palette, Scissors, Smile, Sparkles } from 'lucide-react';
|
|
import { KineticText } from '@/components/magicui/kinetic-text';
|
|
import { AppItem, CategoryItem, resolveLocalised, ToolItem } from '@/types';
|
|
import { CardBeforeAfterSlider } from '@/components/ui/CardBeforeAfterSlider';
|
|
|
|
interface VerticalToolStackProps {
|
|
context: { tools: ToolItem[]; categories: CategoryItem[]; apps: AppItem[]; locale: string };
|
|
}
|
|
|
|
const icons: Record<string, ElementType> = { Smile, Sparkles, Scissors, Palette, Layers };
|
|
|
|
const fallbackImage = '/management/pages/home/media/sample_portrait_1.jpg';
|
|
|
|
export function VerticalToolStackSection({ context }: VerticalToolStackProps) {
|
|
const { tools, categories, apps, locale } = context;
|
|
const [category, setCategory] = useState('all');
|
|
const visibleCategories = useMemo(
|
|
() => category === 'all' ? categories : categories.filter((item) => item.slug === category),
|
|
[categories, category]
|
|
);
|
|
|
|
return (
|
|
<section id="studio-suite" className="scroll-mt-24 border-y border-slate-900/[0.08] bg-[#FAF8F5] py-16 sm:py-20 lg:py-24">
|
|
<div id="tools-stack" className="relative -top-24" />
|
|
<div className="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
|
|
<header className="mx-auto max-w-3xl text-center">
|
|
<p className="eyebrow">THE CREATIVE STUDIO SUITE</p>
|
|
<h2 className="mt-3 text-3xl font-display font-bold tracking-tight text-slate-900 sm:text-4xl lg:text-5xl">
|
|
<KineticText>Find the right tool, fast.</KineticText>
|
|
</h2>
|
|
<p className="mt-4 text-base leading-relaxed text-slate-600 sm:text-lg">Choose a creative task, see a real preview, and start your edit in one tap.</p>
|
|
</header>
|
|
|
|
<div className="tool-filter-rail mt-9 flex gap-2 overflow-x-auto pb-2 sm:mt-10 sm:flex-wrap sm:justify-center sm:overflow-visible" role="tablist" aria-label="Tool categories">
|
|
<FilterButton active={category === 'all'} onClick={() => setCategory('all')} label="All tools" count={tools.length} icon={Layers} />
|
|
{categories.map((item) => {
|
|
const Icon = icons[item.icon || 'Sparkles'] || Sparkles;
|
|
return <FilterButton key={item.slug} active={category === item.slug} onClick={() => setCategory(item.slug)} label={resolveLocalised(item.name, locale)} count={tools.filter((tool) => tool.category === item.slug).length} icon={Icon} />;
|
|
})}
|
|
</div>
|
|
|
|
<div className="mt-10 space-y-12 sm:mt-12 sm:space-y-14">
|
|
{visibleCategories.map((item) => {
|
|
const categoryTools = tools.filter((tool) => tool.category === item.slug);
|
|
if (!categoryTools.length) return null;
|
|
const Icon = icons[item.icon || 'Sparkles'] || Sparkles;
|
|
return (
|
|
<section key={item.slug} aria-labelledby={`${item.slug}-title`}>
|
|
<div className="mb-5 flex items-end justify-between border-b border-slate-200 pb-4">
|
|
<div className="flex items-center gap-3">
|
|
<span className="grid h-10 w-10 place-items-center rounded-2xl bg-blue-50 text-blue-700"><Icon className="h-5 w-5" /></span>
|
|
<div>
|
|
<h3 id={`${item.slug}-title`} className="text-xl font-display font-bold text-slate-900 sm:text-2xl">{resolveLocalised(item.name, locale)}</h3>
|
|
<p className="mt-0.5 text-sm text-slate-600">{resolveLocalised(item.description, locale)}</p>
|
|
</div>
|
|
</div>
|
|
<span className="hidden text-xs font-semibold text-slate-500 sm:block">{categoryTools.length} tools</span>
|
|
</div>
|
|
<div className="grid gap-5 sm:grid-cols-2 lg:grid-cols-3">
|
|
{categoryTools.map((tool) => <ToolCard key={tool.id} tool={tool} app={apps.find((item) => item.id === tool.homeApp)} locale={locale} />)}
|
|
</div>
|
|
</section>
|
|
);
|
|
})}
|
|
</div>
|
|
</div>
|
|
</section>
|
|
);
|
|
}
|
|
|
|
function FilterButton({ active, onClick, label, count, icon: Icon }: { active: boolean; onClick: () => void; label: string; count: number; icon: ElementType }) {
|
|
return (
|
|
<button type="button" role="tab" aria-selected={active} onClick={onClick} className={`inline-flex min-h-11 shrink-0 items-center gap-2 rounded-full border px-4 py-2 text-sm font-semibold transition-colors ${active ? 'border-slate-950 bg-slate-950 text-white' : 'border-slate-200 bg-white text-slate-700 hover:border-slate-400 hover:bg-slate-50'}`}>
|
|
<Icon className="h-4 w-4" /> {label} <span className={`rounded-full px-1.5 py-0.5 text-[10px] ${active ? 'bg-white/15' : 'bg-slate-100 text-slate-500'}`}>{count}</span>
|
|
</button>
|
|
);
|
|
}
|
|
|
|
function ToolCard({ tool, app, locale }: { tool: ToolItem; app?: AppItem; locale: string }) {
|
|
const example = tool.content?.examples?.[0];
|
|
const hasComparison = !!(example?.before && example?.after);
|
|
const image = example?.after || example?.before || fallbackImage;
|
|
|
|
return (
|
|
<article className="group overflow-hidden rounded-3xl border border-slate-900/[0.08] bg-white shadow-cream-sm transition-[box-shadow,border-color,transform] duration-300 hover:-translate-y-0.5 hover:border-blue-300 hover:shadow-cream-md">
|
|
<div className="relative aspect-[16/10] overflow-hidden bg-slate-100">
|
|
{hasComparison ? (
|
|
<CardBeforeAfterSlider
|
|
beforeUrl={example.before}
|
|
afterUrl={example.after}
|
|
beforeLabel="ORIGINAL"
|
|
afterLabel="RESULT"
|
|
aspectRatio="aspect-[16/10]"
|
|
/>
|
|
) : (
|
|
/* eslint-disable-next-line @next/next/no-img-element */
|
|
<img
|
|
src={image}
|
|
alt={resolveLocalised(tool.name, locale)}
|
|
loading="lazy"
|
|
decoding="async"
|
|
className="h-full w-full object-cover transition-transform duration-500 group-hover:scale-[1.03]"
|
|
/>
|
|
)}
|
|
<span className="pointer-events-none absolute left-3 top-3 z-30 rounded-full bg-white/94 px-2.5 py-1 text-[10px] font-semibold uppercase tracking-wide text-slate-700 shadow-sm backdrop-blur">
|
|
{tool.category.replace('-', ' ')}
|
|
</span>
|
|
</div>
|
|
<div className="p-5">
|
|
<h4 className="text-xl font-display font-bold tracking-tight text-slate-900">
|
|
<Link href={`/tools/${tool.slug}`} className="hover:text-blue-700 transition-colors">
|
|
{resolveLocalised(tool.name, locale)}
|
|
</Link>
|
|
</h4>
|
|
<p className="mt-2 line-clamp-2 text-sm leading-relaxed text-slate-600">
|
|
{resolveLocalised(tool.summary, locale)}
|
|
</p>
|
|
<div className="mt-5 flex items-center justify-between gap-3">
|
|
<Link
|
|
href={`/tools/${tool.slug}`}
|
|
className="inline-flex min-h-11 items-center gap-1.5 text-sm font-semibold text-blue-700 transition-transform hover:translate-x-0.5"
|
|
>
|
|
Try it <ArrowRight className="h-4 w-4" />
|
|
</Link>
|
|
{app && (
|
|
<Link
|
|
href={`/apps/${app.slug}`}
|
|
className="text-xs font-medium text-slate-500 hover:text-slate-900"
|
|
>
|
|
Get app
|
|
</Link>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</article>
|
|
);
|
|
}
|