feat: tool page front screen dedicated upload interface and section 2 transformation results

This commit is contained in:
2026-11-04 11:47:43 +05:30
parent 63d850330e
commit 378f5c40a9
4 changed files with 79 additions and 147 deletions
+60 -100
View File
@@ -207,111 +207,71 @@ export function TryItWidget({
{/* Main Body per Status */}
<div className="mt-7">
{status === 'idle' && (
<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 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="Upload photo to edit"
className={`border-2 border-dashed rounded-3xl p-8 sm:p-12 text-center cursor-pointer transition-all duration-300 group ${
isDragOver
? 'border-blue-500 bg-blue-50/60 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>
{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>
)}
<div className="inline-flex items-center gap-2 px-6 py-3 rounded-full bg-blue-600 hover:bg-blue-700 text-white font-semibold text-sm shadow-md shadow-blue-500/20 group-hover:shadow-lg transition-all mb-3">
<UploadCloud className="w-4 h-4" />
<span>Upload Image</span>
</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>
)}
<p className="text-sm sm:text-base font-display font-medium text-slate-700">
or drag and drop your photo here
</p>
<p className="mt-2 text-xs font-mono text-slate-500">
Supports JPG, PNG, WEBP up to {tool.tryIt?.limits?.maxMB || 12}MB • High-res 4K processing
</p>
</div>
{/* 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>
{/* Quick Sample Presets */}
<div className="pt-1">
<p className="text-xs font-mono uppercase tracking-wider text-slate-500 font-semibold mb-3">
Or test instantly with a 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-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>