Skip to content

🎥 Make videos programmatically with React

Stack timeline layer and asset names

JonnyBurger517c72ad46ab
diff --git a/packages/studio/src/components/Timeline/TimelineList.tsx b/packages/studio/src/components/Timeline/TimelineList.tsx
index 1b1fef145c..1fac0c9c5e 100644
--- a/packages/studio/src/components/Timeline/TimelineList.tsx
+++ b/packages/studio/src/components/Timeline/TimelineList.tsx
@@ -268,6 +268,7 @@ export const TimelineList: React.FC = () => {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
line-height: normal;
+ padding-right: 10px;
visibility: hidden;
}`}</style>
{virtualItems.map((virtualItem) =>
diff --git a/packages/studio/src/components/Timeline/TimelineMediaInfo.tsx b/packages/studio/src/components/Timeline/TimelineMediaInfo.tsx
index aacfaaf939..084094e7e9 100644
--- a/packages/studio/src/components/Timeline/TimelineMediaInfo.tsx
+++ b/packages/studio/src/components/Timeline/TimelineMediaInfo.tsx
@@ -6,9 +6,13 @@ import {getTimelineAssetLinkInfo} from './timeline-asset-link';
const lineStyle: React.CSSProperties = {
whiteSpace: 'nowrap',
overflow: 'hidden',
- textOverflow: 'ellipsis',
+ paddingRight: 10,
+ maskImage: 'linear-gradient(to right, black calc(100% - 10px), transparent)',
+ WebkitMaskImage:
+ 'linear-gradient(to right, black calc(100% - 10px), transparent)',
minWidth: 0,
fontSize: 12,
+ lineHeight: '14px',
color: WHITE_ALPHA_30,
display: 'inline-block',
};
@@ -24,7 +28,6 @@ const useAssetLink = (src: string) => {
display: 'inline-block',
overflow: 'hidden',
whiteSpace: 'pre',
- textOverflow: 'ellipsis',
userSelect: 'none',
WebkitUserSelect: 'none',
}),
diff --git a/packages/studio/src/components/Timeline/TimelineSequenceItem.tsx b/packages/studio/src/components/Timeline/TimelineSequenceItem.tsx
index c61f2163c7..8fd31bc689 100644
--- a/packages/studio/src/components/Timeline/TimelineSequenceItem.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSequenceItem.tsx
@@ -1112,6 +1112,32 @@ const TimelineSequenceItemInner: React.FC<{
() => getTimelineSequenceHeight(sequence) + TIMELINE_ITEM_BORDER_BOTTOM,
[sequence],
);
+ const stackMediaName = Boolean(mediaSrc);
+ const namesStyle = useMemo(
+ (): React.CSSProperties => ({
+ ...labelContainerStyle,
+ ...(stackMediaName
+ ? {
+ alignItems: 'stretch',
+ flexDirection: 'column',
+ justifyContent: 'center',
+ }
+ : {}),
+ }),
+ [stackMediaName],
+ );
+ const nameRowStyle = useMemo(
+ (): React.CSSProperties =>
+ stackMediaName
+ ? {
+ display: 'flex',
+ alignItems: 'center',
+ height: 16,
+ minWidth: 0,
+ }
+ : {display: 'contents'},
+ [stackMediaName],
+ );
const connectedCompositionIconStyle = useMemo(
(): React.CSSProperties => ({
@@ -1126,14 +1152,14 @@ const TimelineSequenceItemInner: React.FC<{
const inner: React.CSSProperties = useMemo(() => {
return {
- height: TIMELINE_LIST_ITEM_ROW_HEIGHT,
+ height: stackMediaName ? 30 : TIMELINE_LIST_ITEM_ROW_HEIGHT,
color: WHITE,
fontFamily: 'Arial, Helvetica, sans-serif',
wordBreak: 'break-all',
textAlign: 'left',
flexShrink: 0,
};
- }, []);
+ }, [stackMediaName]);
const rowStyle = useMemo((): React.CSSProperties => {
return effectDropHovered
@@ -1717,37 +1743,47 @@ const TimelineSequenceItemInner: React.FC<{
onPointerEnter={onPointerEnter}
onPointerLeave={onPointerLeave}
>
- <div style={labelContainerStyle}>
- {connectedCompositions.length > 0 ? (
- <>
- <CompositionOrStillIcon
- color={getTimelineColor(false, false)}
- composition={connectedCompositions[0]}
- style={connectedCompositionIconStyle}
- />
- <Spacing x={0.5} />
- </>
- ) : null}
- <TimelineSequenceLabel
- displayName={timelineDisplayName}
- fallbackDisplayName={fallbackDisplayName}
- selected={selected}
- containsSelection={containsSelection}
- editing={isRenaming}
- onCancelEditing={onCancelRenaming}
- onSaveName={onSaveName}
- numberOfHiddenDuplicates={numberOfHiddenDuplicates}
- canHaveExpandableContent={hasExpandableContent}
- disabled={!previewInteractive}
- isExpanded={isExpanded}
- nodePathInfo={nodePathInfo}
- selectedItems={selectedItems}
- sequence={sequence}
- />
+ <div style={namesStyle}>
+ <div style={nameRowStyle}>
+ {connectedCompositions.length > 0 ? (
+ <>
+ <CompositionOrStillIcon
+ color={getTimelineColor(false, false)}
+ composition={connectedCompositions[0]}
+ style={connectedCompositionIconStyle}
+ />
+ <Spacing x={0.5} />
+ </>
+ ) : null}
+ <TimelineSequenceLabel
+ displayName={timelineDisplayName}
+ fallbackDisplayName={fallbackDisplayName}
+ selected={selected}
+ containsSelection={containsSelection}
+ editing={isRenaming}
+ onCancelEditing={onCancelRenaming}
+ onSaveName={onSaveName}
+ numberOfHiddenDuplicates={numberOfHiddenDuplicates}
+ canHaveExpandableContent={hasExpandableContent}
+ disabled={!previewInteractive}
+ isExpanded={isExpanded}
+ nodePathInfo={nodePathInfo}
+ selectedItems={selectedItems}
+ sequence={sequence}
+ />
+ </div>
{mediaSrc ? (
- <>
- <Spacing x={0.5} /> <TimelineMediaInfo src={mediaSrc} />
- </>
+ <div
+ style={{
+ display: 'flex',
+ height: 14,
+ marginTop: -2,
+ paddingLeft: 2,
+ minWidth: 0,
+ }}
+ >
+ <TimelineMediaInfo src={mediaSrc} />
+ </div>
) : null}
</div>
</TimelineRowChrome>
diff --git a/packages/studio/src/components/Timeline/TimelineSequenceName.tsx b/packages/studio/src/components/Timeline/TimelineSequenceName.tsx
index f7403cb60e..53d620a5d7 100644
--- a/packages/studio/src/components/Timeline/TimelineSequenceName.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSequenceName.tsx
@@ -13,6 +13,20 @@ const LABEL_FONT_FAMILY = 'Arial, Helvetica, sans-serif';
// 4px gap + 12px chevron + 4px chevron margin.
const CHEVRON_SLOT_WIDTH = 20;
+const nameTextStyle: React.CSSProperties = {
+ fontFamily: LABEL_FONT_FAMILY,
+ fontSize: 12,
+ lineHeight: 'normal',
+ color: 'inherit',
+ minWidth: 0,
+ paddingRight: 10,
+ maskImage: 'linear-gradient(to right, black calc(100% - 10px), transparent)',
+ WebkitMaskImage:
+ 'linear-gradient(to right, black calc(100% - 10px), transparent)',
+ overflow: 'hidden',
+ whiteSpace: 'nowrap',
+};
+
const getTruncatedDisplayName = (displayName: string): string => {
if (displayName.length > MAX_DISPLAY_NAME_LENGTH) {
return displayName.slice(0, MAX_DISPLAY_NAME_LENGTH) + '...';
@@ -57,7 +71,6 @@ export const TimelineSequenceName: React.FC<{
overflow: chevronSlot === 'none' ? 'hidden' : 'visible',
position: chevronSlot === 'none' ? undefined : 'relative',
whiteSpace: 'nowrap',
- textOverflow: 'ellipsis',
color: getTimelineColor(selected, false),
userSelect: 'none',
WebkitUserSelect: 'none',
@@ -184,16 +197,18 @@ export const TimelineSequenceName: React.FC<{
height: '100%',
left: 0,
lineHeight: 'normal',
- maxWidth: `calc(100% + ${CHEVRON_SLOT_WIDTH}px)`,
+ maxWidth:
+ chevronSlot === 'occupied'
+ ? 'calc(100% + 4px)'
+ : `calc(100% + ${CHEVRON_SLOT_WIDTH}px)`,
overflow: 'hidden',
position: 'absolute',
- textOverflow: 'ellipsis',
top: 0,
whiteSpace: 'nowrap',
width: 'max-content',
}}
>
- {text}
+ <span style={nameTextStyle}>{text}</span>
</div>
</div>
);
@@ -201,7 +216,7 @@ export const TimelineSequenceName: React.FC<{
return (
<div role="group" aria-label={text} style={style}>
- {text}
+ <span style={nameTextStyle}>{text}</span>
</div>
);
};
diff --git a/packages/studio/src/helpers/timeline-layout.ts b/packages/studio/src/helpers/timeline-layout.ts
index 2bce54a389..8128eb045e 100644
--- a/packages/studio/src/helpers/timeline-layout.ts
+++ b/packages/studio/src/helpers/timeline-layout.ts
@@ -287,6 +287,7 @@ export const TIMELINE_LAYER_HEIGHT_VIDEO =
TIMELINE_LAYER_FILMSTRIP_HEIGHT + TIMELINE_VIDEO_INFO_WAVEFORM_HEIGHT;
export const TIMELINE_LAYER_HEIGHT_AUDIO = 34;
+export const TIMELINE_LAYER_HEIGHT_IMAGE = 34;
export const TIMELINE_LAYER_HEIGHT_DEFAULT = 21;
// The horizontal row inside a timeline list item (eye + arrow + label).
export const TIMELINE_LIST_ITEM_ROW_HEIGHT = 21;
@@ -302,5 +303,9 @@ export const getTimelineLayerHeight = (
return TIMELINE_LAYER_HEIGHT_AUDIO;
}
+ if (type === 'image') {
+ return TIMELINE_LAYER_HEIGHT_IMAGE;
+ }
+
return TIMELINE_LAYER_HEIGHT_DEFAULT;
};