feat: complete dynamic JSON-driven photo tools frontend connected to FastAPI backend
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
import React from 'react';
|
||||
import Link from 'next/link';
|
||||
import { Smartphone, Star, Check, ArrowRight, ShieldCheck } from 'lucide-react';
|
||||
import { AppItem, resolveLocalised } from '@/types';
|
||||
|
||||
interface AppCardsSectionProps {
|
||||
title?: any;
|
||||
subtitle?: any;
|
||||
apps?: AppItem[];
|
||||
layout?: 'compact' | 'detailed';
|
||||
showRating?: boolean;
|
||||
locale?: string;
|
||||
}
|
||||
|
||||
export function AppCardsSection({
|
||||
title,
|
||||
subtitle,
|
||||
apps = [],
|
||||
layout = 'compact',
|
||||
showRating = true,
|
||||
locale = 'en',
|
||||
}: AppCardsSectionProps) {
|
||||
return (
|
||||
<section className="py-12 lg:py-16 bg-slate-50/50 dark:bg-slate-950/50">
|
||||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
{(title || subtitle) && (
|
||||
<div className="text-center max-w-3xl mx-auto mb-12 space-y-3">
|
||||
{title && (
|
||||
<h2 className="text-3xl sm:text-4xl font-bold text-slate-900 dark:text-white">
|
||||
{resolveLocalised(title, locale)}
|
||||
</h2>
|
||||
)}
|
||||
{subtitle && (
|
||||
<p className="text-base text-slate-600 dark:text-slate-400">
|
||||
{resolveLocalised(subtitle, locale)}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
|
||||
{apps.map((app) => (
|
||||
<div
|
||||
key={app.id}
|
||||
className="bg-white dark:bg-slate-900 rounded-3xl p-6 border border-slate-200 dark:border-slate-800 shadow-sm hover:shadow-xl transition-all flex flex-col justify-between"
|
||||
>
|
||||
<div>
|
||||
{/* Header: Icon & Rating */}
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<div className="w-12 h-12 rounded-2xl bg-gradient-to-tr from-blue-600 to-indigo-600 flex items-center justify-center text-white shadow-md shadow-blue-500/20">
|
||||
<Smartphone className="w-6 h-6" />
|
||||
</div>
|
||||
{showRating && (
|
||||
<div className="flex items-center space-x-1 bg-amber-50 dark:bg-amber-950/50 border border-amber-200 dark:border-amber-800 px-2.5 py-1 rounded-full text-xs font-semibold text-amber-700 dark:text-amber-400">
|
||||
<Star className="w-3.5 h-3.5 fill-amber-400 text-amber-400" />
|
||||
<span>{app.rating.value}</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<h3 className="text-xl font-bold text-slate-900 dark:text-white">
|
||||
{resolveLocalised(app.name, locale)}
|
||||
</h3>
|
||||
<p className="mt-1 text-xs text-blue-600 dark:text-blue-400 font-medium">
|
||||
{resolveLocalised(app.tagline, locale)}
|
||||
</p>
|
||||
|
||||
<p className="mt-3 text-xs text-slate-600 dark:text-slate-400 leading-relaxed line-clamp-3">
|
||||
{resolveLocalised(app.description, locale)}
|
||||
</p>
|
||||
|
||||
{/* Features Checklist */}
|
||||
{app.features && app.features.length > 0 && (
|
||||
<div className="mt-4 pt-4 border-t border-slate-100 dark:border-slate-800 space-y-2">
|
||||
{app.features.slice(0, 3).map((feat, idx) => (
|
||||
<div key={idx} className="flex items-start space-x-2 text-xs text-slate-600 dark:text-slate-300">
|
||||
<Check className="w-3.5 h-3.5 text-emerald-500 shrink-0 mt-0.5" />
|
||||
<span className="line-clamp-1">{feat}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="mt-6 pt-4 border-t border-slate-100 dark:border-slate-800 space-y-3">
|
||||
{/* Mandatory Disclaimer (PRD §1.2, §9 APP-10) */}
|
||||
<p className="text-[10px] text-slate-400 dark:text-slate-500 italic text-center">
|
||||
{resolveLocalised(app.creditsNote, locale, 'Credits and purchases are specific to this app.')}
|
||||
</p>
|
||||
|
||||
<Link
|
||||
href={`/apps/${app.slug}`}
|
||||
className="w-full inline-flex items-center justify-center space-x-2 py-3 rounded-xl text-xs font-semibold text-white bg-slate-900 dark:bg-white dark:text-slate-900 hover:bg-blue-600 dark:hover:bg-blue-500 dark:hover:text-white transition-all shadow-md"
|
||||
>
|
||||
<span>Get App & Bonus</span>
|
||||
<ArrowRight className="w-3.5 h-3.5" />
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
'use client';
|
||||
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import QRCode from 'qrcode';
|
||||
import { Smartphone, QrCode, Copy, Check, Gift } from 'lucide-react';
|
||||
import { AppItem, ToolItem, resolveLocalised } from '@/types';
|
||||
|
||||
interface AppHandoffSectionProps {
|
||||
app?: AppItem;
|
||||
tool?: ToolItem | null;
|
||||
locale?: string;
|
||||
showBonus?: boolean;
|
||||
showQr?: boolean;
|
||||
}
|
||||
|
||||
export function AppHandoffSection({
|
||||
app,
|
||||
tool,
|
||||
locale = 'en',
|
||||
showBonus = true,
|
||||
showQr = true,
|
||||
}: AppHandoffSectionProps) {
|
||||
const [qrDataUrl, setQrDataUrl] = useState<string>('');
|
||||
const [copied, setCopied] = useState(false);
|
||||
|
||||
if (!app) return null;
|
||||
|
||||
const bonusCode = app.welcomeBonus?.code || 'TRYWEB50';
|
||||
const targetUrl = tool
|
||||
? `http://localhost:3000/go/${tool.slug}/${app.slug}?promo=${bonusCode}`
|
||||
: `http://localhost:3000/apps/${app.slug}?promo=${bonusCode}`;
|
||||
|
||||
useEffect(() => {
|
||||
if (showQr) {
|
||||
QRCode.toDataURL(targetUrl, {
|
||||
width: 180,
|
||||
margin: 1,
|
||||
color: {
|
||||
dark: '#0f172a',
|
||||
light: '#ffffff',
|
||||
},
|
||||
})
|
||||
.then(setQrDataUrl)
|
||||
.catch(console.error);
|
||||
}
|
||||
}, [targetUrl, showQr]);
|
||||
|
||||
const copyPromo = () => {
|
||||
navigator.clipboard.writeText(bonusCode);
|
||||
setCopied(true);
|
||||
setTimeout(() => setCopied(false), 2000);
|
||||
};
|
||||
|
||||
return (
|
||||
<section className="py-12 bg-gradient-to-br from-blue-50/50 via-white to-teal-50/50 dark:from-slate-900 dark:via-slate-900 dark:to-slate-950 border-y border-slate-200 dark:border-slate-800">
|
||||
<div className="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div className="bg-white dark:bg-slate-900 rounded-3xl p-6 sm:p-10 border border-slate-200 dark:border-slate-800 shadow-xl flex flex-col md:flex-row items-center justify-between gap-8">
|
||||
{/* Left Column: Copy & Store CTA */}
|
||||
<div className="space-y-4 max-w-xl">
|
||||
<div className="inline-flex items-center space-x-2 px-3 py-1 rounded-full bg-blue-50 dark:bg-blue-950 text-blue-600 dark:text-blue-400 text-xs font-semibold">
|
||||
<Smartphone className="w-3.5 h-3.5" />
|
||||
<span>Native iOS & Android App</span>
|
||||
</div>
|
||||
|
||||
<h3 className="text-2xl sm:text-3xl font-extrabold text-slate-900 dark:text-white">
|
||||
{tool
|
||||
? `Continue in ${resolveLocalised(app.name, locale)} with 4K Lossless Export`
|
||||
: `Download ${resolveLocalised(app.name, locale)}`}
|
||||
</h3>
|
||||
|
||||
<p className="text-sm text-slate-600 dark:text-slate-400 leading-relaxed">
|
||||
Experience zero-latency hardware accelerated neural processing, batch photoshoot enhancement, and professional fine-tuning sliders.
|
||||
</p>
|
||||
|
||||
{/* Welcome Bonus Promo Banner */}
|
||||
{showBonus && (
|
||||
<div className="p-4 rounded-2xl bg-amber-50 dark:bg-amber-950/40 border border-amber-200 dark:border-amber-800/60 flex items-center justify-between">
|
||||
<div className="flex items-center space-x-3">
|
||||
<div className="w-10 h-10 rounded-xl bg-amber-100 dark:bg-amber-900/60 flex items-center justify-center text-amber-600">
|
||||
<Gift className="w-5 h-5" />
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-xs font-bold text-slate-900 dark:text-white">
|
||||
{app.welcomeBonus?.title || '50 Free HD Export Credits'}
|
||||
</p>
|
||||
<p className="text-[11px] text-slate-500 dark:text-slate-400">
|
||||
Claim promo code on first launch
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
onClick={copyPromo}
|
||||
className="inline-flex items-center space-x-1.5 px-3 py-1.5 rounded-lg text-xs font-mono font-bold bg-white dark:bg-slate-900 border border-amber-300 dark:border-amber-700 text-amber-800 dark:text-amber-300 hover:bg-amber-100 dark:hover:bg-amber-950 transition-colors"
|
||||
>
|
||||
{copied ? <Check className="w-3.5 h-3.5 text-emerald-600" /> : <Copy className="w-3.5 h-3.5" />}
|
||||
<span>{bonusCode}</span>
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Store Download Buttons */}
|
||||
<div className="flex flex-wrap items-center gap-3 pt-2">
|
||||
<a
|
||||
href={app.stores.android?.url || '#'}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="px-5 py-2.5 rounded-xl text-xs font-semibold text-white bg-slate-900 hover:bg-slate-800 dark:bg-white dark:text-slate-900 dark:hover:bg-slate-100 shadow-md transition-all flex items-center space-x-2"
|
||||
>
|
||||
<span>Google Play</span>
|
||||
</a>
|
||||
<a
|
||||
href={app.stores.ios?.url || '#'}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="px-5 py-2.5 rounded-xl text-xs font-semibold text-white bg-slate-900 hover:bg-slate-800 dark:bg-white dark:text-slate-900 dark:hover:bg-slate-100 shadow-md transition-all flex items-center space-x-2"
|
||||
>
|
||||
<span>Apple App Store</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{/* Disclaimer */}
|
||||
<p className="text-[11px] text-slate-400 dark:text-slate-500 italic">
|
||||
{resolveLocalised(app.creditsNote, locale, 'Credits and in-app purchases are specific to this app.')}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Right Column: QR Code Handoff (PRD §9 APP-05) */}
|
||||
{showQr && qrDataUrl && (
|
||||
<div className="text-center p-6 rounded-2xl bg-slate-50 dark:bg-slate-950/60 border border-slate-200 dark:border-slate-800 shrink-0">
|
||||
<div className="p-2 bg-white rounded-xl shadow-inner inline-block">
|
||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||
<img src={qrDataUrl} alt="Scan QR code to install app" className="w-36 h-36" />
|
||||
</div>
|
||||
<div className="mt-3 flex items-center justify-center space-x-1.5 text-xs text-slate-600 dark:text-slate-400 font-medium">
|
||||
<QrCode className="w-4 h-4 text-blue-600" />
|
||||
<span>Scan with phone camera</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
'use client';
|
||||
|
||||
import React, { useState } from 'react';
|
||||
import Link from 'next/link';
|
||||
import { HelpCircle, CheckCircle2, ArrowRight, Sparkles, Smartphone } from 'lucide-react';
|
||||
import { AppItem, resolveLocalised } from '@/types';
|
||||
|
||||
interface AppPickerSectionProps {
|
||||
title?: any;
|
||||
subtitle?: any;
|
||||
apps?: AppItem[];
|
||||
locale?: string;
|
||||
}
|
||||
|
||||
export function AppPickerSection({
|
||||
title,
|
||||
subtitle,
|
||||
apps = [],
|
||||
locale = 'en',
|
||||
}: AppPickerSectionProps) {
|
||||
const [photoGoal, setPhotoGoal] = useState<string>('portrait');
|
||||
const [step, setStep] = useState<number>(1);
|
||||
|
||||
const goalOptions = [
|
||||
{
|
||||
id: 'portrait',
|
||||
title: 'Portraits, Selfies & Skin Beauty',
|
||||
desc: 'Acne, blemish removal, teeth whitening, eye redness',
|
||||
appSlug: 'portrait-app',
|
||||
},
|
||||
{
|
||||
id: 'restoration',
|
||||
title: 'Blurry, Damaged or Old Photos',
|
||||
desc: 'Restoring old photos, fixing scratches, sharpening faces',
|
||||
appSlug: 'photo-enhancer-pro',
|
||||
},
|
||||
{
|
||||
id: 'cutout',
|
||||
title: 'Background Cutout & Object Removal',
|
||||
desc: 'Transparent PNGs, product photography, erasing strangers',
|
||||
appSlug: 'bg-cleaner-app',
|
||||
},
|
||||
{
|
||||
id: 'art',
|
||||
title: 'Anime, Cartoon & Vintage Film Art',
|
||||
desc: 'Cartoon avatars, Polaroid aesthetic, anime stylization',
|
||||
appSlug: 'art-studio-app',
|
||||
},
|
||||
];
|
||||
|
||||
const matchedGoal = goalOptions.find((g) => g.id === photoGoal) || goalOptions[0];
|
||||
const recommendedApp = apps.find((a) => a.slug === matchedGoal.appSlug) || apps[0];
|
||||
|
||||
return (
|
||||
<section className="py-12 lg:py-16 bg-white dark:bg-slate-900 border-t border-slate-200 dark:border-slate-800">
|
||||
<div className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div className="text-center space-y-3 mb-10">
|
||||
<div className="inline-flex items-center space-x-2 px-3 py-1 rounded-full bg-blue-50 dark:bg-blue-950 text-blue-600 dark:text-blue-400 text-xs font-semibold">
|
||||
<HelpCircle className="w-3.5 h-3.5" />
|
||||
<span>Interactive App Matcher</span>
|
||||
</div>
|
||||
<h2 className="text-3xl font-bold text-slate-900 dark:text-white">
|
||||
{resolveLocalised(title, locale, 'Not Sure Which App You Need?')}
|
||||
</h2>
|
||||
<p className="text-sm text-slate-600 dark:text-slate-400">
|
||||
{resolveLocalised(subtitle, locale, 'Select your photo editing goal to find your tailored mobile tool.')}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="bg-slate-50 dark:bg-slate-950 rounded-3xl p-6 sm:p-8 border border-slate-200 dark:border-slate-800 shadow-md space-y-8">
|
||||
<div>
|
||||
<label className="block text-xs font-bold uppercase tracking-wider text-slate-500 dark:text-slate-400 mb-4">
|
||||
Step 1: What would you like to edit?
|
||||
</label>
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
||||
{goalOptions.map((opt) => (
|
||||
<button
|
||||
key={opt.id}
|
||||
onClick={() => setPhotoGoal(opt.id)}
|
||||
className={`p-4 rounded-2xl border text-left transition-all ${
|
||||
photoGoal === opt.id
|
||||
? 'border-blue-600 bg-white dark:bg-slate-900 shadow-md ring-2 ring-blue-500/20'
|
||||
: 'border-slate-200 dark:border-slate-800 hover:border-slate-300 dark:hover:border-slate-700 bg-white/60 dark:bg-slate-900/60'
|
||||
}`}
|
||||
>
|
||||
<p className="font-semibold text-sm text-slate-900 dark:text-white">
|
||||
{opt.title}
|
||||
</p>
|
||||
<p className="text-xs text-slate-500 dark:text-slate-400 mt-1">
|
||||
{opt.desc}
|
||||
</p>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Recommended Result */}
|
||||
{recommendedApp && (
|
||||
<div className="pt-6 border-t border-slate-200 dark:border-slate-800 flex flex-col sm:flex-row items-center justify-between gap-6 bg-gradient-to-r from-blue-50/50 to-teal-50/50 dark:from-blue-950/20 dark:to-teal-950/20 p-6 rounded-2xl">
|
||||
<div className="space-y-1">
|
||||
<span className="text-[11px] font-bold uppercase tracking-wider text-emerald-600 dark:text-emerald-400">
|
||||
Recommended Match:
|
||||
</span>
|
||||
<h4 className="text-xl font-bold text-slate-900 dark:text-white">
|
||||
{resolveLocalised(recommendedApp.name, locale)}
|
||||
</h4>
|
||||
<p className="text-xs text-slate-600 dark:text-slate-400">
|
||||
{resolveLocalised(recommendedApp.tagline, locale)}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Link
|
||||
href={`/apps/${recommendedApp.slug}`}
|
||||
className="shrink-0 inline-flex items-center space-x-2 px-5 py-3 rounded-xl text-xs font-semibold text-white bg-blue-600 hover:bg-blue-700 shadow-md shadow-blue-500/20 transition-all hover:scale-105"
|
||||
>
|
||||
<span>View App & Get 50 Bonus Credits</span>
|
||||
<ArrowRight className="w-4 h-4" />
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
import React from 'react';
|
||||
import Link from 'next/link';
|
||||
import { Globe, Smartphone, ArrowRight } from 'lucide-react';
|
||||
import { ToolItem, AppItem, resolveLocalised } from '@/types';
|
||||
|
||||
interface AvailabilitySectionProps {
|
||||
tool?: ToolItem;
|
||||
homeApp?: AppItem | null;
|
||||
locale?: string;
|
||||
}
|
||||
|
||||
export function AvailabilitySection({ tool, homeApp, locale = 'en' }: AvailabilitySectionProps) {
|
||||
if (!tool) return null;
|
||||
return (
|
||||
<section className="py-8 bg-white dark:bg-slate-900 border-t border-slate-200 dark:border-slate-800">
|
||||
<div className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<h4 className="text-xs font-bold uppercase tracking-wider text-slate-500 dark:text-slate-400 mb-4 text-center">
|
||||
Platform Availability for {resolveLocalised(tool.name, locale)}
|
||||
</h4>
|
||||
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
{/* Web Try */}
|
||||
<div className="p-4 rounded-2xl border border-slate-200 dark:border-slate-800 bg-slate-50 dark:bg-slate-950 flex items-center justify-between">
|
||||
<div className="flex items-center space-x-3">
|
||||
<div className="w-10 h-10 rounded-xl bg-blue-50 dark:bg-blue-950 text-blue-600 flex items-center justify-center">
|
||||
<Globe className="w-5 h-5" />
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-sm font-bold text-slate-900 dark:text-white">Web Browser</p>
|
||||
<p className="text-xs text-slate-500 dark:text-slate-400">Free online try • Standard HD</p>
|
||||
</div>
|
||||
</div>
|
||||
<span className="text-xs font-semibold text-emerald-600 dark:text-emerald-400 bg-emerald-50 dark:bg-emerald-950/60 px-2.5 py-1 rounded-md">
|
||||
Live
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Home App */}
|
||||
{homeApp && (
|
||||
<Link
|
||||
href={`/go/${tool.slug}/${homeApp.slug}`}
|
||||
className="p-4 rounded-2xl border border-blue-200 dark:border-blue-900 bg-blue-50/40 dark:bg-blue-950/30 hover:border-blue-500 transition-all flex items-center justify-between group"
|
||||
>
|
||||
<div className="flex items-center space-x-3">
|
||||
<div className="w-10 h-10 rounded-xl bg-blue-600 text-white flex items-center justify-center shadow-md">
|
||||
<Smartphone className="w-5 h-5" />
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-sm font-bold text-slate-900 dark:text-white group-hover:text-blue-600 transition-colors">
|
||||
{resolveLocalised(homeApp.name, locale)}
|
||||
</p>
|
||||
<p className="text-xs text-blue-600 dark:text-blue-400">Home App • 4K Lossless & Batch</p>
|
||||
</div>
|
||||
</div>
|
||||
<ArrowRight className="w-4 h-4 text-blue-600 group-hover:translate-x-1 transition-transform" />
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
import React from 'react';
|
||||
import { resolveLocalised } from '@/types';
|
||||
import { BeforeAfterSlider } from '../ui/BeforeAfterSlider';
|
||||
|
||||
interface BeforeAfterSectionProps {
|
||||
title?: any;
|
||||
subtitle?: any;
|
||||
items?: Array<{
|
||||
before: string;
|
||||
after: string;
|
||||
alt?: any;
|
||||
caption?: string;
|
||||
}>;
|
||||
locale?: string;
|
||||
}
|
||||
|
||||
export function BeforeAfterSection({
|
||||
title,
|
||||
subtitle,
|
||||
items = [],
|
||||
locale = 'en',
|
||||
}: BeforeAfterSectionProps) {
|
||||
if (!items || items.length === 0) return null;
|
||||
|
||||
return (
|
||||
<section className="py-12 lg:py-16">
|
||||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
{(title || subtitle) && (
|
||||
<div className="text-center max-w-3xl mx-auto mb-10 space-y-3">
|
||||
{title && (
|
||||
<h2 className="text-3xl sm:text-4xl font-bold text-slate-900 dark:text-white">
|
||||
{resolveLocalised(title, locale)}
|
||||
</h2>
|
||||
)}
|
||||
{subtitle && (
|
||||
<p className="text-base text-slate-600 dark:text-slate-400">
|
||||
{resolveLocalised(subtitle, locale)}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className={`grid grid-cols-1 ${items.length > 1 ? 'md:grid-cols-2' : 'max-w-2xl mx-auto'} gap-8`}>
|
||||
{items.map((item, idx) => (
|
||||
<div key={idx} className="space-y-2">
|
||||
<BeforeAfterSlider
|
||||
beforeUrl={item.before}
|
||||
afterUrl={item.after}
|
||||
caption={item.caption}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
import React from 'react';
|
||||
import Link from 'next/link';
|
||||
import { ArrowRight } from 'lucide-react';
|
||||
import { resolveLocalised } from '@/types';
|
||||
|
||||
interface CtaBannerSectionProps {
|
||||
title?: any;
|
||||
subtitle?: any;
|
||||
primaryCta?: {
|
||||
label: any;
|
||||
href: string;
|
||||
};
|
||||
secondaryCta?: {
|
||||
label: any;
|
||||
href: string;
|
||||
};
|
||||
locale?: string;
|
||||
}
|
||||
|
||||
export function CtaBannerSection({
|
||||
title,
|
||||
subtitle,
|
||||
primaryCta,
|
||||
secondaryCta,
|
||||
locale = 'en',
|
||||
}: CtaBannerSectionProps) {
|
||||
return (
|
||||
<section className="py-12 lg:py-16">
|
||||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div className="rounded-3xl bg-gradient-to-r from-blue-600 via-indigo-600 to-teal-600 p-8 sm:p-12 text-center text-white shadow-2xl relative overflow-hidden">
|
||||
<div className="relative z-10 max-w-2xl mx-auto space-y-4">
|
||||
{title && (
|
||||
<h2 className="text-3xl sm:text-4xl font-extrabold tracking-tight">
|
||||
{resolveLocalised(title, locale)}
|
||||
</h2>
|
||||
)}
|
||||
{subtitle && (
|
||||
<p className="text-base text-blue-100">
|
||||
{resolveLocalised(subtitle, locale)}
|
||||
</p>
|
||||
)}
|
||||
|
||||
<div className="pt-4 flex flex-wrap items-center justify-center gap-4">
|
||||
{primaryCta && (
|
||||
<Link
|
||||
href={primaryCta.href}
|
||||
className="px-6 py-3.5 rounded-xl text-sm font-semibold text-slate-900 bg-white hover:bg-slate-100 shadow-md transition-all hover:scale-105 active:scale-95"
|
||||
>
|
||||
{resolveLocalised(primaryCta.label, locale)}
|
||||
</Link>
|
||||
)}
|
||||
{secondaryCta && (
|
||||
<Link
|
||||
href={secondaryCta.href}
|
||||
className="px-6 py-3.5 rounded-xl text-sm font-semibold text-white border border-white/40 hover:bg-white/10 transition-colors"
|
||||
>
|
||||
{resolveLocalised(secondaryCta.label, locale)}
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
'use client';
|
||||
|
||||
import React, { useState } from 'react';
|
||||
import { ChevronDown } from 'lucide-react';
|
||||
import { resolveLocalised } from '@/types';
|
||||
|
||||
interface FaqSectionProps {
|
||||
title?: any;
|
||||
items?: Array<{
|
||||
q: string;
|
||||
a: string;
|
||||
}>;
|
||||
locale?: string;
|
||||
}
|
||||
|
||||
export function FaqSection({
|
||||
title,
|
||||
items = [],
|
||||
locale = 'en',
|
||||
}: FaqSectionProps) {
|
||||
const [openIndex, setOpenIndex] = useState<number | null>(0);
|
||||
|
||||
if (!items || items.length === 0) return null;
|
||||
|
||||
return (
|
||||
<section className="py-12 lg:py-16">
|
||||
<div className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
{title && (
|
||||
<h2 className="text-3xl font-bold text-slate-900 dark:text-white mb-8 text-center">
|
||||
{resolveLocalised(title, locale)}
|
||||
</h2>
|
||||
)}
|
||||
|
||||
<div className="space-y-3">
|
||||
{items.map((item, idx) => {
|
||||
const isOpen = openIndex === idx;
|
||||
return (
|
||||
<div
|
||||
key={idx}
|
||||
className="rounded-2xl border border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-900 overflow-hidden shadow-sm transition-all"
|
||||
>
|
||||
<button
|
||||
onClick={() => setOpenIndex(isOpen ? null : idx)}
|
||||
className="w-full p-5 text-left flex items-center justify-between gap-4 font-semibold text-slate-900 dark:text-white hover:text-blue-600 dark:hover:text-blue-400 transition-colors"
|
||||
>
|
||||
<span className="text-base">{item.q}</span>
|
||||
<ChevronDown
|
||||
className={`w-5 h-5 text-slate-400 shrink-0 transition-transform duration-200 ${
|
||||
isOpen ? 'rotate-180 text-blue-600' : ''
|
||||
}`}
|
||||
/>
|
||||
</button>
|
||||
|
||||
{isOpen && (
|
||||
<div className="px-5 pb-5 text-sm text-slate-600 dark:text-slate-400 leading-relaxed border-t border-slate-100 dark:border-slate-800/60 pt-3">
|
||||
{item.a}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import React from 'react';
|
||||
import { Check } from 'lucide-react';
|
||||
import { resolveLocalised } from '@/types';
|
||||
|
||||
interface FeatureListSectionProps {
|
||||
title?: any;
|
||||
items?: string[];
|
||||
locale?: string;
|
||||
}
|
||||
|
||||
export function FeatureListSection({
|
||||
title,
|
||||
items = [],
|
||||
locale = 'en',
|
||||
}: FeatureListSectionProps) {
|
||||
if (!items || items.length === 0) return null;
|
||||
|
||||
return (
|
||||
<section className="py-12 bg-white dark:bg-slate-900">
|
||||
<div className="max-w-5xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
{title && (
|
||||
<h3 className="text-2xl font-bold text-slate-900 dark:text-white mb-8 text-center">
|
||||
{resolveLocalised(title, locale)}
|
||||
</h3>
|
||||
)}
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
{items.map((feature, idx) => (
|
||||
<div
|
||||
key={idx}
|
||||
className="flex items-start space-x-3 p-4 rounded-2xl bg-slate-50 dark:bg-slate-950/50 border border-slate-200 dark:border-slate-800"
|
||||
>
|
||||
<div className="w-5 h-5 rounded-full bg-emerald-100 dark:bg-emerald-950/60 text-emerald-600 flex items-center justify-center shrink-0 mt-0.5">
|
||||
<Check className="w-3 h-3" />
|
||||
</div>
|
||||
<span className="text-sm font-medium text-slate-800 dark:text-slate-200">
|
||||
{feature}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
import React from 'react';
|
||||
import Link from 'next/link';
|
||||
import { Sparkles, ArrowRight, Smartphone } from 'lucide-react';
|
||||
import { resolveLocalised, ToolItem, AppItem, VariantSpec } from '@/types';
|
||||
import { TryItWidget } from './TryItWidget';
|
||||
|
||||
interface HeroSectionProps {
|
||||
title?: any;
|
||||
subtitle?: any;
|
||||
variant?: string;
|
||||
badge?: any;
|
||||
tryIt?: {
|
||||
toolRef: string;
|
||||
};
|
||||
tool?: ToolItem | null;
|
||||
homeApp?: AppItem | null;
|
||||
variants?: VariantSpec[];
|
||||
locale?: string;
|
||||
}
|
||||
|
||||
export function HeroSection({
|
||||
title,
|
||||
subtitle,
|
||||
variant = 'centered',
|
||||
badge,
|
||||
tool,
|
||||
homeApp,
|
||||
variants = [],
|
||||
locale = 'en',
|
||||
}: HeroSectionProps) {
|
||||
const resolvedTitle = resolveLocalised(title, locale);
|
||||
const resolvedSubtitle = resolveLocalised(subtitle, locale);
|
||||
const resolvedBadge = resolveLocalised(badge, locale);
|
||||
|
||||
if (variant === 'tryit' && tool) {
|
||||
return (
|
||||
<section className="relative overflow-hidden pt-8 pb-16 lg:pt-14 lg:pb-24">
|
||||
{/* Ambient Gradient Background Glow */}
|
||||
<div className="absolute top-0 left-1/2 -translate-x-1/2 w-full max-w-7xl h-96 bg-gradient-to-tr from-blue-500/10 via-teal-500/10 to-indigo-500/10 blur-3xl pointer-events-none -z-10" />
|
||||
|
||||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div className="text-center max-w-3xl mx-auto space-y-4 mb-10">
|
||||
{resolvedBadge && (
|
||||
<div className="inline-flex items-center space-x-2 px-3.5 py-1.5 rounded-full bg-blue-50 dark:bg-blue-950/60 border border-blue-200 dark:border-blue-800 text-xs font-semibold text-blue-700 dark:text-blue-300">
|
||||
<Sparkles className="w-3.5 h-3.5 text-blue-500" />
|
||||
<span>{resolvedBadge}</span>
|
||||
</div>
|
||||
)}
|
||||
<h1 className="text-4xl sm:text-5xl lg:text-6xl font-extrabold text-slate-900 dark:text-white tracking-tight leading-tight">
|
||||
{resolvedTitle}
|
||||
</h1>
|
||||
<p className="text-lg text-slate-600 dark:text-slate-300 leading-relaxed">
|
||||
{resolvedSubtitle}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Embedded Interactive Try-It Widget */}
|
||||
<div className="max-w-4xl mx-auto">
|
||||
<TryItWidget
|
||||
tool={tool}
|
||||
homeApp={homeApp}
|
||||
variants={variants}
|
||||
locale={locale}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
// Centered or Standard Hero
|
||||
return (
|
||||
<section className="relative overflow-hidden pt-12 pb-16 lg:pt-20 lg:pb-24 text-center">
|
||||
<div className="absolute top-0 left-1/2 -translate-x-1/2 w-full max-w-7xl h-80 bg-gradient-to-b from-blue-500/10 to-transparent blur-3xl pointer-events-none -z-10" />
|
||||
|
||||
<div className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 space-y-6">
|
||||
{resolvedBadge && (
|
||||
<div className="inline-flex items-center space-x-2 px-3.5 py-1.5 rounded-full bg-blue-50 dark:bg-blue-950/60 border border-blue-200 dark:border-blue-800 text-xs font-semibold text-blue-700 dark:text-blue-300">
|
||||
<Sparkles className="w-3.5 h-3.5" />
|
||||
<span>{resolvedBadge}</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<h1 className="text-4xl sm:text-5xl lg:text-6xl font-extrabold text-slate-900 dark:text-white tracking-tight leading-tight">
|
||||
{resolvedTitle}
|
||||
</h1>
|
||||
|
||||
<p className="text-lg sm:text-xl text-slate-600 dark:text-slate-300 max-w-2xl mx-auto">
|
||||
{resolvedSubtitle}
|
||||
</p>
|
||||
|
||||
<div className="flex flex-wrap items-center justify-center gap-4 pt-4">
|
||||
<Link
|
||||
href="/tools"
|
||||
className="inline-flex items-center space-x-2 px-6 py-3.5 rounded-xl font-semibold text-white bg-blue-600 hover:bg-blue-700 shadow-md shadow-blue-500/20 transition-all hover:scale-105 active:scale-95"
|
||||
>
|
||||
<span>Explore All Free Tools</span>
|
||||
<ArrowRight className="w-4 h-4" />
|
||||
</Link>
|
||||
<Link
|
||||
href="/apps"
|
||||
className="inline-flex items-center space-x-2 px-6 py-3.5 rounded-xl font-semibold text-slate-700 dark:text-slate-200 bg-slate-100 dark:bg-slate-800 hover:bg-slate-200 dark:hover:bg-slate-700 transition-colors"
|
||||
>
|
||||
<Smartphone className="w-4 h-4 text-slate-500" />
|
||||
<span>Mobile Apps Suite</span>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import React from 'react';
|
||||
import { Info, AlertTriangle, CheckCircle2 } from 'lucide-react';
|
||||
import { resolveLocalised } from '@/types';
|
||||
|
||||
interface NoticeSectionProps {
|
||||
text?: any;
|
||||
level?: 'info' | 'warning' | 'success';
|
||||
locale?: string;
|
||||
}
|
||||
|
||||
export function NoticeSection({ text, level = 'info', locale = 'en' }: NoticeSectionProps) {
|
||||
const resolvedText = resolveLocalised(text, locale);
|
||||
if (!resolvedText) return null;
|
||||
|
||||
const styles = {
|
||||
info: 'bg-blue-50 text-blue-800 border-blue-200 dark:bg-blue-950/40 dark:text-blue-300 dark:border-blue-900',
|
||||
warning: 'bg-amber-50 text-amber-800 border-amber-200 dark:bg-amber-950/40 dark:text-amber-300 dark:border-amber-900',
|
||||
success: 'bg-emerald-50 text-emerald-800 border-emerald-200 dark:bg-emerald-950/40 dark:text-emerald-300 dark:border-emerald-900',
|
||||
};
|
||||
|
||||
const Icon = level === 'warning' ? AlertTriangle : level === 'success' ? CheckCircle2 : Info;
|
||||
|
||||
return (
|
||||
<div className="max-w-4xl mx-auto px-4 sm:px-6 my-4">
|
||||
<div className={`p-4 rounded-2xl border flex items-center space-x-3 text-xs font-medium ${styles[level]}`}>
|
||||
<Icon className="w-4 h-4 shrink-0" />
|
||||
<span>{resolvedText}</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import React from 'react';
|
||||
import { ShieldCheck, Info } from 'lucide-react';
|
||||
import { resolveLocalised } from '@/types';
|
||||
|
||||
interface PricingExplainerSectionProps {
|
||||
title?: any;
|
||||
notes?: string[];
|
||||
locale?: string;
|
||||
}
|
||||
|
||||
export function PricingExplainerSection({
|
||||
title,
|
||||
notes = [],
|
||||
locale = 'en',
|
||||
}: PricingExplainerSectionProps) {
|
||||
return (
|
||||
<section className="py-12 bg-white dark:bg-slate-900">
|
||||
<div className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div className="bg-gradient-to-br from-blue-50/60 to-slate-50 dark:from-blue-950/30 dark:to-slate-950 rounded-3xl p-6 sm:p-8 border border-blue-100 dark:border-blue-900/60 space-y-6">
|
||||
<div className="flex items-center space-x-3">
|
||||
<div className="w-10 h-10 rounded-xl bg-blue-600 text-white flex items-center justify-center">
|
||||
<ShieldCheck className="w-5 h-5" />
|
||||
</div>
|
||||
<div>
|
||||
<h3 className="text-xl font-bold text-slate-900 dark:text-white">
|
||||
{resolveLocalised(title, locale, 'How App Pricing & Credits Work')}
|
||||
</h3>
|
||||
<p className="text-xs text-slate-500 dark:text-slate-400">
|
||||
Transparent and simple: no surprise auto-renewing web subscriptions.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
{notes.map((note, idx) => (
|
||||
<div
|
||||
key={idx}
|
||||
className="flex items-start space-x-3 p-4 rounded-2xl bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-800"
|
||||
>
|
||||
<Info className="w-4 h-4 text-blue-600 shrink-0 mt-0.5" />
|
||||
<span className="text-xs text-slate-700 dark:text-slate-300 leading-relaxed">
|
||||
{note}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
import React from 'react';
|
||||
import Link from 'next/link';
|
||||
import { ArrowRight, Wand2 } from 'lucide-react';
|
||||
import { ToolItem, resolveLocalised } from '@/types';
|
||||
|
||||
interface RelatedToolsSectionProps {
|
||||
tools?: ToolItem[];
|
||||
locale?: string;
|
||||
}
|
||||
|
||||
export function RelatedToolsSection({ tools = [], locale = 'en' }: RelatedToolsSectionProps) {
|
||||
if (!tools || tools.length === 0) return null;
|
||||
|
||||
return (
|
||||
<section className="py-12 bg-slate-50/50 dark:bg-slate-950/40 border-t border-slate-200 dark:border-slate-800">
|
||||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div className="flex items-center justify-between mb-8">
|
||||
<div>
|
||||
<h3 className="text-2xl font-bold text-slate-900 dark:text-white">
|
||||
Related AI Tools
|
||||
</h3>
|
||||
<p className="text-xs text-slate-500 dark:text-slate-400">
|
||||
Explore more tools to enhance your photo editing workflow
|
||||
</p>
|
||||
</div>
|
||||
<Link
|
||||
href="/tools"
|
||||
className="text-xs font-semibold text-blue-600 dark:text-blue-400 hover:underline flex items-center space-x-1"
|
||||
>
|
||||
<span>View all tools</span>
|
||||
<ArrowRight className="w-3.5 h-3.5" />
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6">
|
||||
{tools.map((tool) => (
|
||||
<Link
|
||||
key={tool.id}
|
||||
href={`/tools/${tool.slug}`}
|
||||
className="group p-5 rounded-2xl bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-800 shadow-sm hover:shadow-md hover:border-blue-500 transition-all flex flex-col justify-between"
|
||||
>
|
||||
<div>
|
||||
<div className="w-8 h-8 rounded-lg bg-blue-50 dark:bg-blue-950 text-blue-600 flex items-center justify-center mb-3 group-hover:scale-110 transition-transform">
|
||||
<Wand2 className="w-4 h-4" />
|
||||
</div>
|
||||
<h4 className="font-bold text-slate-900 dark:text-white text-sm group-hover:text-blue-600 transition-colors">
|
||||
{resolveLocalised(tool.name, locale)}
|
||||
</h4>
|
||||
<p className="mt-1 text-xs text-slate-500 dark:text-slate-400 line-clamp-2">
|
||||
{resolveLocalised(tool.summary, locale)}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="mt-4 pt-3 border-t border-slate-100 dark:border-slate-800 text-xs font-medium text-blue-600 dark:text-blue-400 flex items-center justify-between">
|
||||
<span>Try free</span>
|
||||
<ArrowRight className="w-3 h-3 group-hover:translate-x-1 transition-transform" />
|
||||
</div>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import React from 'react';
|
||||
|
||||
interface RichTextSectionProps {
|
||||
markdown?: string;
|
||||
}
|
||||
|
||||
export function RichTextSection({ markdown = '' }: RichTextSectionProps) {
|
||||
// Simple, safe markdown to HTML parser for headers, lists, and paragraphs
|
||||
const renderFormatted = (text: string) => {
|
||||
const lines = text.split('\n');
|
||||
return lines.map((line, idx) => {
|
||||
if (line.startsWith('### ')) {
|
||||
return (
|
||||
<h3 key={idx} className="text-xl font-bold text-slate-900 dark:text-white mt-6 mb-3">
|
||||
{line.replace('### ', '')}
|
||||
</h3>
|
||||
);
|
||||
}
|
||||
if (line.startsWith('1. ') || line.startsWith('2. ') || line.startsWith('3. ') || line.startsWith('4. ')) {
|
||||
return (
|
||||
<div key={idx} className="flex items-start space-x-2 my-2 text-sm text-slate-700 dark:text-slate-300">
|
||||
<span className="font-bold text-blue-600">{line.slice(0, 3)}</span>
|
||||
<span>{line.slice(3)}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
if (line.trim().length === 0) {
|
||||
return <div key={idx} className="h-2" />;
|
||||
}
|
||||
return (
|
||||
<p key={idx} className="text-sm text-slate-600 dark:text-slate-400 leading-relaxed my-2">
|
||||
{line}
|
||||
</p>
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<section className="py-12 bg-white dark:bg-slate-900">
|
||||
<div className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div className="bg-slate-50 dark:bg-slate-950/60 rounded-3xl p-6 sm:p-10 border border-slate-200 dark:border-slate-800 shadow-sm">
|
||||
{renderFormatted(markdown)}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
import React from 'react';
|
||||
import { SectionConfig, ToolItem, AppItem, CategoryItem, VariantSpec } from '@/types';
|
||||
import { resolveBindings, isSectionVisible } from '@/lib/config/bindings';
|
||||
|
||||
import { HeroSection } from './HeroSection';
|
||||
import { ToolGridSection } from './ToolGridSection';
|
||||
import { TryItWidget } from './TryItWidget';
|
||||
import { BeforeAfterSection } from './BeforeAfterSection';
|
||||
import { AppCardsSection } from './AppCardsSection';
|
||||
import { AppHandoffSection } from './AppHandoffSection';
|
||||
import { AvailabilitySection } from './AvailabilitySection';
|
||||
import { AppPickerSection } from './AppPickerSection';
|
||||
import { StepsSection } from './StepsSection';
|
||||
import { FeatureListSection } from './FeatureListSection';
|
||||
import { FaqSection } from './FaqSection';
|
||||
import { StatsSection } from './StatsSection';
|
||||
import { PricingExplainerSection } from './PricingExplainerSection';
|
||||
import { RelatedToolsSection } from './RelatedToolsSection';
|
||||
import { RichTextSection } from './RichTextSection';
|
||||
import { CtaBannerSection } from './CtaBannerSection';
|
||||
import { NoticeSection } from './NoticeSection';
|
||||
|
||||
interface SectionRendererProps {
|
||||
section: SectionConfig;
|
||||
context: {
|
||||
site?: any;
|
||||
page?: any;
|
||||
tool?: ToolItem | null;
|
||||
app?: AppItem | null;
|
||||
homeApp?: AppItem | null;
|
||||
tools?: ToolItem[];
|
||||
apps?: AppItem[];
|
||||
categories?: CategoryItem[];
|
||||
variants?: VariantSpec[];
|
||||
relatedTools?: ToolItem[];
|
||||
locale?: string;
|
||||
device?: 'mobile' | 'desktop';
|
||||
};
|
||||
}
|
||||
|
||||
export function SectionRenderer({ section, context }: SectionRendererProps) {
|
||||
const locale = context.locale || 'en';
|
||||
|
||||
// Visibility Check (PRD §5.2, §5.3 CFG-09)
|
||||
if (!isSectionVisible(section, { device: context.device, locale })) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Resolve bindings on section props (PRD §5.2)
|
||||
const resolvedProps = resolveBindings(section.props || {}, context, locale);
|
||||
|
||||
switch (section.type) {
|
||||
case 'hero':
|
||||
return (
|
||||
<HeroSection
|
||||
{...resolvedProps}
|
||||
variant={section.variant}
|
||||
tool={context.tool}
|
||||
homeApp={context.homeApp}
|
||||
variants={context.variants}
|
||||
locale={locale}
|
||||
/>
|
||||
);
|
||||
|
||||
case 'toolGrid':
|
||||
return (
|
||||
<ToolGridSection
|
||||
{...resolvedProps}
|
||||
tools={context.tools}
|
||||
categories={context.categories}
|
||||
apps={context.apps}
|
||||
locale={locale}
|
||||
/>
|
||||
);
|
||||
|
||||
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">
|
||||
<TryItWidget
|
||||
tool={context.tool}
|
||||
homeApp={context.homeApp}
|
||||
variants={context.variants}
|
||||
locale={locale}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
case 'beforeAfter':
|
||||
return <BeforeAfterSection {...resolvedProps} locale={locale} />;
|
||||
|
||||
case 'appCards':
|
||||
return (
|
||||
<AppCardsSection
|
||||
{...resolvedProps}
|
||||
apps={context.apps}
|
||||
layout={section.variant as any}
|
||||
locale={locale}
|
||||
/>
|
||||
);
|
||||
|
||||
case 'appHandoff':
|
||||
if (!context.app && !context.homeApp) return null;
|
||||
return (
|
||||
<AppHandoffSection
|
||||
{...resolvedProps}
|
||||
app={(context.app || context.homeApp)!}
|
||||
tool={context.tool}
|
||||
locale={locale}
|
||||
/>
|
||||
);
|
||||
|
||||
case 'availability':
|
||||
if (!context.tool) return null;
|
||||
return (
|
||||
<AvailabilitySection
|
||||
tool={context.tool}
|
||||
homeApp={context.homeApp}
|
||||
locale={locale}
|
||||
/>
|
||||
);
|
||||
|
||||
case 'appPicker':
|
||||
return <AppPickerSection {...resolvedProps} apps={context.apps} locale={locale} />;
|
||||
|
||||
case 'steps':
|
||||
return <StepsSection {...resolvedProps} locale={locale} />;
|
||||
|
||||
case 'featureList':
|
||||
return <FeatureListSection {...resolvedProps} locale={locale} />;
|
||||
|
||||
case 'faq':
|
||||
return <FaqSection {...resolvedProps} locale={locale} />;
|
||||
|
||||
case 'stats':
|
||||
return <StatsSection {...resolvedProps} />;
|
||||
|
||||
case 'pricingExplainer':
|
||||
return <PricingExplainerSection {...resolvedProps} locale={locale} />;
|
||||
|
||||
case 'relatedTools':
|
||||
return <RelatedToolsSection tools={context.relatedTools} locale={locale} />;
|
||||
|
||||
case 'richText':
|
||||
return <RichTextSection {...resolvedProps} />;
|
||||
|
||||
case 'ctaBanner':
|
||||
return <CtaBannerSection {...resolvedProps} locale={locale} />;
|
||||
|
||||
case 'notice':
|
||||
return <NoticeSection {...resolvedProps} locale={locale} />;
|
||||
|
||||
default:
|
||||
console.warn(`[SectionRenderer] Unknown section type: ${section.type}`);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import React from 'react';
|
||||
|
||||
interface StatsSectionProps {
|
||||
items?: Array<{
|
||||
value: string;
|
||||
label: string;
|
||||
}>;
|
||||
}
|
||||
|
||||
export function StatsSection({ items = [] }: StatsSectionProps) {
|
||||
if (!items || items.length === 0) return null;
|
||||
|
||||
return (
|
||||
<section className="py-8 bg-slate-50/50 dark:bg-slate-950/40 border-y border-slate-200 dark:border-slate-800">
|
||||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div className="grid grid-cols-2 md:grid-cols-4 gap-6 text-center">
|
||||
{items.map((stat, idx) => (
|
||||
<div key={idx} className="space-y-1">
|
||||
<p className="text-3xl sm:text-4xl font-extrabold bg-clip-text text-transparent bg-gradient-to-r from-blue-600 to-teal-500">
|
||||
{stat.value}
|
||||
</p>
|
||||
<p className="text-xs font-medium text-slate-500 dark:text-slate-400">
|
||||
{stat.label}
|
||||
</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
import React from 'react';
|
||||
import { resolveLocalised } from '@/types';
|
||||
|
||||
interface StepsSectionProps {
|
||||
title?: any;
|
||||
subtitle?: any;
|
||||
items?: Array<{
|
||||
title: any;
|
||||
desc: any;
|
||||
}>;
|
||||
locale?: string;
|
||||
}
|
||||
|
||||
export function StepsSection({
|
||||
title,
|
||||
subtitle,
|
||||
items = [],
|
||||
locale = 'en',
|
||||
}: StepsSectionProps) {
|
||||
if (!items || items.length === 0) return null;
|
||||
|
||||
return (
|
||||
<section className="py-12 lg:py-16 bg-slate-50/50 dark:bg-slate-950/50">
|
||||
<div className="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
{(title || subtitle) && (
|
||||
<div className="text-center max-w-2xl mx-auto mb-12 space-y-3">
|
||||
{title && (
|
||||
<h2 className="text-3xl font-bold text-slate-900 dark:text-white">
|
||||
{resolveLocalised(title, locale)}
|
||||
</h2>
|
||||
)}
|
||||
{subtitle && (
|
||||
<p className="text-sm text-slate-600 dark:text-slate-400">
|
||||
{resolveLocalised(subtitle, locale)}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-8">
|
||||
{items.map((step, idx) => (
|
||||
<div
|
||||
key={idx}
|
||||
className="relative bg-white dark:bg-slate-900 rounded-3xl p-6 sm:p-8 border border-slate-200 dark:border-slate-800 shadow-sm space-y-4"
|
||||
>
|
||||
<div className="w-10 h-10 rounded-xl bg-blue-600 text-white font-bold flex items-center justify-center text-base shadow-md shadow-blue-500/20">
|
||||
{idx + 1}
|
||||
</div>
|
||||
<h3 className="text-lg font-bold text-slate-900 dark:text-white">
|
||||
{resolveLocalised(step.title, locale)}
|
||||
</h3>
|
||||
<p className="text-xs text-slate-600 dark:text-slate-400 leading-relaxed">
|
||||
{resolveLocalised(step.desc, locale)}
|
||||
</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
'use client';
|
||||
|
||||
import React, { useState, useMemo } from 'react';
|
||||
import Link from 'next/link';
|
||||
import { Search, Sparkles, ArrowRight, Wand2, Scissors, Smile, Palette } from 'lucide-react';
|
||||
import { ToolItem, CategoryItem, AppItem, resolveLocalised } from '@/types';
|
||||
|
||||
interface ToolGridSectionProps {
|
||||
title?: any;
|
||||
subtitle?: any;
|
||||
tools?: ToolItem[];
|
||||
categories?: CategoryItem[];
|
||||
apps?: AppItem[];
|
||||
showSearch?: boolean;
|
||||
showCategoryFilter?: boolean;
|
||||
limit?: number;
|
||||
columns?: number;
|
||||
locale?: string;
|
||||
}
|
||||
|
||||
export function ToolGridSection({
|
||||
title,
|
||||
subtitle,
|
||||
tools = [],
|
||||
categories = [],
|
||||
apps = [],
|
||||
showSearch = false,
|
||||
showCategoryFilter = false,
|
||||
limit,
|
||||
locale = 'en',
|
||||
}: ToolGridSectionProps) {
|
||||
const [selectedCategory, setSelectedCategory] = useState<string>('all');
|
||||
const [searchQuery, setSearchQuery] = useState<string>('');
|
||||
|
||||
const appMap = useMemo(() => new Map(apps.map((a) => [a.id, a])), [apps]);
|
||||
|
||||
const filteredTools = useMemo(() => {
|
||||
let list = tools;
|
||||
if (selectedCategory !== 'all') {
|
||||
list = list.filter((t) => t.category === selectedCategory);
|
||||
}
|
||||
if (searchQuery.trim()) {
|
||||
const q = searchQuery.toLowerCase();
|
||||
list = list.filter((t) => {
|
||||
const name = resolveLocalised(t.name, locale).toLowerCase();
|
||||
const summary = resolveLocalised(t.summary, locale).toLowerCase();
|
||||
return name.includes(q) || summary.includes(q);
|
||||
});
|
||||
}
|
||||
if (limit && limit > 0) {
|
||||
list = list.slice(0, limit);
|
||||
}
|
||||
return list;
|
||||
}, [tools, selectedCategory, searchQuery, limit, locale]);
|
||||
|
||||
return (
|
||||
<section className="py-12 lg:py-16">
|
||||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
{/* Section Heading */}
|
||||
{(title || subtitle) && (
|
||||
<div className="text-center max-w-3xl mx-auto mb-10 space-y-3">
|
||||
{title && (
|
||||
<h2 className="text-3xl sm:text-4xl font-bold text-slate-900 dark:text-white">
|
||||
{resolveLocalised(title, locale)}
|
||||
</h2>
|
||||
)}
|
||||
{subtitle && (
|
||||
<p className="text-base text-slate-600 dark:text-slate-400">
|
||||
{resolveLocalised(subtitle, locale)}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Search & Filters */}
|
||||
{(showSearch || showCategoryFilter) && (
|
||||
<div className="mb-8 flex flex-col md:flex-row items-center justify-between gap-4">
|
||||
{showCategoryFilter && categories.length > 0 && (
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<button
|
||||
onClick={() => setSelectedCategory('all')}
|
||||
className={`px-3.5 py-1.5 rounded-full text-xs font-semibold transition-colors ${
|
||||
selectedCategory === 'all'
|
||||
? 'bg-blue-600 text-white'
|
||||
: 'bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-300 hover:bg-slate-200 dark:hover:bg-slate-700'
|
||||
}`}
|
||||
>
|
||||
All Tools
|
||||
</button>
|
||||
{categories.map((cat) => (
|
||||
<button
|
||||
key={cat.id}
|
||||
onClick={() => setSelectedCategory(cat.id)}
|
||||
className={`px-3.5 py-1.5 rounded-full text-xs font-semibold transition-colors ${
|
||||
selectedCategory === cat.id
|
||||
? 'bg-blue-600 text-white'
|
||||
: 'bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-300 hover:bg-slate-200 dark:hover:bg-slate-700'
|
||||
}`}
|
||||
>
|
||||
{resolveLocalised(cat.name, locale)}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{showSearch && (
|
||||
<div className="relative w-full md:w-72">
|
||||
<Search className="w-4 h-4 absolute left-3 top-1/2 -translate-y-1/2 text-slate-400" />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Search AI photo tools..."
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
className="w-full pl-9 pr-4 py-2 rounded-xl text-sm border border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-900 text-slate-900 dark:text-white placeholder-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Tools Cards Grid */}
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6">
|
||||
{filteredTools.map((tool) => {
|
||||
const homeApp = appMap.get(tool.homeApp);
|
||||
return (
|
||||
<div
|
||||
key={tool.id}
|
||||
className="group relative bg-white dark:bg-slate-900 rounded-2xl p-6 border border-slate-200 dark:border-slate-800 shadow-sm hover:shadow-xl hover:border-blue-500/50 transition-all flex flex-col justify-between"
|
||||
>
|
||||
<div>
|
||||
{/* Category Tag & Icon */}
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<span className="text-[11px] font-semibold tracking-wider uppercase text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-950/60 px-2.5 py-1 rounded-md">
|
||||
{tool.category}
|
||||
</span>
|
||||
<div className="w-8 h-8 rounded-lg bg-slate-100 dark:bg-slate-800 flex items-center justify-center text-slate-600 dark:text-slate-300 group-hover:scale-110 group-hover:text-blue-600 transition-all">
|
||||
<Wand2 className="w-4 h-4" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3 className="text-lg font-bold text-slate-900 dark:text-white group-hover:text-blue-600 dark:group-hover:text-blue-400 transition-colors">
|
||||
{resolveLocalised(tool.name, locale)}
|
||||
</h3>
|
||||
|
||||
<p className="mt-2 text-xs text-slate-600 dark:text-slate-400 line-clamp-3 leading-relaxed">
|
||||
{resolveLocalised(tool.summary, locale)}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="mt-6 pt-4 border-t border-slate-100 dark:border-slate-800/80 space-y-3">
|
||||
{/* Home App Attribution (PRD §1.2, §9 APP-01) */}
|
||||
{homeApp && (
|
||||
<div className="text-[11px] text-slate-500 dark:text-slate-400 flex items-center justify-between">
|
||||
<span>Home App:</span>
|
||||
<span className="font-semibold text-slate-700 dark:text-slate-300">
|
||||
{resolveLocalised(homeApp.name, locale)}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Link
|
||||
href={`/tools/${tool.slug}`}
|
||||
className="w-full inline-flex items-center justify-center space-x-2 py-2.5 rounded-xl text-xs font-semibold text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-950/40 hover:bg-blue-600 hover:text-white dark:hover:bg-blue-600 dark:hover:text-white transition-all shadow-sm"
|
||||
>
|
||||
<span>Try Free Online</span>
|
||||
<ArrowRight className="w-3.5 h-3.5" />
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
{filteredTools.length === 0 && (
|
||||
<div className="text-center py-12 text-slate-500 dark:text-slate-400">
|
||||
No photo tools found matching your filter.
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,405 @@
|
||||
'use client';
|
||||
|
||||
import React, { useState, useRef, useEffect } from 'react';
|
||||
import Link from 'next/link';
|
||||
import { UploadCloud, CheckCircle2, AlertCircle, RefreshCw, Download, Smartphone, Sparkles, Loader2, Image as ImageIcon } from 'lucide-react';
|
||||
import { ToolItem, AppItem, VariantSpec, resolveLocalised } from '@/types';
|
||||
import { BeforeAfterSlider } from '../ui/BeforeAfterSlider';
|
||||
|
||||
interface TryItWidgetProps {
|
||||
tool: ToolItem;
|
||||
homeApp?: AppItem | null;
|
||||
variants?: VariantSpec[];
|
||||
locale?: string;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function TryItWidget({
|
||||
tool,
|
||||
homeApp,
|
||||
variants = [],
|
||||
locale = 'en',
|
||||
className = '',
|
||||
}: TryItWidgetProps) {
|
||||
const [selectedFile, setSelectedFile] = useState<File | null>(null);
|
||||
const [previewUrl, setPreviewUrl] = useState<string | null>(null);
|
||||
const [resultUrl, setResultUrl] = useState<string | null>(null);
|
||||
const [activeVariant, setActiveVariant] = useState<string>(
|
||||
tool.tryIt?.endpointRef?.defaultVariant || (variants.length > 0 ? variants[0].id : '')
|
||||
);
|
||||
const [status, setStatus] = useState<'idle' | 'selected' | 'processing' | 'success' | 'limit' | 'error' | 'unavailable'>('idle');
|
||||
const [errorMessage, setErrorMessage] = useState<string>('');
|
||||
const [remainingTries, setRemainingTries] = useState<number>(tool.tryIt?.limits?.perDay || 5);
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
// Sample quick presets if user doesn't have an image on hand
|
||||
const samplePresets = [
|
||||
{
|
||||
label: 'Sample Portrait',
|
||||
url: 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=600&auto=format&fit=crop&q=80',
|
||||
},
|
||||
{
|
||||
label: 'Sample Selfie',
|
||||
url: 'https://images.unsplash.com/photo-1544005313-94ddf0286df2?w=600&auto=format&fit=crop&q=80',
|
||||
},
|
||||
];
|
||||
|
||||
const handleFileChange = (file: File) => {
|
||||
const maxMB = tool.tryIt?.limits?.maxMB || 12;
|
||||
if (file.size > maxMB * 1024 * 1024) {
|
||||
setStatus('error');
|
||||
setErrorMessage(`File exceeds ${maxMB}MB limit.`);
|
||||
return;
|
||||
}
|
||||
|
||||
const objectUrl = URL.createObjectURL(file);
|
||||
setSelectedFile(file);
|
||||
setPreviewUrl(objectUrl);
|
||||
setResultUrl(null);
|
||||
setStatus('selected');
|
||||
setErrorMessage('');
|
||||
};
|
||||
|
||||
const loadSamplePreset = async (url: string) => {
|
||||
try {
|
||||
setStatus('processing');
|
||||
const res = await fetch(url);
|
||||
const blob = await res.blob();
|
||||
const file = new File([blob], 'sample.jpg', { type: 'image/jpeg' });
|
||||
handleFileChange(file);
|
||||
} catch {
|
||||
setStatus('idle');
|
||||
}
|
||||
};
|
||||
|
||||
const handleDrop = (e: React.DragEvent) => {
|
||||
e.preventDefault();
|
||||
if (e.dataTransfer.files && e.dataTransfer.files[0]) {
|
||||
handleFileChange(e.dataTransfer.files[0]);
|
||||
}
|
||||
};
|
||||
|
||||
const runTryIt = async () => {
|
||||
if (!selectedFile) return;
|
||||
|
||||
setStatus('processing');
|
||||
setErrorMessage('');
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('image', selectedFile);
|
||||
if (activeVariant) {
|
||||
formData.append('variant', activeVariant);
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`/api/try/${tool.id}`, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
});
|
||||
|
||||
const remainingHeader = response.headers.get('X-Remaining-Tries');
|
||||
if (remainingHeader) {
|
||||
setRemainingTries(parseInt(remainingHeader, 10));
|
||||
}
|
||||
|
||||
if (response.status === 429) {
|
||||
const data = await response.json();
|
||||
setStatus('limit');
|
||||
setErrorMessage(data.messageKey === 'dailyBudgetExceeded'
|
||||
? "Today's free try budget has been reached. Open in mobile app for unlimited instant access."
|
||||
: "You have reached your daily free try limit on web. Open the app for 50 bonus credits!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (response.status === 503) {
|
||||
setStatus('unavailable');
|
||||
setErrorMessage('This AI tool is temporarily undergoing server maintenance. Please try in the mobile app.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
const errorJson = await response.json().catch(() => null);
|
||||
setStatus('error');
|
||||
setErrorMessage(errorJson?.error?.message || 'Processing failed. Please try again.');
|
||||
return;
|
||||
}
|
||||
|
||||
const blob = await response.blob();
|
||||
const resBlobUrl = URL.createObjectURL(blob);
|
||||
setResultUrl(resBlobUrl);
|
||||
setStatus('success');
|
||||
} catch (err: any) {
|
||||
setStatus('error');
|
||||
setErrorMessage(err.message || 'Network connection failed. Please retry.');
|
||||
}
|
||||
};
|
||||
|
||||
const reset = () => {
|
||||
setSelectedFile(null);
|
||||
if (previewUrl) URL.revokeObjectURL(previewUrl);
|
||||
if (resultUrl) URL.revokeObjectURL(resultUrl);
|
||||
setPreviewUrl(null);
|
||||
setResultUrl(null);
|
||||
setStatus('idle');
|
||||
setErrorMessage('');
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={`bg-white dark:bg-slate-900 rounded-3xl p-6 sm:p-8 shadow-xl border border-slate-200 dark:border-slate-800 ${className}`}>
|
||||
{/* Top Header & Tries Counter */}
|
||||
<div className="flex flex-wrap items-center justify-between gap-4 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-blue-50 dark:bg-blue-950 flex items-center justify-center text-blue-600 dark:text-blue-400">
|
||||
<Sparkles className="w-5 h-5" />
|
||||
</div>
|
||||
<div>
|
||||
<h3 className="font-semibold text-slate-900 dark:text-white">
|
||||
{resolveLocalised(tool.name, locale)} — Free Web Try
|
||||
</h3>
|
||||
<p className="text-xs text-slate-500 dark:text-slate-400">
|
||||
Zero watermarks • Instant RAM processing • No sign-up
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center space-x-2 bg-emerald-50 dark:bg-emerald-950/40 border border-emerald-200 dark:border-emerald-800 px-3 py-1.5 rounded-full text-xs font-medium text-emerald-700 dark:text-emerald-400">
|
||||
<CheckCircle2 className="w-3.5 h-3.5" />
|
||||
<span>{remainingTries} free tries today</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Main Body per Status */}
|
||||
<div className="mt-6">
|
||||
{status === 'idle' && (
|
||||
<div className="space-y-6">
|
||||
{/* Drag & Drop Upload Zone */}
|
||||
<div
|
||||
onDrop={handleDrop}
|
||||
onDragOver={(e) => e.preventDefault()}
|
||||
onClick={() => fileInputRef.current?.click()}
|
||||
className="border-2 border-dashed border-slate-300 dark:border-slate-700 hover:border-blue-500 dark:hover:border-blue-400 rounded-2xl p-8 sm:p-12 text-center cursor-pointer transition-all hover:bg-slate-50 dark:hover:bg-slate-800/40 group"
|
||||
>
|
||||
<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 mx-auto mb-4 rounded-2xl bg-blue-50 dark:bg-blue-950/60 flex items-center justify-center text-blue-600 dark:text-blue-400 group-hover:scale-110 transition-transform">
|
||||
<UploadCloud className="w-8 h-8" />
|
||||
</div>
|
||||
<p className="text-base font-semibold text-slate-900 dark:text-white">
|
||||
Drop your photo here, or <span className="text-blue-600 dark:text-blue-400 underline">browse</span>
|
||||
</p>
|
||||
<p className="mt-1 text-xs text-slate-500 dark:text-slate-400">
|
||||
Supports JPG, PNG, WEBP up to {tool.tryIt?.limits?.maxMB || 12}MB
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Quick Sample Presets */}
|
||||
<div className="pt-2">
|
||||
<p className="text-xs font-semibold text-slate-500 dark:text-slate-400 uppercase tracking-wider mb-3">
|
||||
Or try a sample photo:
|
||||
</p>
|
||||
<div className="flex flex-wrap gap-3">
|
||||
{samplePresets.map((preset, idx) => (
|
||||
<button
|
||||
key={idx}
|
||||
onClick={() => loadSamplePreset(preset.url)}
|
||||
className="inline-flex items-center space-x-2 px-3 py-2 rounded-xl text-xs font-medium bg-slate-100 dark:bg-slate-800 text-slate-700 dark:text-slate-200 hover:bg-slate-200 dark:hover:bg-slate-700 transition-colors"
|
||||
>
|
||||
<ImageIcon className="w-4 h-4 text-slate-500" />
|
||||
<span>{preset.label}</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{status === 'selected' && previewUrl && (
|
||||
<div className="space-y-6">
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6 items-center">
|
||||
{/* Image Preview */}
|
||||
<div className="relative aspect-[4/3] rounded-2xl overflow-hidden border border-slate-200 dark:border-slate-800 bg-slate-100 dark:bg-slate-950">
|
||||
{/* 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/60 hover:bg-black/80 text-white text-xs px-2.5 py-1 rounded-md backdrop-blur-md transition-colors"
|
||||
>
|
||||
Change Photo
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Variant / Mode Controls */}
|
||||
<div className="space-y-4">
|
||||
{variants.length > 0 && (
|
||||
<div>
|
||||
<label className="block text-xs font-semibold text-slate-500 dark:text-slate-400 uppercase tracking-wider mb-2">
|
||||
{resolveLocalised(tool.tryIt?.variantControl?.label, locale, 'Select Mode')}
|
||||
</label>
|
||||
<div className="space-y-2">
|
||||
{variants.map((v) => (
|
||||
<label
|
||||
key={v.id}
|
||||
className={`flex items-center justify-between p-3.5 rounded-xl border cursor-pointer transition-all ${
|
||||
activeVariant === v.id
|
||||
? 'border-blue-600 bg-blue-50/50 dark:bg-blue-950/30 dark:border-blue-500'
|
||||
: 'border-slate-200 dark:border-slate-800 hover:border-slate-300'
|
||||
}`}
|
||||
>
|
||||
<div className="flex items-center space-x-3">
|
||||
<input
|
||||
type="radio"
|
||||
name="variant"
|
||||
value={v.id}
|
||||
checked={activeVariant === v.id}
|
||||
onChange={() => setActiveVariant(v.id)}
|
||||
className="text-blue-600 focus:ring-blue-500"
|
||||
/>
|
||||
<div>
|
||||
<p className="text-sm font-medium text-slate-900 dark:text-white">
|
||||
{resolveLocalised(v.label, locale, v.description || v.id)}
|
||||
</p>
|
||||
{v.description && (
|
||||
<p className="text-xs text-slate-500 dark:text-slate-400">{v.description}</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Run Button */}
|
||||
<button
|
||||
onClick={runTryIt}
|
||||
className="w-full py-3.5 px-6 rounded-xl font-semibold text-white bg-blue-600 hover:bg-blue-700 shadow-lg shadow-blue-500/25 transition-all flex items-center justify-center space-x-2 active:scale-98"
|
||||
>
|
||||
<Sparkles className="w-5 h-5" />
|
||||
<span>Run {resolveLocalised(tool.name, locale)}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{status === 'processing' && (
|
||||
<div className="py-16 text-center space-y-4">
|
||||
<div className="inline-flex p-4 rounded-full bg-blue-50 dark:bg-blue-950 text-blue-600 animate-spin">
|
||||
<Loader2 className="w-8 h-8" />
|
||||
</div>
|
||||
<div>
|
||||
<h4 className="text-lg font-semibold text-slate-900 dark:text-white">
|
||||
Neural AI is processing your photo...
|
||||
</h4>
|
||||
<p className="text-sm text-slate-500 dark:text-slate-400 max-w-sm mx-auto mt-1">
|
||||
Applying model inference and preserving natural textures. Takes 1-3 seconds.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{status === 'success' && previewUrl && resultUrl && (
|
||||
<div className="space-y-6">
|
||||
<BeforeAfterSlider
|
||||
beforeUrl={previewUrl}
|
||||
afterUrl={resultUrl}
|
||||
beforeLabel="Original"
|
||||
afterLabel="AI Result"
|
||||
caption="Drag slider to inspect enhanced details and natural skin textures."
|
||||
/>
|
||||
|
||||
{/* Actions: Download & Reset */}
|
||||
<div className="flex flex-wrap items-center justify-between gap-4 pt-2">
|
||||
<button
|
||||
onClick={reset}
|
||||
className="inline-flex items-center space-x-2 px-4 py-2.5 rounded-xl text-sm font-medium border border-slate-300 dark:border-slate-700 hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors"
|
||||
>
|
||||
<RefreshCw className="w-4 h-4 text-slate-500" />
|
||||
<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-sm font-semibold text-white bg-emerald-600 hover:bg-emerald-700 shadow-md shadow-emerald-500/20 transition-all"
|
||||
>
|
||||
<Download className="w-4 h-4" />
|
||||
<span>Download Standard HD</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{/* Result App Handoff Card (PRD §8.2, §9 APP-06) */}
|
||||
{homeApp && (
|
||||
<div className="mt-6 p-5 rounded-2xl bg-gradient-to-r from-blue-50 to-indigo-50 dark:from-blue-950/40 dark:to-indigo-950/40 border border-blue-100 dark:border-blue-900/60 flex flex-col sm:flex-row items-center justify-between gap-4">
|
||||
<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-xs font-semibold uppercase tracking-wider text-blue-600 dark:text-blue-400">
|
||||
Want 4K Lossless & Batch Export?
|
||||
</span>
|
||||
</div>
|
||||
<h5 className="font-semibold text-slate-900 dark:text-white">
|
||||
Open {resolveLocalised(tool.name, locale)} in {resolveLocalised(homeApp.name, locale)}
|
||||
</h5>
|
||||
<p className="text-xs text-slate-600 dark:text-slate-400">
|
||||
Get 50 free HD export credits upon first mobile install with promo code{' '}
|
||||
<span className="font-mono font-bold text-blue-600">{homeApp.welcomeBonus?.code || 'TRYWEB50'}</span>.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Link
|
||||
href={`/go/${tool.slug}/${homeApp.slug}`}
|
||||
className="shrink-0 px-5 py-2.5 rounded-xl text-sm font-semibold text-white bg-blue-600 hover:bg-blue-700 shadow-md shadow-blue-500/20 transition-all hover:scale-105 active:scale-95"
|
||||
>
|
||||
Open in {resolveLocalised(homeApp.name, locale)}
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{(status === 'limit' || status === 'error' || status === 'unavailable') && (
|
||||
<div className="p-6 rounded-2xl bg-amber-50 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-full bg-amber-100 dark:bg-amber-900/40 flex items-center justify-center text-amber-600 dark:text-amber-400">
|
||||
<AlertCircle className="w-6 h-6" />
|
||||
</div>
|
||||
<div>
|
||||
<h4 className="text-base font-semibold text-slate-900 dark:text-white">
|
||||
{status === 'limit'
|
||||
? 'Daily Free Web Limit Reached'
|
||||
: status === 'unavailable'
|
||||
? 'Service Temporarily Offline'
|
||||
: 'Processing Issue'}
|
||||
</h4>
|
||||
<p className="text-sm text-slate-600 dark:text-slate-400 max-w-md mx-auto mt-1">
|
||||
{errorMessage}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<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-medium border border-slate-300 dark:border-slate-700 hover:bg-white dark:hover:bg-slate-800"
|
||||
>
|
||||
Try Again
|
||||
</button>
|
||||
{homeApp && (
|
||||
<Link
|
||||
href={`/go/${tool.slug}/${homeApp.slug}`}
|
||||
className="px-5 py-2 rounded-xl text-xs font-semibold text-white bg-blue-600 hover:bg-blue-700 shadow-md"
|
||||
>
|
||||
Open in {resolveLocalised(homeApp.name, locale)}
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user