Skip to content

🎥 Make videos programmatically with React

hey

Jonny Burger3acd0691cae8
diff --git a/packages/docs/src/remotion/HomepageVideo/Card.tsx b/packages/docs/src/remotion/HomepageVideo/Card.tsx
new file mode 100644
index 0000000000..91487f569b
--- /dev/null
+++ b/packages/docs/src/remotion/HomepageVideo/Card.tsx
@@ -0,0 +1,31 @@
+import React from "react";
+
+export const paddingAndMargin = 20;
+const height = 360;
+const width = 640;
+export const cardHeight = (height - paddingAndMargin * 3) / 2;
+export const cardWidth = (width - paddingAndMargin * 3) / 2;
+
+export const Card: React.FC<{
+ index: number;
+}> = ({ index }) => {
+ const x =
+ index % 2 === 0 ? paddingAndMargin : cardWidth + paddingAndMargin * 2;
+ const y = index < 2 ? paddingAndMargin : cardHeight + paddingAndMargin * 2;
+
+ return (
+ <div
+ style={{
+ backgroundColor: "green",
+ borderRadius: 13,
+ width: cardWidth,
+ height: cardHeight,
+ position: "absolute",
+ left: x,
+ top: y,
+ }}
+ >
+ hi there
+ </div>
+ );
+};
diff --git a/packages/docs/src/remotion/HomepageVideo/Comp.tsx b/packages/docs/src/remotion/HomepageVideo/Comp.tsx
new file mode 100644
index 0000000000..285e608906
--- /dev/null
+++ b/packages/docs/src/remotion/HomepageVideo/Comp.tsx
@@ -0,0 +1,18 @@
+import React from "react";
+import { AbsoluteFill } from "remotion";
+import { Card, paddingAndMargin } from "./Card";
+
+export const Comp: React.FC = () => {
+ return (
+ <AbsoluteFill
+ style={{
+ padding: paddingAndMargin,
+ }}
+ >
+ <Card index={0} />
+ <Card index={1} />
+ <Card index={2} />
+ <Card index={3} />
+ </AbsoluteFill>
+ );
+};
diff --git a/packages/docs/src/remotion/Root.tsx b/packages/docs/src/remotion/Root.tsx
index bac8077ab9..0edb208102 100644
--- a/packages/docs/src/remotion/Root.tsx
+++ b/packages/docs/src/remotion/Root.tsx
@@ -1,11 +1,12 @@
import { CreateVideoInternals } from "create-video";
import React from "react";
-import { Folder, Still } from "remotion";
+import { Composition, Folder, Still } from "remotion";
import { articles } from "../data/articles";
import { experts } from "../data/experts";
import { AllTemplates } from "./AllTemplates";
import { Article } from "./Article";
import { Expert } from "./Expert";
+import { Comp } from "./HomepageVideo/Comp";
import { TemplateComp } from "./Template";
export const RemotionRoot: React.FC = () => {
@@ -65,6 +66,14 @@ export const RemotionRoot: React.FC = () => {
height={630}
id="template-all"
/>
+ <Composition
+ component={Comp}
+ id="HomepageVideo"
+ width={640}
+ height={360}
+ durationInFrames={120}
+ fps={30}
+ />
</>
);
};