feat: real-time auto-sliding and hover-scrubbing cards in tool stack, and interactive 2-column Try It transformation studio on tool pages
This commit is contained in:
@@ -8,7 +8,7 @@ import { TryItWidget } from './TryItWidget';
|
||||
import { HeroPrism } from '@/components/3d/HeroPrism';
|
||||
import { Kinetic3DText } from '@/components/ui/Kinetic3DText';
|
||||
import { ShimmerBadge } from '@/components/animate-ui/ShimmerBadge';
|
||||
import { DeferredComparison } from '@/components/ui/DeferredComparison';
|
||||
import { CardBeforeAfterSlider } from '@/components/ui/CardBeforeAfterSlider';
|
||||
|
||||
interface HeroSectionProps {
|
||||
title?: any;
|
||||
@@ -170,7 +170,7 @@ export function HeroSection({
|
||||
<div className="relative rounded-[2rem] border border-slate-900/[0.1] bg-white p-2.5 sm:p-3 shadow-cinematic-3d">
|
||||
{example?.before && example?.after ? (
|
||||
<div className="space-y-2.5">
|
||||
<DeferredComparison
|
||||
<CardBeforeAfterSlider
|
||||
beforeUrl={example.before}
|
||||
afterUrl={example.after}
|
||||
beforeLabel="ORIGINAL"
|
||||
|
||||
@@ -119,7 +119,7 @@ function SectionContent({ section, context }: SectionRendererProps) {
|
||||
case 'tryItWidget':
|
||||
if (!context.tool) return null;
|
||||
return (
|
||||
<div className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
||||
<div id="tool-tryit" className="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 py-10 sm:py-14">
|
||||
<TryItWidget
|
||||
tool={context.tool}
|
||||
homeApp={context.homeApp}
|
||||
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
} from 'lucide-react';
|
||||
import { ToolItem, AppItem, VariantSpec, resolveLocalised } from '@/types';
|
||||
import { BeforeAfterSlider } from '../ui/BeforeAfterSlider';
|
||||
import { CardBeforeAfterSlider } from '../ui/CardBeforeAfterSlider';
|
||||
|
||||
interface TryItWidgetProps {
|
||||
tool: ToolItem;
|
||||
@@ -206,65 +207,111 @@ export function TryItWidget({
|
||||
{/* Main Body per Status */}
|
||||
<div className="mt-7">
|
||||
{status === 'idle' && (
|
||||
<div className="space-y-6">
|
||||
{/* Drag & Drop Upload Zone */}
|
||||
<div
|
||||
onDrop={handleDrop}
|
||||
onDragOver={(e) => {
|
||||
e.preventDefault();
|
||||
setIsDragOver(true);
|
||||
}}
|
||||
onDragLeave={() => setIsDragOver(false)}
|
||||
onClick={() => fileInputRef.current?.click()}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter' || e.key === ' ') {
|
||||
e.preventDefault();
|
||||
fileInputRef.current?.click();
|
||||
}
|
||||
}}
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
aria-label="Choose a JPG, PNG, or WebP photo to edit"
|
||||
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 scale-[1.01]'
|
||||
: 'border-slate-300 hover:border-blue-500 bg-slate-50/50 hover:bg-blue-50/20'
|
||||
}`}
|
||||
>
|
||||
<input
|
||||
ref={fileInputRef}
|
||||
type="file"
|
||||
accept="image/jpeg,image/png,image/webp"
|
||||
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-blue-50 border border-blue-100 flex items-center justify-center text-blue-600 group-hover:scale-110 transition-all duration-300 shadow-sm">
|
||||
<UploadCloud className="w-8 h-8 sm:w-10 sm:h-10" />
|
||||
<div className="grid grid-cols-1 lg:grid-cols-[1.1fr_.9fr] gap-8 items-center">
|
||||
{/* Left Column: Interactive Before/After Transformation Preview */}
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-xs font-mono uppercase tracking-wider text-slate-500 font-bold flex items-center gap-1.5">
|
||||
<Sparkles className="w-3.5 h-3.5 text-blue-600" /> Real AI Transformation Output
|
||||
</span>
|
||||
<span className="text-[10px] font-mono font-semibold text-blue-700 bg-blue-50 px-2 py-0.5 rounded-full border border-blue-200">
|
||||
Auto-sliding & scrubber
|
||||
</span>
|
||||
</div>
|
||||
<p className="text-base sm:text-lg font-display font-bold text-slate-900">
|
||||
Drag & drop your photo here, or <span className="text-blue-600 underline decoration-blue-300 underline-offset-4 group-hover:text-blue-700">browse file</span>
|
||||
</p>
|
||||
<p className="mt-1.5 text-xs font-mono text-slate-500">
|
||||
Supports JPG, PNG, WEBP up to {tool.tryIt?.limits?.maxMB || 12}MB
|
||||
</p>
|
||||
|
||||
{tool.content?.examples?.[0]?.before && tool.content?.examples?.[0]?.after ? (
|
||||
<div className="rounded-2xl overflow-hidden border border-slate-900/10 shadow-cream-sm">
|
||||
<CardBeforeAfterSlider
|
||||
beforeUrl={tool.content.examples[0].before}
|
||||
afterUrl={tool.content.examples[0].after}
|
||||
beforeLabel="ORIGINAL"
|
||||
afterLabel="AI RESULT"
|
||||
aspectRatio="aspect-[4/3] sm:aspect-[16/10]"
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div className="aspect-[16/10] bg-slate-100 rounded-2xl grid place-items-center text-slate-400 text-sm">
|
||||
Transformation preview
|
||||
</div>
|
||||
)}
|
||||
|
||||
{tool.content?.examples?.[0]?.caption && (
|
||||
<p className="text-center text-xs font-medium text-slate-500 px-1">
|
||||
{tool.content.examples[0].caption}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Quick Sample Presets */}
|
||||
<div>
|
||||
<p className="text-xs font-mono uppercase tracking-wider text-slate-500 font-semibold mb-3">
|
||||
Or inspect with an instant sample photo:
|
||||
</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 gap-2 px-4 py-2.5 rounded-xl text-xs font-semibold bg-slate-100 border border-slate-200 text-slate-700 hover:bg-blue-50 hover:border-blue-300 hover:text-blue-700 transition-all active:scale-95 shadow-sm"
|
||||
>
|
||||
<ImageIcon className="w-3.5 h-3.5 text-slate-500" />
|
||||
<span>{preset.label}</span>
|
||||
</button>
|
||||
))}
|
||||
{/* Right Column: Upload Zone & Instant Samples */}
|
||||
<div className="space-y-5">
|
||||
<div>
|
||||
<h4 className="font-display font-bold text-slate-900 text-lg sm:text-xl">
|
||||
Try with your photo
|
||||
</h4>
|
||||
<p className="text-xs text-slate-500 mt-1">
|
||||
Test {resolveLocalised(tool.name, locale)} in your browser with zero setup or sign-in.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Drag & Drop Upload Zone */}
|
||||
<div
|
||||
onDrop={handleDrop}
|
||||
onDragOver={(e) => {
|
||||
e.preventDefault();
|
||||
setIsDragOver(true);
|
||||
}}
|
||||
onDragLeave={() => setIsDragOver(false)}
|
||||
onClick={() => fileInputRef.current?.click()}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter' || e.key === ' ') {
|
||||
e.preventDefault();
|
||||
fileInputRef.current?.click();
|
||||
}
|
||||
}}
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
aria-label="Choose a JPG, PNG, or WebP photo to edit"
|
||||
className={`border-2 border-dashed rounded-2xl p-6 sm:p-8 text-center cursor-pointer transition-all duration-300 group ${
|
||||
isDragOver
|
||||
? 'border-blue-500 bg-blue-50/50 scale-[1.01]'
|
||||
: 'border-slate-300 hover:border-blue-500 bg-slate-50/60 hover:bg-blue-50/30'
|
||||
}`}
|
||||
>
|
||||
<input
|
||||
ref={fileInputRef}
|
||||
type="file"
|
||||
accept="image/jpeg,image/png,image/webp"
|
||||
className="hidden"
|
||||
onChange={(e) => e.target.files?.[0] && handleFileChange(e.target.files[0])}
|
||||
/>
|
||||
<div className="w-12 h-12 mx-auto mb-3 rounded-2xl bg-blue-50 border border-blue-100 flex items-center justify-center text-blue-600 group-hover:scale-110 transition-all duration-300 shadow-sm">
|
||||
<UploadCloud className="w-6 h-6" />
|
||||
</div>
|
||||
<p className="text-sm sm:text-base font-display font-bold text-slate-900">
|
||||
Drop your photo here, or <span className="text-blue-600 underline decoration-blue-300 underline-offset-4 group-hover:text-blue-700">browse</span>
|
||||
</p>
|
||||
<p className="mt-1 text-[11px] font-mono text-slate-500">
|
||||
JPG, PNG, WebP up to {tool.tryIt?.limits?.maxMB || 12}MB
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Quick Sample Presets */}
|
||||
<div>
|
||||
<p className="text-xs font-mono uppercase tracking-wider text-slate-500 font-semibold mb-2.5">
|
||||
Or test instantly with a sample photo:
|
||||
</p>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{samplePresets.map((preset, idx) => (
|
||||
<button
|
||||
key={idx}
|
||||
onClick={() => loadSamplePreset(preset.url)}
|
||||
className="inline-flex items-center gap-1.5 px-3 py-2 rounded-xl text-xs font-semibold bg-white border border-slate-200 text-slate-700 hover:bg-blue-50 hover:border-blue-300 hover:text-blue-700 transition-all active:scale-95 shadow-2xs"
|
||||
>
|
||||
<ImageIcon className="w-3.5 h-3.5 text-slate-400" />
|
||||
<span>{preset.label}</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { ElementType } from 'react';
|
||||
import Link from 'next/link';
|
||||
import { ArrowRight, Layers, Palette, Scissors, Smile, Sparkles } from 'lucide-react';
|
||||
import { AppItem, CategoryItem, resolveLocalised, ToolItem } from '@/types';
|
||||
import { DeferredComparison } from '@/components/ui/DeferredComparison';
|
||||
import { CardBeforeAfterSlider } from '@/components/ui/CardBeforeAfterSlider';
|
||||
|
||||
interface VerticalToolStackProps {
|
||||
context: { tools: ToolItem[]; categories: CategoryItem[]; apps: AppItem[]; locale: string };
|
||||
@@ -87,7 +87,7 @@ function ToolCard({ tool, app, locale }: { tool: ToolItem; app?: AppItem; locale
|
||||
<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 ? (
|
||||
<DeferredComparison
|
||||
<CardBeforeAfterSlider
|
||||
beforeUrl={example.before}
|
||||
afterUrl={example.after}
|
||||
beforeLabel="ORIGINAL"
|
||||
@@ -104,7 +104,7 @@ function ToolCard({ tool, app, locale }: { tool: ToolItem; app?: AppItem; locale
|
||||
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-10 rounded-full bg-white/94 px-2.5 py-1 text-[10px] font-semibold uppercase tracking-wide text-slate-700 shadow-sm backdrop-blur">
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user