Skip to content

🎥 Make videos programmatically with React

`remotion`: Make `<Series>` a `<Sequence>` with `layout="none"`

Jonny Burger0ca53e2bc900
diff --git a/packages/core/src/series/index.tsx b/packages/core/src/series/index.tsx
index 03c260587b..9f3754bbf6 100644
--- a/packages/core/src/series/index.tsx
+++ b/packages/core/src/series/index.tsx
@@ -3,7 +3,6 @@ import React, {Children, forwardRef, useMemo} from 'react';
import {addSequenceStackTraces} from '../enable-sequence-stack-traces.js';
import type {LayoutAndStyle, SequenceProps} from '../Sequence.js';
import {Sequence} from '../Sequence.js';
-import {ENABLE_V5_BREAKING_CHANGES} from '../v5-flag.js';
import {validateDurationInFrames} from '../validation/validate-duration-in-frames.js';
import {flattenChildren} from './flatten-children.js';
import {
@@ -34,15 +33,7 @@ const SeriesSequenceRefForwardingFunction: React.ForwardRefRenderFunction<
const SeriesSequence = forwardRef(SeriesSequenceRefForwardingFunction);
-type V4Props = {
- children: React.ReactNode;
-};
-
-type V5Props = SequenceProps;
-
-type SeriesProps = true extends typeof ENABLE_V5_BREAKING_CHANGES
- ? V5Props
- : V4Props;
+type SeriesProps = SequenceProps;
/**
* @description with this component, you can easily stitch together scenes that should play sequentially after another.
@@ -141,19 +132,18 @@ const Series: FC<SeriesProps> & {
});
}, [props.children]);
- if (ENABLE_V5_BREAKING_CHANGES) {
- return (
- <IsInsideSeriesContainer>
- <Sequence {...props}>{childrenValue}</Sequence>
- </IsInsideSeriesContainer>
- );
- }
-
- return <IsInsideSeriesContainer>{childrenValue}</IsInsideSeriesContainer>;
+ return (
+ <IsInsideSeriesContainer>
+ <Sequence layout="none" name="<Series>" {...props}>
+ {childrenValue}
+ </Sequence>
+ </IsInsideSeriesContainer>
+ );
};
Series.Sequence = SeriesSequence;
export {Series};
+addSequenceStackTraces(Series);
addSequenceStackTraces(SeriesSequence);
diff --git a/packages/core/src/test/series.test.tsx b/packages/core/src/test/series.test.tsx
index 264142dd62..3a41d555b1 100644
--- a/packages/core/src/test/series.test.tsx
+++ b/packages/core/src/test/series.test.tsx
@@ -8,7 +8,6 @@ import {Series} from '../series/index.js';
import type {TimelineContextValue} from '../TimelineContext.js';
import {AbsoluteTimeContext, TimelineContext} from '../TimelineContext.js';
import {useCurrentFrame} from '../use-current-frame.js';
-import {ENABLE_V5_BREAKING_CHANGES} from '../v5-flag.js';
import {WrapSequenceContext} from './wrap-sequence-context.js';
const ABS_FILL =
@@ -79,11 +78,7 @@ test('Basic series test', () => {
</Series>
</WrapSequenceContext>,
);
- expect(outerHTML).toBe(
- ENABLE_V5_BREAKING_CHANGES
- ? `${ABS_FILL}${ABS_FILL}<div>third 0</div></div></div>`
- : `${ABS_FILL}<div>third 0</div></div>`,
- );
+ expect(outerHTML).toBe(`${ABS_FILL}<div>third 0</div></div>`);
});
test('Should support fragments', () => {
@@ -111,11 +106,7 @@ test('Should support fragments', () => {
</WrapSequenceContext>,
);
- expect(outerHtml).not.toBe(
- ENABLE_V5_BREAKING_CHANGES
- ? `${ABS_FILL}${ABS_FILL}<div>second 1</div></div></div>`
- : `${ABS_FILL}<div>second 1</div></div>`,
- );
+ expect(outerHtml).not.toBe(`${ABS_FILL}<div>second 1</div></div>`);
});
test('Should not allow foreign elements', () => {
expect(() => {
@@ -140,11 +131,7 @@ test('Should allow layout prop', () => {
</Series>
</WrapSequenceContext>,
);
- expect(outerHTML).toBe(
- ENABLE_V5_BREAKING_CHANGES
- ? `${ABS_FILL}${ABS_FILL}<div>first 0</div></div></div>`
- : `${ABS_FILL}<div>first 0</div></div>`,
- );
+ expect(outerHTML).toBe(`${ABS_FILL}<div>first 0</div></div>`);
const outerHTML2 = renderForFrame(
0,
@@ -156,11 +143,7 @@ test('Should allow layout prop', () => {
</Series>
</WrapSequenceContext>,
);
- expect(outerHTML2).toBe(
- ENABLE_V5_BREAKING_CHANGES
- ? `${ABS_FILL}<div>first 0</div></div>`
- : '<div>first 0</div>',
- );
+ expect(outerHTML2).toBe('<div>first 0</div>');
});
test('Should render nothing after the end', () => {
const outerHTML = renderForFrame(
@@ -173,7 +156,7 @@ test('Should render nothing after the end', () => {
</Series>
</WrapSequenceContext>,
);
- expect(outerHTML).toBe(ENABLE_V5_BREAKING_CHANGES ? `${ABS_FILL}</div>` : '');
+ expect(outerHTML).toBe('');
});
test('Should throw if invalid or no duration provided', () => {
expect(() => {
@@ -218,11 +201,7 @@ test('Should allow whitespace', () => {
</WrapSequenceContext>,
);
- expect(outerHtml).toBe(
- ENABLE_V5_BREAKING_CHANGES
- ? `${ABS_FILL}${ABS_FILL}<div>second 1</div></div></div>`
- : `${ABS_FILL}<div>second 1</div></div>`,
- );
+ expect(outerHtml).toBe(`${ABS_FILL}<div>second 1</div></div>`);
});
test('Handle empty Series.Sequence', () => {
expect(() =>
@@ -254,11 +233,7 @@ test('Should allow negative overlap prop', () => {
</Series>
</WrapSequenceContext>,
);
- expect(outerHTML).toBe(
- ENABLE_V5_BREAKING_CHANGES
- ? `${ABS_FILL}<div>first 4</div><div>second 0</div></div>`
- : '<div>first 4</div><div>second 0</div>',
- );
+ expect(outerHTML).toBe('<div>first 4</div><div>second 0</div>');
});
test('Should allow positive overlap prop', () => {
@@ -275,7 +250,7 @@ test('Should allow positive overlap prop', () => {
</Series>
</WrapSequenceContext>,
);
- expect(outerHTML).toBe(ENABLE_V5_BREAKING_CHANGES ? `${ABS_FILL}</div>` : '');
+ expect(outerHTML).toBe('');
});
test('Should disallow NaN as offset prop', () => {
@@ -340,11 +315,7 @@ test('Should cascade negative offset props', () => {
</Series>
</WrapSequenceContext>,
);
- expect(outerHTML).toBe(
- ENABLE_V5_BREAKING_CHANGES
- ? `${ABS_FILL}<div>third 0</div></div>`
- : '<div>third 0</div>',
- );
+ expect(outerHTML).toBe('<div>third 0</div>');
});
test('Should cascade positive offset props', () => {
@@ -364,11 +335,7 @@ test('Should cascade positive offset props', () => {
</Series>
</WrapSequenceContext>,
);
- expect(outerHTML).toBe(
- ENABLE_V5_BREAKING_CHANGES
- ? `${ABS_FILL}<div>third 0</div></div>`
- : '<div>third 0</div>',
- );
+ expect(outerHTML).toBe('<div>third 0</div>');
});
test('Allow durationInFrames as Infinity for last Series.Sequence', () => {
@@ -388,11 +355,7 @@ test('Allow durationInFrames as Infinity for last Series.Sequence', () => {
</Series>
</WrapSequenceContext>,
);
- expect(outerHTML).toBe(
- ENABLE_V5_BREAKING_CHANGES
- ? `${ABS_FILL}${ABS_FILL}<div>third 0</div></div></div>`
- : `${ABS_FILL}<div>third 0</div></div>`,
- );
+ expect(outerHTML).toBe(`${ABS_FILL}<div>third 0</div></div>`);
});
test('Disallow durationInFrames as Infinity for first n-1 Series.Sequence', () => {
diff --git a/packages/docs/docs/series.mdx b/packages/docs/docs/series.mdx
index 1b575deedb..d87dde8a7f 100644
--- a/packages/docs/docs/series.mdx
+++ b/packages/docs/docs/series.mdx
@@ -46,9 +46,18 @@ export const Example: React.FC = () => {
<SeriesExample type="base" />
-## API
+## `<Series>` props
+
+Since <AvailableFrom v="4.0.443" inline />, `<Series>` is a [`<Sequence>`](/docs/sequence) under the hood and accepts all of its props, with `layout` defaulting to `"none"`.
+
+Apart from the props listed below, all props from [`<Sequence>`](/docs/sequence) are accepted.
+
+### `layout?`
+
+Either `"absolute-fill"` or `"none"` _(default)_. If set to `"absolute-fill"`, the series is wrapped in an [`<AbsoluteFill>`](/docs/absolute-fill) container.
+
+## `<Series.Sequence>` props
-The `<Series />` component takes no props. It may only contain a list of `<Series.Sequence />` instances.
A `<Series.Sequence />` component accepts the following props:
### `durationInFrames?`