diff --git a/dashboard/src/components/ResultCard.jsx b/dashboard/src/components/ResultCard.jsx index b6c84d3..2927dfb 100644 --- a/dashboard/src/components/ResultCard.jsx +++ b/dashboard/src/components/ResultCard.jsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react'; +import React, { useState, useEffect, useRef } from 'react'; import { Download, Share2, Instagram, Youtube, Video, AlertCircle, Loader2, Copy, Check, Wand2, Type, Calendar, Languages, FileText, Link2, Scissors, Crosshair, TrendingUp } from 'lucide-react'; import { getApiUrl } from '../config'; import { apiFetch } from '../lib/api'; @@ -38,6 +38,20 @@ function formatDuration(clip) { export default function ResultCard({ clip, index, jobId, durable, uploadPostKey, uploadUserId, geminiApiKey, elevenLabsKey, isManaged, onPlay, onPause, onBulkSubtitle, clipCount = 1, bulkProgress, initialState = null, onStateChange, connectedPlatforms = null, onConnectSocials, onEditClip = null, onReframeClip = null }) { const [showModal, setShowModal] = useState(false); + // The "why" line is clamped to two lines so cards in a row stay level; + // when it overflows, a hover (desktop) or tap (touch) shows the whole + // sentence in a popover that floats over the card instead of growing it. + const whyRef = useRef(null); + const [whyOpen, setWhyOpen] = useState(false); + const [whyClamped, setWhyClamped] = useState(false); + useEffect(() => { + const el = whyRef.current; + if (!el) return; + const check = () => setWhyClamped(el.scrollHeight > el.clientHeight + 1); + check(); + window.addEventListener('resize', check); + return () => window.removeEventListener('resize', check); + }, [clip.why]); const [showDescModal, setShowDescModal] = useState(false); const [showSubtitleModal, setShowSubtitleModal] = useState(false); const [showWatermarkModal, setShowWatermarkModal] = useState(false); @@ -819,9 +833,28 @@ export default function ResultCard({ clip, index, jobId, durable, uploadPostKey, {/* The score alone says how much, not why. One line from the selection pass on what this moment has going for it. */} {clip.why && ( -

- {clip.why} -

+
setWhyOpen(true)} + onMouseLeave={() => setWhyOpen(false)} + > +

whyClamped && setWhyOpen(v => !v)} + aria-label="why openshorts picked this moment" + > + {clip.why} +

+ {whyClamped && whyOpen && ( +
+ {clip.why} +
+ )} +
)}
{durationReadout && {durationReadout}}