feat(hero): overhaul hero and interactive try-it widget with neo-studio aesthetics

This commit is contained in:
2026-11-03 12:59:38 +05:30
parent a23776ad7c
commit 7aa031f6db
3 changed files with 143 additions and 110 deletions
+83 -63
View File
@@ -1,8 +1,21 @@
'use client';
import React, { useState, useRef, useEffect } from 'react';
import React, { useState, useRef } from 'react';
import Link from 'next/link';
import { UploadCloud, CheckCircle2, AlertCircle, RefreshCw, Download, Smartphone, Sparkles, Loader2, Image as ImageIcon, Zap, ChevronRight } from 'lucide-react';
import {
UploadCloud,
AlertCircle,
RefreshCw,
Download,
Smartphone,
Sparkles,
Loader2,
Image as ImageIcon,
Zap,
ChevronRight,
ShieldCheck,
CheckCircle2
} from 'lucide-react';
import { ToolItem, AppItem, VariantSpec, resolveLocalised } from '@/types';
import { BeforeAfterSlider } from '../ui/BeforeAfterSlider';
@@ -35,13 +48,17 @@ export function TryItWidget({
const samplePresets = [
{
label: 'Portrait Sample',
label: 'Portrait Retouch',
url: 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=600&auto=format&fit=crop&q=80',
},
{
label: 'Natural Face',
label: 'Natural Studio Model',
url: 'https://images.unsplash.com/photo-1544005313-94ddf0286df2?w=600&auto=format&fit=crop&q=80',
},
{
label: 'Vintage Archival Shot',
url: 'https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=600&auto=format&fit=crop&q=80',
},
];
const handleFileChange = (file: File) => {
@@ -146,28 +163,31 @@ export function TryItWidget({
};
return (
<div className={`relative bg-white/90 dark:bg-slate-900/90 backdrop-blur-2xl rounded-3xl p-5 sm:p-8 shadow-2xl border border-slate-200/80 dark:border-slate-800/80 overflow-hidden ${className}`}>
{/* Decorative Glow Corner */}
<div className="absolute top-0 right-0 w-64 h-64 bg-gradient-to-bl from-blue-500/10 via-cyan-500/10 to-transparent blur-2xl pointer-events-none -z-10" />
<div className={`relative bg-[#0B0F17]/90 backdrop-blur-2xl rounded-3xl p-6 sm:p-9 border border-white/[0.08] shadow-[0_25px_60px_-15px_rgba(0,0,0,0.8)] overflow-hidden ${className}`}>
{/* Decorative Radial Ambient Corner Glow */}
<div className="absolute top-0 right-0 w-80 h-80 bg-gradient-to-bl from-cyan-500/15 via-purple-600/10 to-transparent blur-3xl pointer-events-none -z-10" />
{/* Top Header & Tries Counter */}
<div className="flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3 sm:gap-4 pb-5 sm:pb-6 border-b border-slate-100 dark:border-slate-800">
<div className="flex items-center space-x-3">
<div className="w-10 h-10 rounded-xl bg-gradient-to-tr from-blue-600 to-cyan-500 flex items-center justify-center text-white shadow-md shadow-blue-500/20 shrink-0">
<Zap className="w-5 h-5" />
<div className="flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 pb-6 border-b border-white/[0.08]">
<div className="flex items-center gap-3.5">
<div className="w-11 h-11 rounded-2xl bg-gradient-to-tr from-cyan-500 to-purple-600 flex items-center justify-center text-black shadow-lg shadow-cyan-500/25 shrink-0">
<Zap className="w-5 h-5 text-black" />
</div>
<div>
<h3 className="font-bold text-slate-900 dark:text-white text-base sm:text-lg">
{resolveLocalised(tool.name, locale)} — Free Online Try
<h3 className="font-display font-extrabold text-white text-base sm:text-lg flex items-center gap-2">
<span>{resolveLocalised(tool.name, locale)}</span>
<span className="text-[10px] font-mono text-cyan-400 bg-cyan-950/60 border border-cyan-500/30 px-2 py-0.5 rounded-full">
Interactive Trial
</span>
</h3>
<p className="text-xs text-slate-500 dark:text-slate-400">
Zero Watermarks • In-Memory Processing • No Sign-Up
<p className="text-xs font-mono text-slate-400 mt-0.5">
Zero Watermarks • In-Memory RAM Stream • No Sign-Up
</p>
</div>
</div>
<div className="self-end sm:self-auto flex items-center space-x-2 bg-emerald-50 dark:bg-emerald-950/50 border border-emerald-200 dark:border-emerald-800 px-3 py-1.5 rounded-full text-xs font-semibold text-emerald-700 dark:text-emerald-400">
<span className="w-2 h-2 rounded-full bg-emerald-500 animate-pulse"></span>
<div className="self-end sm:self-auto flex items-center gap-2 bg-emerald-950/40 border border-emerald-500/30 px-3.5 py-1.5 rounded-full text-xs font-mono text-emerald-400">
<span className="w-2 h-2 rounded-full bg-emerald-400 animate-pulse"></span>
<span>{remainingTries} free tries today</span>
</div>
</div>
@@ -187,8 +207,8 @@ export function TryItWidget({
onClick={() => fileInputRef.current?.click()}
className={`border-2 border-dashed rounded-3xl p-8 sm:p-14 text-center cursor-pointer transition-all duration-300 group ${
isDragOver
? 'border-blue-500 bg-blue-50/50 dark:bg-blue-950/40 scale-[1.01]'
: 'border-slate-300 dark:border-slate-700 hover:border-blue-500 dark:hover:border-blue-400 hover:bg-slate-50/60 dark:hover:bg-slate-800/40'
? 'border-cyan-400 bg-cyan-950/30 scale-[1.01] shadow-[0_0_30px_rgba(0,240,255,0.2)]'
: 'border-white/[0.12] hover:border-cyan-400/60 hover:bg-white/[0.03]'
}`}
>
<input
@@ -198,30 +218,30 @@ export function TryItWidget({
className="hidden"
onChange={(e) => e.target.files?.[0] && handleFileChange(e.target.files[0])}
/>
<div className="w-16 h-16 sm:w-20 sm:h-20 mx-auto mb-4 rounded-3xl bg-gradient-to-tr from-blue-50 to-indigo-50 dark:from-blue-950/60 dark:to-indigo-950/60 border border-blue-200/60 dark:border-blue-800/60 flex items-center justify-center text-blue-600 dark:text-blue-400 group-hover:scale-110 transition-transform duration-300 shadow-sm">
<div className="w-16 h-16 sm:w-20 sm:h-20 mx-auto mb-4 rounded-3xl bg-cyan-500/10 border border-cyan-500/20 flex items-center justify-center text-cyan-400 group-hover:scale-110 group-hover:shadow-[0_0_25px_rgba(0,240,255,0.3)] transition-all duration-300">
<UploadCloud className="w-8 h-8 sm:w-10 sm:h-10" />
</div>
<p className="text-base sm:text-lg font-bold text-slate-900 dark:text-white">
Drag & drop your photo here, or <span className="text-blue-600 dark:text-blue-400 underline decoration-2 underline-offset-4">browse</span>
<p className="text-base sm:text-lg font-display font-bold text-white">
Drag & drop your photo here, or <span className="text-cyan-400 underline decoration-cyan-400/50 underline-offset-4 group-hover:text-cyan-300">browse file</span>
</p>
<p className="mt-1.5 text-xs text-slate-500 dark:text-slate-400">
<p className="mt-1.5 text-xs font-mono text-slate-400">
Supports JPG, PNG, WEBP up to {tool.tryIt?.limits?.maxMB || 12}MB
</p>
</div>
{/* Quick Sample Presets */}
<div>
<p className="text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-wider mb-3">
Or test with a sample photo:
<p className="text-xs font-mono uppercase tracking-wider text-slate-400 mb-3">
Or inspect with an instant sample preset:
</p>
<div className="flex flex-wrap gap-2.5">
{samplePresets.map((preset, idx) => (
<button
key={idx}
onClick={() => loadSamplePreset(preset.url)}
className="inline-flex items-center space-x-2 px-4 py-2.5 rounded-xl text-xs font-semibold bg-slate-100 dark:bg-slate-800 text-slate-700 dark:text-slate-200 hover:bg-blue-50 dark:hover:bg-blue-950 hover:text-blue-600 dark:hover:text-blue-400 border border-transparent hover:border-blue-200 dark:hover:border-blue-800 transition-all active:scale-95"
className="inline-flex items-center gap-2 px-4 py-2.5 rounded-xl text-xs font-semibold bg-white/[0.04] border border-white/[0.08] text-slate-300 hover:text-white hover:bg-cyan-950/40 hover:border-cyan-500/30 transition-all active:scale-95"
>
<ImageIcon className="w-3.5 h-3.5 text-slate-400" />
<ImageIcon className="w-3.5 h-3.5 text-cyan-400" />
<span>{preset.label}</span>
</button>
))}
@@ -234,22 +254,22 @@ export function TryItWidget({
<div className="space-y-6">
<div className="grid grid-cols-1 md:grid-cols-2 gap-6 items-center">
{/* Image Preview Card */}
<div className="relative aspect-[4/3] rounded-2xl sm:rounded-3xl overflow-hidden border border-slate-200 dark:border-slate-800 bg-slate-100 dark:bg-slate-950 shadow-md">
<div className="relative aspect-[4/3] rounded-3xl overflow-hidden border border-white/[0.1] bg-[#07090E] shadow-xl">
{/* eslint-disable-next-line @next/next/no-img-element */}
<img src={previewUrl} alt="Selected photo" className="w-full h-full object-cover" />
<button
onClick={reset}
className="absolute top-3 right-3 bg-black/70 hover:bg-black/90 text-white text-xs font-semibold px-3 py-1.5 rounded-xl backdrop-blur-md transition-colors"
className="absolute top-3 right-3 bg-black/80 hover:bg-black text-white text-xs font-mono px-3 py-1.5 rounded-xl backdrop-blur-md border border-white/20 transition-colors"
>
Change Photo
</button>
</div>
{/* Mode Selection & Run Action */}
<div className="space-y-4">
<div className="space-y-5">
{variants.length > 0 && (
<div>
<label className="block text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-wider mb-2.5">
<label className="block text-xs font-mono uppercase tracking-wider text-slate-400 mb-2.5">
{resolveLocalised(tool.tryIt?.variantControl?.label, locale, 'Select Retouch Mode')}
</label>
<div className="space-y-2">
@@ -258,8 +278,8 @@ export function TryItWidget({
key={v.id}
className={`flex items-center justify-between p-3.5 rounded-2xl border cursor-pointer transition-all duration-200 ${
activeVariant === v.id
? 'border-blue-600 bg-blue-50/60 dark:bg-blue-950/40 dark:border-blue-500 shadow-sm ring-1 ring-blue-500/20'
: 'border-slate-200 dark:border-slate-800 hover:border-slate-300 dark:hover:border-slate-700'
? 'border-cyan-400 bg-cyan-950/40 text-cyan-300 shadow-[0_0_15px_rgba(0,240,255,0.15)]'
: 'border-white/[0.08] hover:border-white/[0.2] bg-white/[0.02]'
}`}
>
<div className="flex items-center space-x-3">
@@ -269,14 +289,14 @@ export function TryItWidget({
value={v.id}
checked={activeVariant === v.id}
onChange={() => setActiveVariant(v.id)}
className="text-blue-600 focus:ring-blue-500 h-4 w-4"
className="text-cyan-400 focus:ring-cyan-400 h-4 w-4 bg-transparent border-white/20"
/>
<div>
<p className="text-xs sm:text-sm font-bold text-slate-900 dark:text-white">
<p className="text-xs sm:text-sm font-bold text-white">
{resolveLocalised(v.label, locale, v.description || v.id)}
</p>
{v.description && (
<p className="text-[11px] text-slate-500 dark:text-slate-400">{v.description}</p>
<p className="text-[11px] text-slate-400">{v.description}</p>
)}
</div>
</div>
@@ -289,9 +309,9 @@ export function TryItWidget({
{/* Run Button */}
<button
onClick={runTryIt}
className="w-full py-4 px-6 rounded-2xl font-bold text-sm text-white bg-gradient-to-r from-blue-600 via-indigo-600 to-cyan-500 hover:from-blue-700 hover:to-indigo-700 shadow-xl shadow-blue-500/25 hover:shadow-blue-500/40 transition-all flex items-center justify-center space-x-2 active:scale-98"
className="w-full py-4 px-6 rounded-2xl font-bold text-xs sm:text-sm text-black bg-gradient-to-r from-cyan-400 via-teal-300 to-purple-400 hover:from-cyan-300 hover:to-teal-200 shadow-[0_0_25px_rgba(0,240,255,0.35)] transition-all flex items-center justify-center gap-2 active:scale-98"
>
<Sparkles className="w-4 h-4" />
<Sparkles className="w-4 h-4 text-black" />
<span>Run {resolveLocalised(tool.name, locale)}</span>
</button>
</div>
@@ -300,20 +320,20 @@ export function TryItWidget({
)}
{status === 'processing' && (
<div className="py-14 sm:py-20 text-center space-y-4">
<div className="relative inline-flex p-4 rounded-2xl bg-blue-50 dark:bg-blue-950/80 text-blue-600 shadow-inner">
<Loader2 className="w-10 h-10 animate-spin" />
<div className="py-16 sm:py-20 text-center space-y-5">
<div className="relative inline-flex p-5 rounded-3xl bg-cyan-950/40 border border-cyan-500/30 text-cyan-400 shadow-[0_0_35px_rgba(0,240,255,0.25)]">
<Loader2 className="w-10 h-10 animate-spin text-cyan-400" />
<span className="absolute -top-1 -right-1 flex h-3 w-3">
<span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-cyan-400 opacity-75"></span>
<span className="relative inline-flex rounded-full h-3 w-3 bg-cyan-500"></span>
</span>
</div>
<div>
<h4 className="text-lg font-bold text-slate-900 dark:text-white">
<h4 className="text-lg font-display font-bold text-white">
CRE Neural Vision Engine Processing...
</h4>
<p className="text-xs sm:text-sm text-slate-500 dark:text-slate-400 max-w-sm mx-auto mt-1">
Applying deep learning models while keeping original textures and skin pores intact.
<p className="text-xs sm:text-sm text-slate-400 max-w-sm mx-auto mt-1 font-mono">
Synthesizing deep learning layers while preserving native pore texture in volatile RAM.
</p>
</div>
</div>
@@ -333,44 +353,44 @@ export function TryItWidget({
<div className="flex flex-wrap items-center justify-between gap-3 pt-2">
<button
onClick={reset}
className="inline-flex items-center space-x-2 px-4 py-2.5 rounded-xl text-xs sm:text-sm font-semibold border border-slate-300 dark:border-slate-700 hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors"
className="inline-flex items-center gap-2 px-4 py-2.5 rounded-xl text-xs sm:text-sm font-semibold border border-white/[0.1] bg-white/[0.04] hover:bg-white/[0.08] text-slate-300 hover:text-white transition-colors"
>
<RefreshCw className="w-4 h-4 text-slate-500" />
<RefreshCw className="w-4 h-4 text-slate-400" />
<span>Process Another Photo</span>
</button>
<a
href={resultUrl}
download={`${tool.slug}-result.png`}
className="inline-flex items-center space-x-2 px-6 py-2.5 rounded-xl text-xs sm:text-sm font-bold text-white bg-emerald-600 hover:bg-emerald-700 shadow-lg shadow-emerald-500/20 transition-all hover:scale-105 active:scale-95"
className="inline-flex items-center gap-2 px-6 py-2.5 rounded-xl text-xs sm:text-sm font-bold text-black bg-gradient-to-r from-cyan-400 to-teal-300 hover:from-cyan-300 hover:to-teal-200 shadow-[0_0_20px_rgba(0,240,255,0.3)] transition-all hover:scale-105 active:scale-95"
>
<Download className="w-4 h-4" />
<Download className="w-4 h-4 text-black" />
<span>Download Result (HD)</span>
</a>
</div>
{/* Result App Handoff Card */}
{homeApp && (
<div className="mt-6 p-5 sm:p-6 rounded-3xl bg-gradient-to-r from-blue-50/80 via-indigo-50/80 to-cyan-50/80 dark:from-blue-950/40 dark:via-indigo-950/40 dark:to-cyan-950/40 border border-blue-200/80 dark:border-blue-900/60 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4">
<div className="mt-6 p-6 rounded-3xl bg-gradient-to-br from-purple-950/40 via-cyan-950/20 to-black border border-purple-500/30 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-5">
<div className="space-y-1">
<div className="flex items-center space-x-2">
<Smartphone className="w-4 h-4 text-blue-600 dark:text-blue-400" />
<span className="text-[11px] font-extrabold uppercase tracking-wider text-blue-600 dark:text-blue-400">
<div className="flex items-center gap-2">
<Smartphone className="w-4 h-4 text-purple-400" />
<span className="text-[11px] font-mono uppercase tracking-widest text-purple-300">
Need 4K Lossless & Batch Processing?
</span>
</div>
<h5 className="font-bold text-slate-900 dark:text-white text-base">
Open {resolveLocalised(tool.name, locale)} in {resolveLocalised(homeApp.name, locale)}
<h5 className="font-display font-bold text-white text-base">
Open in {resolveLocalised(homeApp.name, locale)}
</h5>
<p className="text-xs text-slate-600 dark:text-slate-400">
<p className="text-xs text-slate-400">
Get 50 free HD export credits on first launch with promo code{' '}
<span className="font-mono font-extrabold text-blue-600 dark:text-cyan-400">{homeApp.welcomeBonus?.code || 'TRYWEB50'}</span>.
<span className="font-mono font-bold text-cyan-400">{homeApp.welcomeBonus?.code || 'TRYWEB50'}</span>.
</p>
</div>
<Link
href={`/go/${tool.slug}/${homeApp.slug}`}
className="w-full sm:w-auto shrink-0 px-6 py-3 rounded-2xl text-xs font-bold text-white bg-blue-600 hover:bg-blue-700 shadow-md shadow-blue-500/25 transition-all text-center flex items-center justify-center space-x-2"
className="w-full sm:w-auto shrink-0 px-6 py-3 rounded-full text-xs font-bold text-black bg-gradient-to-r from-purple-400 to-cyan-400 shadow-md transition-all text-center flex items-center justify-center gap-2 hover:scale-105"
>
<span>Open in Mobile App</span>
<ChevronRight className="w-4 h-4" />
@@ -381,19 +401,19 @@ export function TryItWidget({
)}
{(status === 'limit' || status === 'error' || status === 'unavailable') && (
<div className="p-6 sm:p-8 rounded-3xl bg-amber-50/80 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 text-center space-y-4">
<div className="w-12 h-12 mx-auto rounded-2xl bg-amber-100 dark:bg-amber-900/40 flex items-center justify-center text-amber-600 dark:text-amber-400">
<div className="p-7 sm:p-9 rounded-3xl bg-amber-950/20 border border-amber-500/30 text-center space-y-4">
<div className="w-12 h-12 mx-auto rounded-2xl bg-amber-900/40 border border-amber-500/40 flex items-center justify-center text-amber-400">
<AlertCircle className="w-6 h-6" />
</div>
<div>
<h4 className="text-base font-bold text-slate-900 dark:text-white">
<h4 className="text-base font-display font-bold text-white">
{status === 'limit'
? 'Daily Free Web Limit Reached'
: status === 'unavailable'
? 'Service Temporarily Offline'
: 'Processing Issue'}
</h4>
<p className="text-xs sm:text-sm text-slate-600 dark:text-slate-400 max-w-md mx-auto mt-1">
<p className="text-xs sm:text-sm text-slate-400 max-w-md mx-auto mt-1 font-mono">
{errorMessage}
</p>
</div>
@@ -401,14 +421,14 @@ export function TryItWidget({
<div className="flex flex-wrap items-center justify-center gap-3 pt-2">
<button
onClick={reset}
className="px-4 py-2 rounded-xl text-xs font-semibold border border-slate-300 dark:border-slate-700 hover:bg-white dark:hover:bg-slate-800"
className="px-4 py-2 rounded-xl text-xs font-semibold border border-white/[0.1] bg-white/[0.04] hover:bg-white/[0.08] text-slate-300"
>
Try Again
</button>
{homeApp && (
<Link
href={`/go/${tool.slug}/${homeApp.slug}`}
className="px-5 py-2 rounded-xl text-xs font-bold text-white bg-blue-600 hover:bg-blue-700 shadow-md"
className="px-5 py-2 rounded-xl text-xs font-bold text-black bg-gradient-to-r from-cyan-400 to-teal-300 shadow-md"
>
Open in {resolveLocalised(homeApp.name, locale)}
</Link>