Skip to content

🎥 Make videos programmatically with React

@remotion/studio: Address timeline keyframe review feedback

JonnyBurgerc7769b8d65dd
diff --git a/packages/studio/src/components/Timeline/TimelineEffectFieldRow.tsx b/packages/studio/src/components/Timeline/TimelineEffectFieldRow.tsx
index 49978ffdce..805f17d4d4 100644
--- a/packages/studio/src/components/Timeline/TimelineEffectFieldRow.tsx
+++ b/packages/studio/src/components/Timeline/TimelineEffectFieldRow.tsx
@@ -7,16 +7,13 @@ import {StudioServerConnectionCtx} from '../../helpers/client-id';
import type {EffectSchemaFieldInfo} from '../../helpers/timeline-layout';
import {EXPANDED_SECTION_PADDING_RIGHT} from '../../helpers/timeline-layout';
import {callApi} from '../call-api';
+import {getComputedStatusLabel} from './get-timeline-keyframes';
import {enqueueSavePropChange} from './save-prop-queue';
import {getTimelineFieldLabelRowStyle} from './timeline-field-row-layout';
import {TimelineExpandArrowSpacer} from './TimelineExpandArrowButton';
import {TimelineLayerEyeSpacer} from './TimelineLayerEye';
import {TimelineRowChrome} from './TimelineRowChrome';
-import {
- getComputedStatusLabel,
- TimelineFieldValue,
- UnsupportedStatus,
-} from './TimelineSchemaField';
+import {TimelineFieldValue, UnsupportedStatus} from './TimelineSchemaField';
const fieldRowBase: React.CSSProperties = {
paddingRight: EXPANDED_SECTION_PADDING_RIGHT,
diff --git a/packages/studio/src/components/Timeline/TimelineExpandedTrackKeyframes.tsx b/packages/studio/src/components/Timeline/TimelineExpandedTrackKeyframes.tsx
index 9cbce799d3..db60c6cbbb 100644
--- a/packages/studio/src/components/Timeline/TimelineExpandedTrackKeyframes.tsx
+++ b/packages/studio/src/components/Timeline/TimelineExpandedTrackKeyframes.tsx
@@ -12,7 +12,7 @@ import {
TIMELINE_PADDING,
} from '../../helpers/timeline-layout';
import {ExpandedTracksGetterContext} from '../ExpandedTracksProvider';
-import {getTimelineKeyframes} from './TimelineSchemaField';
+import {getTimelineKeyframes} from './get-timeline-keyframes';
import {TimelineWidthContext} from './TimelineWidthProvider';
const row: React.CSSProperties = {
@@ -80,19 +80,16 @@ const TimelineExpandedTrackKeyframesInner: React.FC<{
const timelineWidth = useContext(TimelineWidthContext);
const {getIsExpanded} = useContext(ExpandedTracksGetterContext);
const {codeValues} = useContext(Internals.VisualModeCodeValuesContext);
- const {getDragOverrides} = useContext(
- Internals.VisualModeDragOverridesContext,
- );
const tree = useMemo(
() =>
buildTimelineTree({
sequence,
nodePathInfo,
- getDragOverrides,
+ getDragOverrides: () => ({}),
codeValues,
}),
- [codeValues, getDragOverrides, nodePathInfo, sequence],
+ [codeValues, nodePathInfo, sequence],
);
const flat = useMemo(
@@ -141,7 +138,7 @@ const TimelineExpandedTrackKeyframesInner: React.FC<{
? null
: keyframes.map((keyframe) => (
<div
- key={`${keyframe.frame}-${JSON.stringify(keyframe.value)}`}
+ key={String(keyframe.frame)}
style={{
...diamondBase,
left:
diff --git a/packages/studio/src/components/Timeline/TimelineSchemaField.tsx b/packages/studio/src/components/Timeline/TimelineSchemaField.tsx
index bdaffafa5e..9752eb0e4e 100644
--- a/packages/studio/src/components/Timeline/TimelineSchemaField.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSchemaField.tsx
@@ -1,6 +1,5 @@
import React from 'react';
import type {
- CanUpdateSequencePropStatus,
CanUpdateSequencePropStatusFalse,
CanUpdateSequencePropStatusTrue,
} from 'remotion';
@@ -9,6 +8,7 @@ import type {
TimelineFieldOnDragValueChange,
TimelineFieldOnSave,
} from '../../helpers/timeline-layout';
+import {getComputedStatusLabel} from './get-timeline-keyframes';
import {TimelineBooleanField} from './TimelineBooleanField';
import {TimelineColorField} from './TimelineColorField';
import {TimelineEnumField} from './TimelineEnumField';
@@ -38,34 +38,6 @@ export const UnsupportedStatus: React.FC<{
return <span style={unsupportedLabel}>{label}</span>;
};
-export const getComputedStatusLabel = (
- propStatus: CanUpdateSequencePropStatusFalse,
-): string => {
- if (propStatus.reason !== 'computed') {
- throw new Error(
- `Unsupported prop status: ${propStatus.reason satisfies never}`,
- );
- }
-
- return propStatus.keyframes?.length ? 'keyframed' : 'computed';
-};
-
-export const getTimelineKeyframes = (
- propStatus: CanUpdateSequencePropStatus | null | undefined,
-): {frame: number; value: unknown}[] => {
- if (!propStatus || propStatus.canUpdate) {
- return [];
- }
-
- if (propStatus.reason !== 'computed') {
- throw new Error(
- `Unsupported prop status: ${propStatus.reason satisfies never}`,
- );
- }
-
- return propStatus.keyframes ?? [];
-};
-
export const TimelineNonEditableStatus: React.FC<{
readonly propStatus: CanUpdateSequencePropStatusFalse;
}> = ({propStatus}) => {
diff --git a/packages/studio/src/components/Timeline/get-timeline-keyframes.ts b/packages/studio/src/components/Timeline/get-timeline-keyframes.ts
new file mode 100644
index 0000000000..f04f60068f
--- /dev/null
+++ b/packages/studio/src/components/Timeline/get-timeline-keyframes.ts
@@ -0,0 +1,32 @@
+import type {
+ CanUpdateSequencePropStatus,
+ CanUpdateSequencePropStatusFalse,
+} from 'remotion';
+
+export const getComputedStatusLabel = (
+ propStatus: CanUpdateSequencePropStatusFalse,
+): string => {
+ if (propStatus.reason !== 'computed') {
+ throw new Error(
+ `Unsupported prop status: ${propStatus.reason satisfies never}`,
+ );
+ }
+
+ return propStatus.keyframes?.length ? 'keyframed' : 'computed';
+};
+
+export const getTimelineKeyframes = (
+ propStatus: CanUpdateSequencePropStatus | null | undefined,
+): {frame: number; value: unknown}[] => {
+ if (!propStatus || propStatus.canUpdate) {
+ return [];
+ }
+
+ if (propStatus.reason !== 'computed') {
+ throw new Error(
+ `Unsupported prop status: ${propStatus.reason satisfies never}`,
+ );
+ }
+
+ return propStatus.keyframes ?? [];
+};