|
|
|
|
@ -8,66 +8,54 @@ const TimelineSeg = ({
|
|
|
|
|
isCutRangeValid, duration: durationRaw, cutStartTime, cutEndTime, apparentCutStart,
|
|
|
|
|
apparentCutEnd, isActive, segNum, onSegClick, color,
|
|
|
|
|
}) => {
|
|
|
|
|
const markerWidth = 4;
|
|
|
|
|
const duration = durationRaw || 1;
|
|
|
|
|
const cutSectionWidth = `calc(${((apparentCutEnd - apparentCutStart) / duration) * 100}% - ${markerWidth * 2}px)`;
|
|
|
|
|
const cutSectionWidth = `${((apparentCutEnd - apparentCutStart) / duration) * 100}%`;
|
|
|
|
|
const markerWidth = 4;
|
|
|
|
|
|
|
|
|
|
const startTimePos = `${(apparentCutStart / duration) * 100}%`;
|
|
|
|
|
const endTimePos = `${(apparentCutEnd / duration) * 100}%`;
|
|
|
|
|
const markerBorder = isActive ? `2px solid ${color.lighten(0.5).string()}` : undefined;
|
|
|
|
|
const backgroundColor = isActive ? color.lighten(0.5).alpha(0.5).string() : color.alpha(0.5).string();
|
|
|
|
|
const markerBorderRadius = 5;
|
|
|
|
|
|
|
|
|
|
const startMarkerStyle = {
|
|
|
|
|
background: color.alpha(0.5).string(),
|
|
|
|
|
width: markerWidth,
|
|
|
|
|
left: startTimePos,
|
|
|
|
|
borderLeft: markerBorder,
|
|
|
|
|
borderTopLeftRadius: markerBorderRadius,
|
|
|
|
|
borderBottomLeftRadius: markerBorderRadius,
|
|
|
|
|
};
|
|
|
|
|
const endMarkerStyle = {
|
|
|
|
|
background: color.alpha(0.5).string(),
|
|
|
|
|
width: markerWidth,
|
|
|
|
|
marginLeft: -markerWidth,
|
|
|
|
|
left: endTimePos,
|
|
|
|
|
borderRight: markerBorder,
|
|
|
|
|
borderTopRightRadius: markerBorderRadius,
|
|
|
|
|
borderBottomRightRadius: markerBorderRadius,
|
|
|
|
|
};
|
|
|
|
|
const cutSectionStyle = {
|
|
|
|
|
background: color.alpha(0.5).string(),
|
|
|
|
|
marginLeft: markerWidth,
|
|
|
|
|
left: startTimePos,
|
|
|
|
|
width: cutSectionWidth,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const onThisSegClick = () => onSegClick(segNum);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
// eslint-disable-next-line react/jsx-fragments
|
|
|
|
|
<div>
|
|
|
|
|
<motion.div
|
|
|
|
|
style={{ position: 'absolute', top: 0, bottom: 0, left: startTimePos, width: cutSectionWidth, display: 'flex', background: backgroundColor, originX: 0 }}
|
|
|
|
|
layoutTransition={{ type: 'spring', damping: 30, stiffness: 1000 }}
|
|
|
|
|
initial={{ opacity: 0, scaleX: 0 }}
|
|
|
|
|
animate={{ opacity: 1, scaleX: 1 }}
|
|
|
|
|
exit={{ opacity: 0, scaleX: 0 }}
|
|
|
|
|
onClick={onThisSegClick}
|
|
|
|
|
>
|
|
|
|
|
{cutStartTime !== undefined && (
|
|
|
|
|
<div style={startMarkerStyle} className="cut-time-marker" role="button" tabIndex="0" onClick={onThisSegClick} />
|
|
|
|
|
<div style={startMarkerStyle} role="button" tabIndex="0" />
|
|
|
|
|
)}
|
|
|
|
|
{isCutRangeValid && (cutStartTime !== undefined || cutEndTime !== undefined) && (
|
|
|
|
|
<motion.div
|
|
|
|
|
layoutTransition
|
|
|
|
|
initial={{ opacity: 0 }}
|
|
|
|
|
animate={{ opacity: 1 }}
|
|
|
|
|
exit={{ opacity: 0 }}
|
|
|
|
|
|
|
|
|
|
className="cut-section"
|
|
|
|
|
style={cutSectionStyle}
|
|
|
|
|
<div
|
|
|
|
|
role="button"
|
|
|
|
|
tabIndex="0"
|
|
|
|
|
onClick={onThisSegClick}
|
|
|
|
|
style={{ flexGrow: 1 }}
|
|
|
|
|
title={`${formatDuration({ seconds: cutEndTime - cutStartTime })}`}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
{cutEndTime !== undefined && (
|
|
|
|
|
<div style={endMarkerStyle} className="cut-time-marker" role="button" tabIndex="0" onClick={onThisSegClick} />
|
|
|
|
|
<div style={endMarkerStyle} role="button" tabIndex="0" />
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</motion.div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|