Skip to content

🎥 Make videos programmatically with React

Promote `<Timeline>` component on remotion.dev

Jonny Burger4902efa51181
diff --git a/packages/docs/docs/building-a-timeline.mdx b/packages/docs/docs/building-a-timeline.mdx
index 776830f757..8b19d35b10 100644
--- a/packages/docs/docs/building-a-timeline.mdx
+++ b/packages/docs/docs/building-a-timeline.mdx
@@ -2,6 +2,7 @@
image: /generated/articles-docs-building-a-timeline.png
id: building-a-timeline
title: Build a timeline-based video editor
+sidebar_label: Build a timeline
crumb: 'Building video apps'
---
@@ -12,11 +13,20 @@ Read this document for guidance on building a video editor with the following ch
- Items can be arbitrarily placed on a track
- Items can be of different types (e.g. video, audio, text, etc.)
+## Get the `<Timeline>` component
+
+We offer a copy-pasteable `<Timeline>` component that follows Remotion's best practices and also already handles zoom.
+If you want to save time and get a head start, you can [purchase it in the Remotion Store](https://www.remotion.pro/timeline).
+
+You can also build your own timeline component.
+The following steps will use the same approach we used to build our Timeline component.
+
+## Build your own timeline
+
<img src="/img/timelineitems.png" />
<br />
<br />
-<Step>1</Step> Define a TypeScript type <code>Item</code> defining the different
-item types. Create another one for defining the shape of a <code>Track</code>:
+<Step>1</Step> Define a TypeScript type <code>Item</code> defining the different item types. Create another one for defining the shape of a <code>Track</code>:
```tsx twoslash title="types.ts"
type BaseItem = {
@@ -113,11 +123,7 @@ const Track: React.FC<{
<AbsoluteFill>
{track.items.map((item) => {
return (
- <Sequence
- key={item.id}
- from={item.from}
- durationInFrames={item.durationInFrames}
- >
+ <Sequence key={item.id} from={item.from} durationInFrames={item.durationInFrames}>
<ItemComp item={item} />
</Sequence>
);
@@ -213,22 +219,13 @@ export const Editor = () => {
return (
<>
- <Player
- component={Main}
- fps={30}
- inputProps={inputProps}
- durationInFrames={600}
- compositionWidth={1280}
- compositionHeight={720}
- />
+ <Player component={Main} fps={30} inputProps={inputProps} durationInFrames={600} compositionWidth={1280} compositionHeight={720} />
</>
);
};
```
-<Step>4</Step> Build a timeline component: You now have access to the <code>
- tracks
-</code> state and can update it using the <code>setTracks</code> function.
+<Step>4</Step> Build a timeline component: You now have access to the <code>tracks</code> state and can update it using the <code>setTracks</code> function.
We do not currently provide samples how to build a timeline component, since everybody has different needs and styling preferences.
@@ -268,14 +265,7 @@ const Editor: React.FC = () => {
return (
<>
- <Player
- component={Main}
- fps={30}
- inputProps={inputProps}
- durationInFrames={600}
- compositionWidth={1280}
- compositionHeight={720}
- />
+ <Player component={Main} fps={30} inputProps={inputProps} durationInFrames={600} compositionWidth={1280} compositionHeight={720} />
<Timeline tracks={tracks} setTracks={setTracks} />
</>
);
diff --git a/packages/docs/src/components/icons/timeline.tsx b/packages/docs/src/components/icons/timeline.tsx
new file mode 100644
index 0000000000..070dc6f0b4
--- /dev/null
+++ b/packages/docs/src/components/icons/timeline.tsx
@@ -0,0 +1,27 @@
+import type {SVGProps} from 'react';
+import React from 'react';
+
+export const TimelineIcon: React.FC<SVGProps<SVGSVGElement>> = (props) => {
+ return (
+ <svg
+ {...props}
+ viewBox="0 0 56 69"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ <path
+ d="M51.4313 38.0917L31.4998 52.4424C30.2419 53.3481 28.5581 53.3925 27.2543 52.5543L4.73299 38.0763C3.65291 37.382 3 36.1861 3 34.9021V6.77359C3 4.68949 4.68949 3 6.77358 3H49.2264C51.3105 3 53 4.68949 53 6.77358V35.0293C53 36.243 52.4163 37.3826 51.4313 38.0917Z"
+ stroke="black"
+ strokeWidth="5"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ />
+ <path
+ d="M29 55L29 66"
+ stroke="black"
+ strokeWidth="5"
+ strokeLinecap="square"
+ />
+ </svg>
+ );
+};
diff --git a/packages/docs/src/pages/templates/index.tsx b/packages/docs/src/pages/templates/index.tsx
index fd44f025ac..fcb79a1da7 100644
--- a/packages/docs/src/pages/templates/index.tsx
+++ b/packages/docs/src/pages/templates/index.tsx
@@ -7,6 +7,7 @@ import React from 'react';
import {IconForTemplate} from '../../components/IconForTemplate';
import {Seo} from '../../components/Seo';
import {SkiaIcon} from '../../components/icons/skia';
+import {TimelineIcon} from '../../components/icons/timeline';
import styles from './styles.module.css';
const content: React.CSSProperties = {
@@ -160,6 +161,25 @@ export default () => {
/>
</Item>
</Link>
+ <Link
+ key={'map'}
+ className={styles.item}
+ style={outer}
+ to={`https://www.remotion.pro/timeline`}
+ >
+ <Item
+ label={'<Timeline />'}
+ description={
+ 'A copy pasteable component for timeline-based editing'
+ }
+ >
+ <TimelineIcon
+ style={{
+ height: 0.7 * 32,
+ }}
+ />
+ </Item>
+ </Link>
</div>
<br />