Files
webb/src/components/sections/HeroSection.tsx
T

214 lines
9.0 KiB
TypeScript
Raw Normal View History

'use client';
2026-11-06 10:53:55 +05:30
import React, { useState } from 'react';
import Link from 'next/link';
2026-11-06 10:53:55 +05:30
import { ArrowRight, Smartphone, SlidersHorizontal, UploadCloud } from 'lucide-react';
import { ToolItem, VariantSpec, resolveLocalised } from '@/types';
import { TryItWidget } from './TryItWidget';
2026-11-06 10:53:55 +05:30
import { CardBeforeAfterSlider } from '@/components/ui/CardBeforeAfterSlider';
interface HeroSectionProps {
title?: Record<string, string> | string;
badge?: Record<string, string> | string;
subtitle?: Record<string, string> | string;
primaryCta?: { label?: Record<string, string> | string; href?: string };
secondaryCta?: { label?: Record<string, string> | string; href?: string };
variant?: string;
tool?: ToolItem;
homeApp?: any;
variants?: VariantSpec[];
locale?: string;
}
export function HeroSection({
title,
badge,
subtitle,
primaryCta,
secondaryCta,
variant = 'frontpage',
tool,
homeApp,
variants = [],
locale = 'en',
}: HeroSectionProps) {
const [mobileTab, setMobileTab] = useState<'upload' | 'compare'>('upload');
2026-11-06 10:53:55 +05:30
const primaryCtaLabel = resolveLocalised(primaryCta?.label, locale, 'Explore our tools');
const primaryCtaHref = primaryCta?.href || '#our-tools';
2026-11-06 10:53:55 +05:30
const secondaryCtaLabel = resolveLocalised(secondaryCta?.label, locale, 'Native mobile apps');
const secondaryCtaHref = secondaryCta?.href || '/apps';
2026-11-06 10:53:55 +05:30
// 1. Tool Detail Page Hero (/tools/[slug])
if (variant === 'toolHero' && tool) {
const toolMedia = (tool as any).media;
const primaryExample = tool.content?.examples?.[0] || {
before: toolMedia?.before || `/management/pages/tools/${tool.slug}/media/before.jpg`,
after: toolMedia?.after || `/management/pages/tools/${tool.slug}/media/after.jpg`,
caption: 'Sub-pixel neural transformation details',
};
return (
2026-11-06 10:53:55 +05:30
<section className="relative bg-paper border-b border-rule pt-8 pb-16 px-4 sm:px-6 lg:px-8">
<div className="max-w-container mx-auto">
{/* Breadcrumb Navigation */}
2026-11-06 10:53:55 +05:30
<nav className="flex items-center gap-2 text-xs font-body text-muted mb-6">
<Link href="/" className="hover:text-ink transition-colors">Home</Link>
<span>/</span>
2026-11-06 10:53:55 +05:30
<Link href="/tools" className="hover:text-ink transition-colors">Tools</Link>
<span>/</span>
2026-11-06 10:53:55 +05:30
<span className="text-ink font-medium">{resolveLocalised(tool.name, locale)}</span>
</nav>
2026-11-06 10:53:55 +05:30
{/* Heading Block */}
<div className="max-w-3xl mb-10">
<h1 className="text-3xl sm:text-5xl font-display font-bold text-ink tracking-tight">
{resolveLocalised(tool.name, locale)}
</h1>
2026-11-06 10:53:55 +05:30
<p className="mt-3 text-base sm:text-lg text-ink-2 font-body max-w-2xl leading-relaxed">
{resolveLocalised(tool.summary, locale)}
</p>
</div>
2026-11-06 10:53:55 +05:30
{/* Studio Workspace: Counter Layout (Upload Studio on Left, Comparison Proof on Right) */}
<div className="grid grid-cols-1 lg:grid-cols-12 gap-8 items-start">
{/* Upload Studio */}
<div className="lg:col-span-6 bg-paper-hi border border-rule rounded-card p-6 shadow-sheet">
<div className="border-b border-rule pb-3 mb-6 flex items-center justify-between">
<span className="studio-label">Proof studio</span>
<span className="text-xs text-muted font-body">Zero server retention</span>
</div>
<TryItWidget
tool={tool}
homeApp={homeApp}
variants={variants}
locale={locale}
/>
</div>
2026-11-06 10:53:55 +05:30
{/* Comparison Proof Sheet */}
<div className="lg:col-span-6">
<div className="studio-sheet p-4 crop-marked">
<div className="mb-3 flex items-center justify-between text-xs text-muted font-body">
<span>Transformation specimen</span>
<span>Drag slider to inspect</span>
</div>
<div className="aspect-[4/3] rounded-card overflow-hidden bg-paper-2">
<CardBeforeAfterSlider
beforeUrl={primaryExample.before}
afterUrl={primaryExample.after}
title={resolveLocalised(tool.name, locale)}
slug={tool.slug}
aspectRatio="aspect-[4/3]"
/>
</div>
<div className="mt-3 text-xs text-muted font-body text-center">
Full 4K batch processing available in the {homeApp ? resolveLocalised(homeApp.name, locale) : 'mobile app'}.
</div>
</div>
</div>
</div>
</div>
</section>
);
}
2026-11-06 10:53:55 +05:30
// 2. Centered Directory Hero (for /tools, /apps, /pricing, /trust)
if (variant === 'centered') {
2026-11-06 10:53:55 +05:30
const resolvedTitle = resolveLocalised(title, locale) || 'Creative studio';
const resolvedSubtitle = resolveLocalised(subtitle, locale);
return (
2026-11-06 10:53:55 +05:30
<section className="relative pt-16 pb-14 text-center bg-paper border-b border-rule">
<div className="max-w-3xl mx-auto px-4 sm:px-6 lg:px-8 space-y-4">
<h1 className="text-3xl sm:text-5xl font-display font-bold text-ink tracking-tight">
{resolvedTitle}
</h1>
{resolvedSubtitle && (
2026-11-06 10:53:55 +05:30
<p className="text-base sm:text-lg text-ink-2 font-body max-w-xl mx-auto leading-relaxed">
{resolvedSubtitle}
</p>
)}
2026-11-06 10:53:55 +05:30
<div className="flex flex-wrap items-center justify-center gap-3 pt-2">
<Link href="/#our-tools" className="btn-primary">
Browse tools
</Link>
2026-11-06 10:53:55 +05:30
<Link href="/apps" className="btn-secondary">
Mobile apps
</Link>
</div>
</div>
</section>
);
}
2026-11-06 10:53:55 +05:30
// 3. Homepage Hero (Narrative Workflow shape, Counter posture)
return (
2026-11-06 10:53:55 +05:30
<section id="hero-section" className="relative bg-paper studio-proof-grid border-b border-rule pt-12 sm:pt-16 pb-16 sm:pb-20">
<div className="max-w-container mx-auto px-4 sm:px-6 lg:px-8">
<div className="grid grid-cols-1 lg:grid-cols-12 gap-10 lg:gap-12 items-center">
{/* Left Column: Content & Actions (Counter Posture) */}
<div className="lg:col-span-6 space-y-6">
<div className="space-y-3">
<h1 className="text-4xl sm:text-5xl lg:text-6xl font-display font-bold text-ink tracking-tight leading-[1.04]">
Photographic tools, built with precision.
</h1>
<p className="text-base sm:text-lg text-ink-2 font-body leading-relaxed max-w-xl">
Retouch portraits, extract cutouts, and restore archival prints directly in your browser.
</p>
</div>
2026-11-06 10:53:55 +05:30
{/* Actions */}
<div className="flex flex-wrap items-center gap-3 pt-1">
<a href={primaryCtaHref} className="btn-primary">
<span>{primaryCtaLabel}</span>
<ArrowRight className="w-4 h-4" aria-hidden="true" />
</a>
2026-11-06 10:53:55 +05:30
<Link href={secondaryCtaHref} className="btn-secondary">
<Smartphone className="w-4 h-4 text-accent" aria-hidden="true" />
<span>{secondaryCtaLabel}</span>
</Link>
</div>
2026-11-06 10:53:55 +05:30
{/* Proof Line */}
<div className="pt-2 flex items-center gap-6 text-xs text-muted font-body border-t border-rule">
<span>Zero server image retention</span>
<span>Hardware-accelerated neural models</span>
<span>Free browser trial</span>
</div>
</div>
2026-11-06 10:53:55 +05:30
{/* Right Column: Lead Interactive Specimen (Crop-Marked Before/After Loupe) */}
<div className="lg:col-span-6">
<div className="studio-sheet p-4 sm:p-5 crop-marked">
<div className="mb-3 flex items-center justify-between text-xs text-muted font-body">
<span className="font-medium text-ink">Skin & blemish retoucher</span>
<span>Drag to inspect sub-pore restoration</span>
</div>
2026-11-06 10:53:55 +05:30
<div className="aspect-[16/10] rounded-card overflow-hidden bg-paper-2 border border-rule">
<CardBeforeAfterSlider
beforeUrl="/management/pages/home/sections/our-tools/blemish-remover/before.jpg"
afterUrl="/management/pages/home/sections/our-tools/blemish-remover/after.jpg"
title="Skin & blemish retoucher"
slug="blemish-remover"
aspectRatio="aspect-[16/10]"
/>
</div>
2026-11-06 10:53:55 +05:30
<div className="mt-3 flex items-center justify-between text-xs text-muted font-body">
<span>Natural skin pore preservation</span>
<Link href="/tools/blemish-remover" className="text-accent hover:underline font-medium">
Open full tool studio
</Link>
</div>
</div>
</div>
</div>
</div>
</section>
);
}