diff --git a/src/SegmentList.jsx b/src/SegmentList.jsx index ac88088c..84d8d217 100644 --- a/src/SegmentList.jsx +++ b/src/SegmentList.jsx @@ -15,6 +15,59 @@ const buttonBaseStyle = { const neutralButtonColor = 'rgba(255, 255, 255, 0.2)'; + +const Segment = memo(({ seg, index, currentSegIndex, formatTimecode, getFrameCount, segOrderDecrease, segOrderIncrease, invertCutSegments, onClick }) => { + const { t } = useTranslation(); + + const duration = seg.end - seg.start; + const durationMs = duration * 1000; + + const isActive = !invertCutSegments && currentSegIndex === index; + + function renderNumber() { + if (invertCutSegments) return ; + + const { + segBgColor, segBorderColor, + } = getSegColors(seg); + + return {index + 1}; + } + + const timeStr = `${formatTimecode(seg.start)} - ${formatTimecode(seg.end)}`; + + return ( + !invertCutSegments && onClick(index)} + positionTransition + style={{ originY: 0, margin: '5px 0', border: `1px solid rgba(255,255,255,${isActive ? 1 : 0.3})`, padding: 5, borderRadius: 5, position: 'relative' }} + initial={{ scaleY: 0 }} + animate={{ scaleY: 1 }} + exit={{ scaleY: 0 }} + > +
+ {renderNumber()} + {timeStr} +
+
{seg.name}
+
+ {t('Duration')} {prettyMs(durationMs)} +
+
+ ({Math.floor(durationMs)} ms, {getFrameCount(duration)} frames) +
+ + {isActive && ( + + + + + )} +
+ ); +}); + const SegmentList = memo(({ formatTimecode, cutSegments, outSegments, getFrameCount, onSegClick, currentSegIndex, invertCutSegments, @@ -72,58 +125,6 @@ const SegmentList = memo(({ e.stopPropagation(); } - const renderSegments = () => outSegments.map((seg, index) => { - const duration = seg.end - seg.start; - const durationMs = duration * 1000; - - const isActive = !invertCutSegments && currentSegIndex === index; - const uuid = seg.uuid || `${seg.start}`; - - function renderNumber() { - if (invertCutSegments) return ; - - const { - segBgColor, segBorderColor, - } = getSegColors(seg); - - return {index + 1}; - } - - const timeStr = `${formatTimecode(seg.start)} - ${formatTimecode(seg.end)}`; - - return ( - !invertCutSegments && onSegClick(index)} - key={uuid} - positionTransition - style={{ originY: 0, margin: '5px 0', border: `1px solid rgba(255,255,255,${isActive ? 1 : 0.3})`, padding: 5, borderRadius: 5, position: 'relative' }} - initial={{ scaleY: 0 }} - animate={{ scaleY: 1 }} - exit={{ scaleY: 0 }} - > -
- {renderNumber()} - {timeStr} -
-
{seg.name}
-
- {t('Duration')} {prettyMs(durationMs)} -
-
- ({Math.floor(durationMs)} ms, {getFrameCount(duration)} frames) -
- - {isActive && ( - - - - - )} -
- ); - }); - const renderFooter = () => { const { segActiveBgColor: currentSegActiveBgColor } = getSegColors(currentCutSeg); const { segActiveBgColor: segmentAtCursorActiveBgColor } = getSegColors(segmentAtCursor); @@ -195,7 +196,10 @@ const SegmentList = memo(({ {headerText} - {outSegments && renderSegments()} + {outSegments && outSegments.map((seg, index) => { + const id = seg.uuid || `${seg.start}`; + return ; + })} {outSegments && renderFooter()}