fix(dashboard): replace cramped tutorial card with a Next tour

The coach chip stacked three step labels on top of each other. Walk Clip
Generator control by control instead, and park the tooltip inside the
viewport on small screens.
This commit is contained in:
victormanuel.caverogracia 2026-09-01 14:11:44 +02:00
parent 016267f204
commit 8a22fa7b9e
3 changed files with 192 additions and 39 deletions

View file

@ -1032,6 +1032,7 @@ function App() {
return (
<button
key={item.id}
data-tutorial={item.id === 'dashboard' ? 'nav-clips' : undefined}
onClick={() => goToTab(item.id)}
title={tabLocked(item.id) ? 'Finish your first clips to unlock' : item.label}
disabled={tabLocked(item.id)}
@ -1135,6 +1136,7 @@ function App() {
return (
<button
key={item.id}
data-tutorial={item.id === 'dashboard' ? 'nav-clips' : undefined}
onClick={() => goToTab(item.id)}
disabled={tabLocked(item.id)}
aria-current={isActive ? 'page' : undefined}
@ -1181,7 +1183,7 @@ function App() {
>
<Menu size={20} />
</button>
<span className="md:hidden font-display lowercase text-base text-ink truncate">
<span data-tutorial="nav-clips" className="md:hidden font-display lowercase text-base text-ink truncate">
{activeNav?.label || 'openshorts'}
</span>
{status !== 'idle' && (

View file

@ -1,31 +1,118 @@
import { ArrowRight, CheckCircle2, LayoutDashboard, Sparkles } from 'lucide-react';
import { useEffect, useLayoutEffect, useState } from 'react';
import { ArrowLeft, ArrowRight, CheckCircle2, LayoutDashboard, Sparkles } from 'lucide-react';
import Modal from './ui/Modal';
import StepIndicator from './ui/StepIndicator';
const STEPS = ['Add a video', 'Generate', 'Your clips'];
const TOUR = [
{
target: '[data-tutorial="nav-clips"]',
title: 'Clip Generator',
body: 'This is the tool people come for. A long video in, vertical shorts out. The other menu items stay locked until you finish one run.',
},
{
target: '[data-tutorial="source-tabs"]',
title: 'Upload or paste a link',
body: 'Drop an MP4, or switch to Video URL and paste YouTube, TikTok, Instagram…',
},
{
target: '[data-tutorial="drop-zone"]',
title: 'Your video',
body: 'Click the box or paste the link here. Keep files under 500MB.',
},
{
target: '[data-tutorial="output-format"]',
title: 'Output format',
body: '9:16 is TikTok, Reels and Shorts. Leave it unless you need a square feed post or landscape.',
},
{
target: '[data-tutorial="generate"]',
title: 'Generate',
body: 'Tick that you have the rights, then generate. That is the whole first run.',
},
];
function stepIndex(jobStatus) {
if (jobStatus === 'processing') return 1;
if (jobStatus === 'complete') return 2;
return 0;
function visibleTarget(selector) {
return [...document.querySelectorAll(selector)].find((el) => {
const r = el.getBoundingClientRect();
return r.width > 2 && r.height > 2;
}) || null;
}
function stepCopy(jobStatus) {
if (jobStatus === 'processing') return 'Hang on — Clip Generator is finding the moments and cutting vertical shorts.';
if (jobStatus === 'error') return 'That run failed. Try another YouTube link or file. The other tools stay locked until one job finishes.';
if (jobStatus === 'complete') return 'Clips are ready.';
return 'Paste a YouTube link or drop a video below, tick the rights box, then generate.';
function placeTip(rect, tipW, tipH, vw, vh) {
const m = 12;
const gap = 12;
const mobile = vw < 640;
if (mobile) {
return {
top: Math.max(m, vh - tipH - m - 8),
left: m,
width: vw - m * 2,
};
}
let top = rect.bottom + gap;
if (top + tipH > vh - m) top = rect.top - gap - tipH;
if (top < m) top = m;
let left = rect.left + rect.width / 2 - tipW / 2;
left = Math.max(m, Math.min(left, vw - m - tipW));
return { top, left, width: tipW };
}
/**
* First-login Clip Generator tutorial.
* - intro: blocking modal (Start / skip)
* - coach: non-blocking card that tracks idle → processing → complete
* - intro: blocking modal
* - coach: Next/Back spotlight on each Clip Generator control
* - celebrate: modal after the first successful job
*
* QA: open #app?tutorial=1 to force the intro without a fresh signup.
* QA: #app?tutorial=1
*/
export default function ClipTutorial({ phase, jobStatus, onStart, onSkip, onDismissCelebrate }) {
const [step, setStep] = useState(0);
const [spot, setSpot] = useState(null);
useEffect(() => {
if (phase === 'coach') setStep(0);
}, [phase]);
useLayoutEffect(() => {
if (phase !== 'coach' || jobStatus === 'processing' || jobStatus === 'error') {
setSpot(null);
return;
}
const measure = () => {
const spec = TOUR[step];
if (!spec) { setSpot(null); return; }
const el = visibleTarget(spec.target);
if (el) el.scrollIntoView({ block: 'nearest', inline: 'nearest' });
const rect = el ? el.getBoundingClientRect() : null;
const vw = window.innerWidth;
const vh = window.innerHeight;
const r = (n) => Math.round(n);
const mobile = vw < 640;
const tipW = Math.min(360, vw - 24);
const tipH = 220;
const hole = rect
? { top: r(rect.top - 6), left: r(rect.left - 6), width: r(rect.width + 12), height: r(rect.height + 12) }
: null;
const rawTip = hole
? placeTip({ top: hole.top, bottom: hole.top + hole.height, left: hole.left, width: hole.width }, tipW, tipH, vw, vh)
: { top: mobile ? vh - 240 : vh / 2 - 80, left: 12, width: vw - 24 };
const tip = { top: r(rawTip.top), left: r(rawTip.left), width: r(rawTip.width) };
setSpot((prev) => {
const next = { hole, tip, mobile };
try {
if (prev && JSON.stringify(prev) === JSON.stringify(next)) return prev;
} catch (_) { /* ignore */ }
return next;
});
};
measure();
window.addEventListener('resize', measure);
window.addEventListener('scroll', measure, true);
return () => {
window.removeEventListener('resize', measure);
window.removeEventListener('scroll', measure, true);
};
}, [phase, step, jobStatus]);
if (phase === 'intro') {
return (
<Modal isOpen hideClose eyebrow="FIRST CLIPS" title="Let's make your first shorts" size="md">
@ -35,16 +122,11 @@ export default function ClipTutorial({ phase, jobStatus, onStart, onSkip, onDism
</div>
<p className="text-sm text-ink2 leading-relaxed">
People come here for <b className="text-ink font-medium">Clip Generator</b>: a long video in,
vertical shorts out. That is the only tool unlocked on this first run.
vertical shorts out. We will walk the screen, then you run one video.
</p>
</div>
<ol className="text-sm text-muted space-y-2 mb-6 list-decimal pl-5">
<li>Paste a YouTube link or upload a file</li>
<li>Generate</li>
<li>Watch the clips</li>
</ol>
<button type="button" onClick={onStart} className="btn-primary w-full">
Start with Clip Generator <ArrowRight size={16} />
Show me around <ArrowRight size={16} />
</button>
<button
type="button"
@ -57,26 +139,93 @@ export default function ClipTutorial({ phase, jobStatus, onStart, onSkip, onDism
);
}
if (phase === 'coach') {
const current = stepIndex(jobStatus);
if (phase === 'coach' && (jobStatus === 'processing' || jobStatus === 'error')) {
return (
<div
className="fixed z-[80] left-3 right-3 md:left-auto md:right-6 md:w-[22rem]
bottom-[4.75rem] md:bottom-6 card p-4 shadow-[0_12px_40px_rgba(0,0,0,0.35)]"
bottom-3 md:bottom-6 card p-4"
role="status"
>
<p className="eyebrow mb-3">First clips</p>
<StepIndicator steps={STEPS} current={current} />
<p className={`text-sm leading-relaxed mt-3 ${jobStatus === 'error' ? 'text-danger' : 'text-muted'}`}>
{stepCopy(jobStatus)}
<p className="eyebrow mb-2">First clips</p>
<p className={`text-sm leading-relaxed ${jobStatus === 'error' ? 'text-danger' : 'text-muted'}`}>
{jobStatus === 'error'
? 'That run failed. Try another video — other tools stay locked until one job finishes.'
: 'Hang on — Clip Generator is finding the moments and cutting vertical shorts.'}
</p>
<button
type="button"
onClick={onSkip}
className="mt-3 text-xs lowercase text-muted hover:text-ink transition-colors"
</div>
);
}
if (phase === 'coach') {
const last = step >= TOUR.length - 1;
const spec = TOUR[step] || TOUR[0];
const onLast = () => setStep(TOUR.length);
if (step >= TOUR.length) {
return (
<div
className="fixed z-[80] inset-x-3 bottom-3 md:inset-x-auto md:right-6 md:bottom-6 md:max-w-sm
card px-4 py-3 flex flex-wrap items-center gap-x-3 gap-y-1"
role="status"
>
skip — unlock the rest
</button>
<p className="text-sm text-muted leading-snug flex-1 min-w-0">
Your turn — add a video and generate.
</p>
<button type="button" onClick={onSkip} className="text-xs lowercase text-muted hover:text-ink shrink-0">
skip
</button>
</div>
);
}
const hole = spot?.hole;
const tip = spot?.tip;
return (
<div className="fixed inset-0 z-[80]" role="dialog" aria-modal="true" aria-label="Clip Generator tutorial">
{!hole && <div className="absolute inset-0 bg-black/55" />}
{hole && (
<div
className="absolute rounded-input pointer-events-none border border-brass/70"
style={{
top: hole.top,
left: hole.left,
width: hole.width,
height: hole.height,
boxShadow: '0 0 0 9999px rgba(0,0,0,0.55)',
}}
/>
)}
<div
className="absolute card p-4 max-h-[min(70vh,24rem)] overflow-y-auto"
style={{
top: tip?.top ?? 16,
left: tip?.left ?? 12,
width: tip?.width ?? undefined,
maxWidth: 'calc(100vw - 24px)',
}}
>
<p className="eyebrow mb-2">{String(step + 1).padStart(2, '0')} / {String(TOUR.length).padStart(2, '0')}</p>
<h3 className="font-display lowercase text-lg text-ink leading-tight mb-2">{spec.title}</h3>
<p className="text-sm text-muted leading-relaxed mb-4">{spec.body}</p>
<div className="flex flex-wrap items-center gap-2">
{step > 0 && (
<button type="button" onClick={() => setStep((s) => s - 1)} className="btn-ghost text-sm px-3">
<ArrowLeft size={14} /> Back
</button>
)}
<button
type="button"
onClick={last ? onLast : () => setStep((s) => s + 1)}
className="btn-primary text-sm px-4 ml-auto"
>
{last ? 'Got it' : 'Next'} <ArrowRight size={14} />
</button>
</div>
<button type="button" onClick={onSkip} className="mt-3 text-xs lowercase text-muted hover:text-ink transition-colors">
skip — unlock the rest
</button>
</div>
</div>
);
}

View file

@ -108,7 +108,7 @@ export default function MediaInput({ onProcess, isProcessing }) {
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">
<div className="flex gap-4 sm:gap-6 mb-6 border-b border-rule" data-tutorial="source-tabs">
<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'
@ -135,7 +135,7 @@ export default function MediaInput({ onProcess, isProcessing }) {
<form onSubmit={handleSubmit}>
{mode === 'url' ? (
<div className="space-y-4">
<div className="space-y-4" data-tutorial="drop-zone">
<div className="relative">
<input
type="url"
@ -174,6 +174,7 @@ export default function MediaInput({ onProcess, isProcessing }) {
</div>
) : (
<div
data-tutorial="drop-zone"
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()}
@ -208,7 +209,7 @@ export default function MediaInput({ onProcess, isProcessing }) {
)}
{/* Output format selector */}
<div className="mt-5">
<div className="mt-5" data-tutorial="output-format">
<p className="eyebrow mb-2">Output format</p>
<div className="grid grid-cols-3 gap-2">
{[
@ -351,6 +352,7 @@ export default function MediaInput({ onProcess, isProcessing }) {
<button
type="submit"
data-tutorial="generate"
disabled={isProcessing || !acknowledged || (mode === 'url' && !url) || (mode === 'file' && !file)}
className="w-full btn-primary mt-4"
>