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

385 lines
18 KiB
TypeScript
Raw Normal View History

'use client';
import React, { useState, useEffect } from 'react';
import Link from 'next/link';
import dynamic from 'next/dynamic';
import {
Sparkles,
ArrowRight,
Smartphone,
ShieldCheck,
Cpu,
Zap,
Layers
} 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';
import { Particles } from '@/components/magicui/particles';
import { BorderBeam } from '@/components/magicui/border-beam';
import { LightRays } from '@/components/magicui/light-rays';
import { RainbowButton } from '@/components/magicui/rainbow-button';
import { InteractiveHoverButton } from '@/components/magicui/interactive-hover-button';
import { BlurFade } from '@/components/magicui/blur-fade';
import { KineticText } from '@/components/magicui/kinetic-text';
import { AnimatedShinyText } from '@/components/magicui/animated-shiny-text';
import { TextAnimate } from '@/components/magicui/text-animate';
import { cn } from '@/lib/utils';
/**
* Interactive Hero Headline Item:
* - At first: Magic UI TextAnimate character entrance (blurInUp stagger)
* - After hovering: Magic UI AnimatedShinyText specular shimmer reflection
* - 0% text shift: unified single DOM node with zero layout jitter
*/
function HeroHeadlineItem({
text,
delay = 0,
}: {
text: string;
delay?: number;
}) {
const [isEntranceDone, setIsEntranceDone] = useState(false);
useEffect(() => {
const timer = setTimeout(() => {
setIsEntranceDone(true);
}, (delay + 0.75) * 1000);
return () => clearTimeout(timer);
}, [delay]);
return (
<AnimatedShinyText
shimmerWidth={220}
hoverOnly={true}
className="font-display font-black text-ink tracking-tight inline-block cursor-pointer select-none overflow-visible pb-[0.25em] -mb-[0.25em]"
>
{isEntranceDone ? (
<span className="font-display font-black text-ink tracking-tight inline-block overflow-visible pb-[0.25em] -mb-[0.25em]">
{text}
</span>
) : (
<TextAnimate
animation="blurInUp"
by="character"
duration={0.55}
delay={delay}
startOnView={false}
accessible={false}
as="span"
className="font-display font-black text-ink tracking-tight inline-block overflow-visible pb-[0.25em] -mb-[0.25em]"
segmentClassName="inline-block whitespace-pre overflow-visible pb-[0.25em] -mb-[0.25em]"
>
{text}
</TextAnimate>
)}
</AnimatedShinyText>
);
}
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) {
2026-11-06 10:53:55 +05:30
const primaryCtaLabel = resolveLocalised(primaryCta?.label, locale, 'Explore our tools');
const primaryCtaHref = primaryCta?.href || '#our-tools';
const secondaryCtaLabel = resolveLocalised(secondaryCta?.label, locale, 'Mobile studio apps');
const secondaryCtaHref = secondaryCta?.href || '#recommended-apps';
// 1. Tool Detail Page Hero (/tools/[slug]) — Where actual operations live
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 (
<section className="relative bg-paper border-b border-rule pt-12 pb-20 px-4 sm:px-6 lg:px-10 overflow-hidden">
{/* Subtle Ambient Studio Background */}
<div
className="pointer-events-none absolute inset-0 opacity-20 studio-proof-grid"
aria-hidden="true"
/>
<div
className="pointer-events-none absolute top-0 right-0 w-[550px] h-[550px] [background:radial-gradient(circle_at_center,color-mix(in_oklab,var(--color-accent)_12%,transparent)_0%,transparent_70%)]"
aria-hidden="true"
/>
<div className="max-w-container mx-auto relative z-10">
{/* Breadcrumb Navigation */}
<nav className="flex items-center gap-2 text-xs font-body text-muted mb-8">
<Link href="/" className="hover:text-ink motion-safe:transition-colors">Home</Link>
<span>/</span>
<Link href="/tools" className="hover:text-ink motion-safe:transition-colors">Tools</Link>
<span>/</span>
<span className="text-ink font-semibold">{resolveLocalised(tool.name, locale)}</span>
</nav>
2026-11-06 10:53:55 +05:30
{/* Heading Block */}
<div className="max-w-3xl mb-12">
<div className="inline-flex items-center gap-2 px-3.5 py-1 rounded-full bg-paper-hi border border-rule text-xs font-body text-ink shadow-xs mb-4">
<Sparkles className="w-3.5 h-3.5 text-accent" />
<span>Studio neural vision</span>
</div>
<h1 className="text-3xl sm:text-5xl font-display font-extrabold text-ink tracking-tight">
<AnimatedShinyText>{resolveLocalised(tool.name, locale)}</AnimatedShinyText>
</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>
{/* Studio Workspace: Upload Studio on Left, Comparison on Right */}
2026-11-06 10:53:55 +05:30
<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 sm:p-8 shadow-sheet relative overflow-hidden">
<BorderBeam size={120} duration={10} borderWidth={1.5} colorFrom="var(--color-accent)" colorTo="var(--color-accent-hi)" />
<div className="border-b border-rule pb-3.5 mb-6 flex items-center justify-between">
<span className="studio-label font-semibold text-ink">Interactive tool studio</span>
2026-11-06 10:53:55 +05:30
<span className="text-xs text-muted font-body">Zero server retention</span>
</div>
<TryItWidget
tool={tool}
homeApp={homeApp}
variants={variants}
locale={locale}
/>
</div>
{/* Specimen View */}
2026-11-06 10:53:55 +05:30
<div className="lg:col-span-6">
<div className="studio-sheet p-5 rounded-card">
<div className="mb-3.5 flex items-center justify-between text-xs text-muted font-body">
<span className="font-medium text-ink">Transformation specimen</span>
<span>Drag slider to inspect details</span>
2026-11-06 10:53:55 +05:30
</div>
<div className="aspect-[4/3] rounded-2xl overflow-hidden bg-paper-2 border border-rule">
2026-11-06 10:53:55 +05:30
<CardBeforeAfterSlider
beforeUrl={primaryExample.before}
afterUrl={primaryExample.after}
title={resolveLocalised(tool.name, locale)}
slug={tool.slug}
aspectRatio="aspect-[4/3]"
/>
</div>
<div className="mt-3.5 text-xs text-muted font-body text-center">
2026-11-06 10:53:55 +05:30
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 (
<section className="relative pt-24 sm:pt-28 pb-16 sm:pb-20 text-center bg-paper border-b border-rule overflow-hidden">
{/* Layered Studio Lighting Ambient Glow */}
<div
className="pointer-events-none absolute top-0 left-1/2 -translate-x-1/2 w-[750px] h-[450px] [background:radial-gradient(ellipse_at_top,color-mix(in_oklab,var(--color-accent)_12%,transparent)_0%,transparent_70%)]"
aria-hidden="true"
/>
<div
className="pointer-events-none absolute inset-0 opacity-20 studio-proof-grid"
aria-hidden="true"
/>
{/* Layered Light Rays & Particles */}
<LightRays className="opacity-40" />
<Particles quantity={25} size={0.7} color="var(--color-accent)" className="absolute inset-0 pointer-events-none" />
<div className="max-w-3xl mx-auto px-4 sm:px-6 lg:px-8 space-y-6 relative z-10">
<BlurFade delay={0.06}>
<div className="inline-flex items-center gap-2 px-4 py-1.5 rounded-full bg-paper-hi border border-rule text-xs font-body text-ink shadow-xs">
<span className="w-2 h-2 rounded-full bg-accent animate-pulse" />
<span className="font-semibold text-accent">Studio Neural Directory</span>
<span className="w-1 h-1 rounded-full bg-muted/40" />
<span className="text-muted">Direct browser trials</span>
</div>
</BlurFade>
<BlurFade delay={0.12}>
<h1 className="text-3xl sm:text-5xl lg:text-6xl font-display font-extrabold text-ink tracking-tight text-balance">
<KineticText>{resolvedTitle}</KineticText>
</h1>
</BlurFade>
{resolvedSubtitle && (
<BlurFade delay={0.18}>
<p className="text-sm sm:text-base lg:text-lg text-ink-2 font-body max-w-xl mx-auto leading-relaxed text-pretty">
{resolvedSubtitle}
</p>
</BlurFade>
)}
{/* Studio Capability Highlights */}
<BlurFade delay={0.22}>
<div className="pt-1 flex flex-wrap items-center justify-center gap-2 text-xs font-body text-muted">
<span className="inline-flex items-center gap-1.5 px-3 py-1 rounded-full bg-paper-hi/90 border border-rule shadow-2xs">
<Sparkles className="w-3.5 h-3.5 text-accent" />
<span>12 neural models</span>
</span>
<span className="inline-flex items-center gap-1.5 px-3 py-1 rounded-full bg-paper-hi/90 border border-rule shadow-2xs">
<ShieldCheck className="w-3.5 h-3.5 text-emerald-600" />
<span>Zero server storage</span>
</span>
<span className="inline-flex items-center gap-1.5 px-3 py-1 rounded-full bg-paper-hi/90 border border-rule shadow-2xs">
<Zap className="w-3.5 h-3.5 text-amber-500" />
<span>Live comparison sliders</span>
</span>
</div>
</BlurFade>
<BlurFade delay={0.26}>
<div className="flex flex-wrap items-center justify-center gap-4 pt-2">
<RainbowButton href="#tools-catalog">
<span>Browse all tools</span>
<ArrowRight className="w-4 h-4 ml-1.5 inline" aria-hidden="true" />
</RainbowButton>
<InteractiveHoverButton text="Mobile apps suite" href="/apps" />
</div>
</BlurFade>
</div>
</section>
);
}
// 3. Front Page Hero (Pure Website Intro, UI, and Animations — NO IMAGE FUNCTIONS, NO OPERATIONS)
return (
<section
id="hero-section"
className="relative min-h-[90vh] sm:min-h-screen flex items-center overflow-hidden bg-paper pt-20 sm:pt-24 pb-14 sm:pb-20 lg:pb-24"
>
{/* Background Layer 1: High-Resolution Responsive Background Image */}
<div className="absolute inset-0 z-0 overflow-hidden">
<picture>
<source media="(max-width: 768px)" srcSet="/management/pages/home/hero_mobile.webp" type="image/webp" />
<source media="(max-width: 768px)" srcSet="/management/pages/home/hero_mobile.jpg" type="image/jpeg" />
<source srcSet="/management/pages/home/hero_desktop.webp" type="image/webp" />
<img
src="/management/pages/home/hero_desktop.jpg"
alt="CRE Innovations Photo Studio"
className="w-full h-full object-cover object-[75%_25%] sm:object-right select-none pointer-events-none opacity-70 sm:opacity-90 brightness-[0.98] sm:brightness-[0.97] translate-y-0 sm:translate-y-6 sm:scale-[1.02]"
loading="eager"
decoding="sync"
/>
</picture>
{/* Dynamic Studio Gradient Feathering (Light Theme Porcelain Scrims) */}
{/* Top Edge Feathering */}
<div className="absolute inset-x-0 top-0 h-28 sm:h-36 bg-gradient-to-b from-paper from-40% via-paper/90 via-70% to-transparent pointer-events-none" />
{/* Left Side Scrim for Desktop: Ensures 100% typography contrast while keeping the photography vibrant */}
<div className="absolute inset-0 bg-gradient-to-r from-paper via-paper/85 via-35% to-transparent to-60% hidden sm:block pointer-events-none" />
{/* Mobile Scrim: Studio porcelain gradient covering headline, subtitle, and action buttons (top 70%), transitioning smoothly into vibrant photography */}
<div className="absolute inset-x-0 top-0 h-[70%] bg-gradient-to-b from-paper from-25% via-paper/92 via-65% to-transparent sm:hidden pointer-events-none" />
{/* Soft Bottom Fade */}
<div className="absolute inset-x-0 bottom-0 h-20 sm:h-24 bg-gradient-to-t from-paper via-paper/85 via-45% to-transparent pointer-events-none" />
</div>
{/* Background Layer 2: Magic UI Atmospheric Light Rays */}
<LightRays className="opacity-45" />
{/* Background Layer 3: Magic UI Floating Particles */}
<Particles
quantity={35}
size={0.8}
color="var(--color-accent)"
className="absolute inset-0 pointer-events-none z-0"
/>
{/* Background Layer 4: Fine Dot Matrix Pattern */}
<div
className="pointer-events-none absolute inset-0 opacity-20 studio-proof-grid z-0"
aria-hidden="true"
/>
{/* Content Container (Website Introduction, Visual Hierarchy, Kinetic Motion) */}
<div className="relative z-10 max-w-[1720px] w-full mx-auto px-4 sm:px-8 lg:px-14 flex flex-col justify-center min-h-[85vh] sm:min-h-[90vh]">
<div className="max-w-2xl sm:max-w-3xl lg:max-w-4xl space-y-6 sm:space-y-8 text-center sm:text-left mx-auto sm:mx-0">
{/* Masterpiece 3-Line Headline:
Line 1: Imagine. -> Magic UI TextAnimate on first, AnimatedShinyText on hover
Line 2: Transform. -> Magic UI TextAnimate on first, AnimatedShinyText on hover
Line 3: Create Impossible -> Simple bluish-purple accent */}
<div className="space-y-0.5 sm:space-y-1">
<h1 className="sr-only">Imagine. Transform. Create Impossible.</h1>
{/* Line 1 - Imagine. with Magic UI TextAnimate (black) -> AnimatedShinyText on hover */}
<div className="text-4xl sm:text-6xl md:text-7xl lg:text-8xl font-display font-black tracking-tight leading-[1.22] sm:leading-[1.18] pb-2 sm:pb-3 block overflow-visible">
<HeroHeadlineItem text="Imagine." delay={0.08} />
</div>
{/* Line 2 - Transform. with Magic UI TextAnimate (black) -> AnimatedShinyText on hover */}
<div className="text-4xl sm:text-6xl md:text-7xl lg:text-8xl font-display font-black tracking-tight leading-[1.22] sm:leading-[1.18] pb-2 sm:pb-3 block overflow-visible">
<HeroHeadlineItem text="Transform." delay={0.28} />
</div>
{/* Line 3 - Create Impossible: Simple bluish-purple accent text */}
<div className="text-4xl sm:text-6xl md:text-7xl lg:text-8xl font-display font-extrabold tracking-tight bg-gradient-to-r from-blue-600 via-indigo-600 to-purple-600 bg-clip-text text-transparent leading-[1.22] sm:leading-[1.18] pt-1 block overflow-visible">
Create Impossible
</div>
</div>
{/* Subtitle */}
<BlurFade delay={0.16}>
<div className="space-y-4 max-w-xl mx-auto sm:mx-0">
<p className="text-base sm:text-xl md:text-2xl text-ink-2 font-body font-normal leading-relaxed text-pretty">
Turn ordinary moments into extraordinary visual art. Instant and private photo transformation right in your browser with hardware acceleration.
2026-11-06 10:53:55 +05:30
</p>
</div>
</BlurFade>
{/* Action Buttons: Redesigned with RainbowButton & InteractiveHoverButton */}
<BlurFade delay={0.24}>
<div className="flex flex-col sm:flex-row items-center sm:items-start justify-center sm:justify-start gap-4 pt-1">
<RainbowButton
href={primaryCtaHref}
className="w-full max-w-[280px] sm:max-w-none sm:w-auto"
>
2026-11-06 10:53:55 +05:30
<span>{primaryCtaLabel}</span>
<ArrowRight className="w-4 h-4 ml-1.5 inline shrink-0" aria-hidden="true" />
</RainbowButton>
<InteractiveHoverButton
text={secondaryCtaLabel}
href={secondaryCtaHref}
className="w-full max-w-[280px] sm:max-w-none sm:w-auto min-h-[50px]"
/>
2026-11-06 10:53:55 +05:30
</div>
</BlurFade>
</div>
</div>
</section>
);
}