clipwright/dashboard/src/components/MediaInput.jsx
victormanuel.caverogracia aa676a7814 redesign: Lumen design system across landing, app and paywall
Full visual rework to a single locked design system (design.md, Lumen
Night Foundry): dark violet canvas, molten-brass accent, Instrument
Serif + Geist + JetBrains Mono, hairline cards, zero gradients and
zero glassmorphism.

- Landing: marquee hero with real vertical demo clip in an instrument
  bezel, meter strip, smart-crop before/after section, cloud-first
  copy (start free trial primary, self-host demoted to secondary),
  text density cut, SEO surfaces preserved (single h1, ids, FAQs,
  comparison table intact)
- App: workbench restyle — sidebar with mono ordinals, unified header,
  settings/ai-agent/dashboard views on shared tokens; per-feature
  gradient identities retired
- Shared UI: new Modal, SegmentedControl and StepIndicator replace 8+
  duplicated modal shells and 2 wizard steppers
- New pricing paywall page (#/pricing): demo proof strip, honest trust
  signals, billing FAQ
- Routing: app logo links back to landing via #landing without
  resetting the skip-landing preference
- Responsive: audited and fixed at 320/375/414/768px (no horizontal
  scroll, tables scroll in-container, single-line CTAs)
- ScheduleWeekModal translated to English; ProcessingAnimation comment
  noise removed

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-17 02:41:22 +02:00

192 lines
9.1 KiB
JavaScript

import React, { useState, useEffect, useRef } from 'react';
import { Link2, Upload, FileVideo, X, Info, Loader2 } from 'lucide-react';
import { getApiUrl } from '../config';
const SUPPORTED_PLATFORMS = [
'YouTube', 'Vimeo', 'TikTok', 'X / Twitter', 'Twitch',
'Facebook', 'Instagram', 'Dailymotion', 'Reddit', 'Streamable',
];
export default function MediaInput({ onProcess, isProcessing }) {
const [youtubeUrlEnabled, setYoutubeUrlEnabled] = useState(true);
// File upload is the primary path; the link is secondary.
const [mode, setMode] = useState('file'); // 'file' | 'url'
const [url, setUrl] = useState('');
const [file, setFile] = useState(null);
const [acknowledged, setAcknowledged] = useState(false);
const [showInfo, setShowInfo] = useState(false);
const infoRef = useRef(null);
// Close the compatibility popover on any outside click.
useEffect(() => {
if (!showInfo) return;
const onClick = (e) => {
if (infoRef.current && !infoRef.current.contains(e.target)) setShowInfo(false);
};
document.addEventListener('mousedown', onClick);
return () => document.removeEventListener('mousedown', onClick);
}, [showInfo]);
useEffect(() => {
fetch(getApiUrl('/api/config'))
.then((r) => r.ok ? r.json() : null)
.then((cfg) => {
if (cfg && cfg.youtubeUrlEnabled === false) {
setYoutubeUrlEnabled(false);
setMode('file');
}
})
.catch(() => {});
}, []);
const handleSubmit = (e) => {
e.preventDefault();
if (!acknowledged) return;
if (mode === 'url' && url) {
onProcess({ type: 'url', payload: url, acknowledged: true });
} else if (mode === 'file' && file) {
onProcess({ type: 'file', payload: file, acknowledged: true });
}
};
const handleDrop = (e) => {
e.preventDefault();
if (e.dataTransfer.files && e.dataTransfer.files[0]) {
setFile(e.dataTransfer.files[0]);
setMode('file');
}
};
return (
<div className="card p-4 sm:p-6 animate-fade">
<div className="flex gap-4 sm:gap-6 mb-6 border-b border-rule">
<button
onClick={() => setMode('file')}
className={`flex items-center gap-2 pb-3 px-1 -mb-px border-b-2 text-sm lowercase whitespace-nowrap transition-colors ${mode === 'file'
? 'text-ink border-brass'
: 'text-muted border-transparent hover:text-ink2'
}`}
>
<Upload size={16} className={`hidden sm:block ${mode === 'file' ? 'text-brass' : ''}`} />
Upload File
</button>
{youtubeUrlEnabled && (
<button
onClick={() => setMode('url')}
className={`flex items-center gap-2 pb-3 px-1 -mb-px border-b-2 text-sm lowercase whitespace-nowrap transition-colors ${mode === 'url'
? 'text-ink border-brass'
: 'text-muted border-transparent hover:text-ink2'
}`}
>
<Link2 size={16} className={`hidden sm:block ${mode === 'url' ? 'text-brass' : ''}`} />
Video URL
</button>
)}
</div>
<form onSubmit={handleSubmit}>
{mode === 'url' ? (
<div className="space-y-4">
<div className="relative">
<input
type="url"
value={url}
onChange={(e) => setUrl(e.target.value)}
placeholder="https://... paste a video link"
className="input-field pr-11"
required
/>
<div className="absolute inset-y-0 right-2 flex items-center" ref={infoRef}>
<button
type="button"
onClick={() => setShowInfo((v) => !v)}
aria-label="Supported platforms"
className="p-1.5 text-muted hover:text-brass transition-colors"
>
<Info size={16} />
</button>
{showInfo && (
<div className="absolute right-0 top-full mt-2 w-64 z-20 card p-4 text-left animate-fade">
<p className="eyebrow mb-2">Paste a link from</p>
<div className="flex flex-wrap gap-1.5">
{SUPPORTED_PLATFORMS.map((p) => (
<span key={p} className="text-xs px-2 py-0.5 rounded-full bg-paper3 text-ink2">
{p}
</span>
))}
</div>
<p className="text-xs text-muted mt-2.5 leading-relaxed">
…and 1,000+ more sites. If a link has a public video, we can usually fetch it.
</p>
</div>
)}
</div>
</div>
</div>
) : (
<div
className={`border-2 border-dashed rounded-card p-6 sm:p-8 text-center transition-colors ${file ? 'border-brass' : 'border-rule2 hover:border-brass'
}`}
onDragOver={(e) => e.preventDefault()}
onDrop={handleDrop}
>
{file ? (
<div className="flex items-center justify-center gap-3 text-ok min-w-0">
<FileVideo size={18} className="shrink-0" />
<span className="font-medium truncate">{file.name}</span>
<button
type="button"
onClick={() => setFile(null)}
className="p-1 text-muted hover:text-ink hover:bg-paper3 rounded-full transition-colors"
>
<X size={16} />
</button>
</div>
) : (
<label className="cursor-pointer block">
<input
type="file"
accept="video/*"
onChange={(e) => setFile(e.target.files?.[0] || null)}
className="hidden"
/>
<Upload className="mx-auto mb-3 text-muted" size={18} />
<p className="text-ink2 lowercase">Click to upload or drag and drop</p>
<p className="readout mt-2">MP4, MOV up to 500MB</p>
</label>
)}
</div>
)}
<label className="flex items-start gap-2 mt-5 text-xs text-muted cursor-pointer select-none">
<input
type="checkbox"
checked={acknowledged}
onChange={(e) => setAcknowledged(e.target.checked)}
className="mt-0.5 accent-[var(--color-accent)] cursor-pointer"
/>
<span>
I confirm I own this content or have the rights to process it. I am responsible for any content I submit. See our <a href="/#legal" target="_blank" rel="noopener noreferrer" className="text-ink2 underline underline-offset-2 hover:text-brass transition-colors" onClick={(e) => e.stopPropagation()}>Terms & Privacy</a>.
</span>
</label>
<button
type="submit"
disabled={isProcessing || !acknowledged || (mode === 'url' && !url) || (mode === 'file' && !file)}
className="w-full btn-primary mt-4"
>
{isProcessing ? (
<>
<Loader2 size={16} className="animate-spin" />
Processing Video...
</>
) : (
<>
Generate Clips
</>
)}
</button>
</form>
</div>
);
}