dashboard: show the full clip 'why' in a popover when it is clamped
The line is clamped to two lines so cards in a row stay level; a long sentence then reads as '...how easily audiences...' with the rest only in the native title tooltip. When the text actually overflows, hovering (desktop) or tapping (touch) now floats the whole sentence over the card, so nothing grows and the grid stays aligned.
This commit is contained in:
parent
36dba9b3b1
commit
4b2cf58922
1 changed files with 37 additions and 4 deletions
|
|
@ -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 && (
|
||||
<p className="text-xs text-muted leading-snug line-clamp-2 mb-2 break-words" title="why openshorts picked this moment">
|
||||
{clip.why}
|
||||
</p>
|
||||
<div
|
||||
className="relative mb-2"
|
||||
onMouseEnter={() => setWhyOpen(true)}
|
||||
onMouseLeave={() => setWhyOpen(false)}
|
||||
>
|
||||
<p
|
||||
ref={whyRef}
|
||||
className={`text-xs text-muted leading-snug line-clamp-2 break-words ${whyClamped ? 'cursor-pointer' : ''}`}
|
||||
onClick={() => whyClamped && setWhyOpen(v => !v)}
|
||||
aria-label="why openshorts picked this moment"
|
||||
>
|
||||
{clip.why}
|
||||
</p>
|
||||
{whyClamped && whyOpen && (
|
||||
<div
|
||||
role="tooltip"
|
||||
className="absolute left-0 right-0 top-full mt-1 z-20 bg-paper border border-rule rounded-input px-3 py-2 text-xs text-ink leading-snug shadow-lg"
|
||||
>
|
||||
{clip.why}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
{durationReadout && <span className="readout bg-paper3 px-2 py-0.5 rounded-full shrink-0">{durationReadout}</span>}
|
||||
|
|
|
|||
Loading…
Reference in a new issue