197 lines
7.6 KiB
TypeScript
197 lines
7.6 KiB
TypeScript
'use client';
|
|
|
|
import React, { useState, useEffect } from 'react';
|
|
import QRCode from 'qrcode';
|
|
import {
|
|
Smartphone,
|
|
Copy,
|
|
Check,
|
|
ExternalLink,
|
|
Zap,
|
|
Sparkles
|
|
} from 'lucide-react';
|
|
import { AppItem, ToolItem, resolveLocalised } from '@/types';
|
|
import { KineticText } from '@/components/magicui/kinetic-text';
|
|
|
|
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 [copiedLink, setCopiedLink] = useState(false);
|
|
const [origin, setOrigin] = useState<string>('');
|
|
|
|
useEffect(() => {
|
|
if (typeof window !== 'undefined') {
|
|
setOrigin(window.location.origin);
|
|
}
|
|
}, []);
|
|
|
|
if (!app) return null;
|
|
|
|
const baseHost = origin || 'http://localhost:3000';
|
|
const targetUrl = tool
|
|
? `${baseHost}/go/${tool.slug}/${app.slug}`
|
|
: `${baseHost}/apps/${app.slug}`;
|
|
|
|
useEffect(() => {
|
|
if (showQr) {
|
|
QRCode.toDataURL(targetUrl, {
|
|
width: 220,
|
|
margin: 1,
|
|
color: {
|
|
dark: '#141E28',
|
|
light: '#F8F9FA',
|
|
},
|
|
})
|
|
.then((url) => setQrDataUrl(url))
|
|
.catch(() => {});
|
|
}
|
|
}, [showQr, targetUrl]);
|
|
|
|
const copyLink = () => {
|
|
navigator.clipboard.writeText(targetUrl);
|
|
setCopiedLink(true);
|
|
setTimeout(() => setCopiedLink(false), 2000);
|
|
};
|
|
|
|
const appName = resolveLocalised(app.name, locale);
|
|
const appTagline = resolveLocalised(app.tagline, locale);
|
|
|
|
return (
|
|
<section id="app-handoff" className="py-16 sm:py-24 bg-paper border-b border-rule relative overflow-hidden">
|
|
{/* Studio Lighting Background Glow */}
|
|
<div
|
|
className="pointer-events-none absolute top-10 left-10 w-[500px] h-[350px] [background:radial-gradient(ellipse_at_center,color-mix(in_oklab,var(--color-accent)_12%,transparent)_0%,transparent_70%)]"
|
|
aria-hidden="true"
|
|
/>
|
|
<div
|
|
className="pointer-events-none absolute inset-0 opacity-20 studio-proof-grid"
|
|
aria-hidden="true"
|
|
/>
|
|
|
|
<div className="max-w-container mx-auto px-4 sm:px-6 lg:px-8 space-y-10 relative z-10">
|
|
{/* Section Header */}
|
|
<div className="max-w-2xl space-y-2 border-b border-rule pb-5">
|
|
<h2 className="text-3xl sm:text-4xl font-display font-bold text-ink tracking-tight">
|
|
<KineticText>Continue on mobile</KineticText>
|
|
</h2>
|
|
<p className="text-sm sm:text-base text-ink-2 font-body text-pretty">
|
|
Handoff this tool directly to your iOS or Android phone for lossless 4K mobile processing.
|
|
</p>
|
|
</div>
|
|
|
|
<div className="grid grid-cols-1 lg:grid-cols-12 gap-8 items-start">
|
|
{/* Left Column: App Specifications & Store Buttons */}
|
|
<div className="lg:col-span-7 studio-sheet rounded-3xl p-6 sm:p-8 space-y-6">
|
|
<div className="border-b border-rule pb-5 space-y-2">
|
|
<span className="text-xs text-muted font-body">Dedicated companion client</span>
|
|
<h3 className="text-2xl font-display font-bold text-ink">
|
|
{appName}
|
|
</h3>
|
|
<p className="text-sm text-ink-2 font-body leading-relaxed">
|
|
{appTagline}
|
|
</p>
|
|
</div>
|
|
|
|
{/* Mobile Studio Capabilities */}
|
|
{showBonus && (
|
|
<div className="p-4 bg-paper-2 border border-rule rounded-2xl flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3">
|
|
<div className="flex items-center gap-3">
|
|
<div className="w-8 h-8 rounded-xl bg-accent/10 flex items-center justify-center shrink-0">
|
|
<Sparkles className="w-4 h-4 text-accent" />
|
|
</div>
|
|
<div className="space-y-0.5">
|
|
<span className="text-xs font-body font-semibold text-ink">
|
|
Lossless 4K & Batch Processing
|
|
</span>
|
|
<p className="text-xs text-muted font-body">
|
|
Hardware neural acceleration for rapid multi-photo exports.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<span className="font-body text-xs font-semibold text-accent px-3 py-1 bg-paper-hi border border-rule rounded-full shrink-0">
|
|
Native Mobile Studio
|
|
</span>
|
|
</div>
|
|
)}
|
|
|
|
{/* Official Store Buttons */}
|
|
<div className="pt-2 space-y-3">
|
|
<span className="text-xs text-muted font-body block">Direct store installation</span>
|
|
<div className="flex flex-col sm:flex-row flex-wrap gap-3">
|
|
<a
|
|
href={app.stores?.ios?.url || `/go/${tool?.slug || 'explore'}/${app.slug}`}
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
className="btn-secondary min-h-[48px] rounded-full justify-center w-full sm:w-auto"
|
|
>
|
|
<Smartphone className="w-4 h-4 text-accent" aria-hidden="true" />
|
|
<span>Apple App Store</span>
|
|
<ExternalLink className="w-3.5 h-3.5 text-muted ml-1" aria-hidden="true" />
|
|
</a>
|
|
|
|
<a
|
|
href={app.stores?.android?.url || `/go/${tool?.slug || 'explore'}/${app.slug}`}
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
className="btn-secondary min-h-[48px] rounded-full justify-center w-full sm:w-auto"
|
|
>
|
|
<Smartphone className="w-4 h-4 text-accent" aria-hidden="true" />
|
|
<span>Google Play</span>
|
|
<ExternalLink className="w-3.5 h-3.5 text-muted ml-1" aria-hidden="true" />
|
|
</a>
|
|
|
|
<button
|
|
type="button"
|
|
onClick={copyLink}
|
|
className="btn-secondary min-h-[48px] rounded-full justify-center w-full sm:w-auto"
|
|
aria-label="Copy direct deep link"
|
|
>
|
|
{copiedLink ? <Check className="w-4 h-4 text-accent" aria-hidden="true" /> : <Copy className="w-4 h-4 text-muted" aria-hidden="true" />}
|
|
<span>{copiedLink ? 'Link copied' : 'Copy link'}</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div className="pt-2 text-xs text-muted font-body">
|
|
{resolveLocalised(app.creditsNote, locale, 'In-app purchases and subscriptions are managed securely via Apple App Store and Google Play.')}
|
|
</div>
|
|
</div>
|
|
|
|
{/* Right Column: Clean QR Code Card */}
|
|
{showQr && qrDataUrl && (
|
|
<div className="lg:col-span-5 studio-sheet rounded-3xl p-6 sm:p-8 text-center flex flex-col items-center">
|
|
<span className="text-xs text-muted font-body mb-4">Scan with phone camera</span>
|
|
|
|
<div className="p-4 bg-paper-hi border border-rule rounded-2xl inline-block shadow-sm">
|
|
<img
|
|
src={qrDataUrl}
|
|
alt={`Scan QR code to install ${appName}`}
|
|
className="w-44 h-44 object-contain rounded-xl"
|
|
/>
|
|
</div>
|
|
|
|
<div className="mt-4 space-y-1 text-xs font-body text-muted">
|
|
<p className="font-medium text-ink">Instant mobile handoff</p>
|
|
<p>Directs to App Store or Google Play for instantaneous installation.</p>
|
|
</div>
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</section>
|
|
);
|
|
}
|