🎥 Make videos programmatically with React
finalize
Jonny Burgera29d323af0d3
diff --git a/packages/docs/components/LandingPage/GetStartedStrip.tsx b/packages/docs/components/LandingPage/GetStartedStrip.tsxnew file mode 100644index 0000000000..e68a946bd7--- /dev/null+++ b/packages/docs/components/LandingPage/GetStartedStrip.tsx@@ -0,0 +1,97 @@+import React, { useState } from "react";+import styled, { keyframes } from "styled-components";+import { BlueButton } from "../layout/Button";+import { GithubButton } from "./GithubButton";++const Row = styled.div`+ display: flex;+ flex-direction: row;+ align-items: center;+`;++const CodeBlock = styled.div`+ background-color: #333;+ padding: 12px 16px;+ border-radius: 8px;+ color: white;+ font: var(--ifm-code-font-size) / var(--ifm-pre-line-height)+ var(--ifm-font-family-monospace);+ cursor: pointer;+ &:hover {+ background-color: #444;+ }+`;++const A = styled.a`+ &:hover {+ text-decoration: none;+ }+`;++const animation = keyframes`+ 0% {+ transform: translateY(-18px);+ opacity: 0;+ }++ 30% {+ opacity: 0.7;+ }+ 70% {+ opacity: 0.7;+ }+ 100% {+ transform: translateY(-23px);+ opacity: 0;+ }+`;++const Copied = styled.div`+ position: absolute;+ animation: ${animation} 0.7s linear;+ z-index: 0;+ animation-fill-mode: forwards;+ top: 0;+ font: var(--ifm-code-font-size) / var(--ifm-pre-line-height)+ var(--ifm-font-family-monospace);+ font-size: 13px;+ width: 100%;+ text-align: center;+`;++export const GetStarted: React.FC = () => {+ const [clicked, setClicked] = useState<number | null>(null);+ return (+ <>+ <Row>+ <div style={{ position: "relative" }}>+ {clicked ? <Copied key={clicked}>Copied!</Copied> : null}+ <CodeBlock+ onClick={() => {+ navigator.clipboard.writeText("npm init video");++ setClicked(Date.now());+ }}+ title="Click to copy"+ >+ $ npm init video+ </CodeBlock>+ </div>+ <div style={{ width: 10 }}></div>+ <A href="/docs">+ <BlueButton size="sm" loading={false} fullWidth={false}>+ Docs+ </BlueButton>+ </A>+ <div style={{ width: 10 }}></div>+ <A href="https://github.com/JonnyBurger/remotion">+ <BlueButton size="sm" loading={false} fullWidth={false}>+ <GithubButton></GithubButton>+ </BlueButton>+ </A>+ </Row>+ <div style={{ height: 10 }}></div>+ <Row></Row>+ </>+ );+};diff --git a/packages/docs/components/LandingPage/GithubButton.tsx b/packages/docs/components/LandingPage/GithubButton.tsxnew file mode 100644index 0000000000..ab120f0468--- /dev/null+++ b/packages/docs/components/LandingPage/GithubButton.tsx@@ -0,0 +1,50 @@+import React, { useEffect, useState } from "react";+import styled from "styled-components";++const Container = styled.div`+ display: flex;+ flex-direction: row;+ font-weight: bold;+ justify-content: center;+ align-items: center;+`;++const Stars = styled.div`+ font-size: 0.75em;+ margin-top: 2.5px;+`;++const GithubIcon: React.FC = () => {+ return (+ <svg viewBox="0 0 496 512" style={{ height: 24, marginRight: 8 }}>+ <path+ fill="currentColor"+ d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"+ ></path>+ </svg>+ );+};++export const GithubButton: React.FC = () => {+ const [stars, setStars] = useState(null);++ useEffect(() => {+ fetch(`https://api.github.com/repos/JonnyBurger/remotion`)+ .then((res) => res.json())+ .then((json) => json.watchers)+ .then((stars) => {+ setStars(stars);+ })+ .catch((err) => {+ console.log(err);+ setStars(null);+ });+ }, []);++ return (+ <Container>+ <GithubIcon></GithubIcon> <div>Github</div>{" "}+ <div style={{ width: 8 }}></div> <Stars>{stars ? stars : null}</Stars>+ </Container>+ );+};diff --git a/packages/docs/components/LandingPage/PlayerPreview.tsx b/packages/docs/components/LandingPage/PlayerPreview.tsxindex 49741b6023..93d25dbe43 100644--- a/packages/docs/components/LandingPage/PlayerPreview.tsx+++ b/packages/docs/components/LandingPage/PlayerPreview.tsx@@ -6,15 +6,21 @@ const Container = styled.div`flex: 1;cursor: pointer;position: relative;+ &:hover {+ transform: scale(1.015);+ }+ transition: transform 0.3s;`;+const A = styled.a``;+export const PlayerPreview: React.FC = () => {return (- <a href="https://www.youtube.com/watch?v=gwlDorikqgY" target="_blank">+ <A href="https://www.youtube.com/watch?v=gwlDorikqgY" target="_blank"><Container><imgstyle={{- boxShadow: "0 0 8px rgba(0, 0, 0, 0.2)",+ boxShadow: "var(--box-shadow)",}}src="http://i3.ytimg.com/vi/gwlDorikqgY/maxresdefault.jpg"></img>@@ -31,6 +37,6 @@ export const PlayerPreview: React.FC = () => {Watch 2 min video</div></Container>- </a>+ </A>);};diff --git a/packages/docs/components/LandingPage/Programmatic.tsx b/packages/docs/components/LandingPage/Programmatic.tsxindex 4beee338ed..c5d0f08a36 100644--- a/packages/docs/components/LandingPage/Programmatic.tsx+++ b/packages/docs/components/LandingPage/Programmatic.tsx@@ -48,7 +48,7 @@ export const ProgrammaticContent: React.FC<{ data: GithubResponse | null }> = ({if (isIntersecting) {playerRef.current?.play();}- }, [data]);+ }, [data, isIntersecting]);return (<MobilePlayer ref={containerRef}>diff --git a/packages/docs/components/LandingPage/WriteInReact.tsx b/packages/docs/components/LandingPage/WriteInReact.tsxindex f959a4fbcf..a1cce81c39 100644--- a/packages/docs/components/LandingPage/WriteInReact.tsx+++ b/packages/docs/components/LandingPage/WriteInReact.tsx@@ -1,10 +1,8 @@-import TabItem from "@theme/TabItem";-import Tabs from "@theme/Tabs";import React, { useState } from "react";import styled from "styled-components";-import headerStyles from "../../src/pages/header.module.css";import styles from "../../src/pages/styles.module.css";import { mobile } from "../layout/layout";+import { GetStarted } from "./GetStartedStrip";import { PlayerPreview } from "./PlayerPreview";const Row = styled.div`@@ -69,22 +67,8 @@ export const WriteInReact: React.FC = () => {Use your React knowledge to create real MP4 videos. <br /> Scale yourvideo production using server-side rendering and parametrization.</p>- <Tabs- className={headerStyles.tabContainer}- defaultValue="npm"- values={[- { label: "NPM", value: "npm" },- { label: "Yarn", value: "yarn" },- ]}- >- <TabItem value="npm">- <Snippet snippetValue={"npm init video"} />- </TabItem>- <TabItem value="yarn">- <Snippet snippetValue={"yarn create video"} />- </TabItem>- </Tabs>+ <GetStarted></GetStarted></div><Right><PlayerPreview />diff --git a/packages/docs/components/LandingPage/if-you-know-react.tsx b/packages/docs/components/LandingPage/if-you-know-react.tsxindex d50853e469..b85cb68dfa 100644--- a/packages/docs/components/LandingPage/if-you-know-react.tsx+++ b/packages/docs/components/LandingPage/if-you-know-react.tsx@@ -1,5 +1,6 @@import React from "react";import styled from "styled-components";+import { BlueButton } from "../layout/Button";import { mobile } from "../layout/layout";import { CodeExample } from "./CodeExample";@@ -35,24 +36,22 @@ const Rea = styled.span`-webkit-background-clip: text;`;-const Button = styled.div`- padding: 10px 16px;- background-color: rgb(66, 144, 245);+const A = styled.a`display: inline-block;- border-radius: 3px;- color: white;- font-weight: bold;${mobile`margin-bottom: 80px;- `}+ `};+ &:hover {+ text-decoration: none;+ }`;export const IfYouKnowReact: React.FC = () => {return (<Row><CodeExample></CodeExample>- <div style={{ width: 80 }}></div>+ <div style={{ width: 40 }}></div><div><Title>If you know <Rea>React</Rea> <br />@@ -63,9 +62,11 @@ export const IfYouKnowReact: React.FC = () => {rules of React stay the same. <br />Learn the fundamentals in just a few minutes:</p>- <a href="/docs/the-fundamentals">- <Button>Learn Remotion</Button>- </a>+ <A href="/docs/the-fundamentals">+ <BlueButton size="sm" fullWidth={false} loading={false}>+ Learn Remotion+ </BlueButton>+ </A></div></Row>);diff --git a/packages/docs/components/LandingPage/parametrize.tsx b/packages/docs/components/LandingPage/parametrize.tsxindex 1ef4553adf..5545836d20 100644--- a/packages/docs/components/LandingPage/parametrize.tsx+++ b/packages/docs/components/LandingPage/parametrize.tsx@@ -1,5 +1,6 @@import React, { useEffect, useReducer, useRef, useState } from "react";import styled from "styled-components";+import { BlueButton } from "../layout/Button";import { mobile } from "../layout/layout";import { GithubResponse } from "./GithubDemo";import { ProgrammaticContent } from "./Programmatic";@@ -152,8 +153,13 @@ export const Parametrize: React.FC = () => {<formonSubmit={(e) => {e.preventDefault();+ if (!ref.current?.value) {+ return;+ }+setUsername(ref.current?.value as string);}}+ style={{ display: "flex", flexDirection: "row" }}><InputautoFocus@@ -162,13 +168,19 @@ export const Parametrize: React.FC = () => {placeholder="Your Github username"></Input>{" "}<div style={{ width: 8, display: "inline-block" }}></div>- <SubmitButton- disabled={state.type === "loading"}- style={{ opacity: state.type === "loading" ? 0.5 : 1 }}- onClick={() => setUsername(ref.current?.value as string)}+ <BlueButton+ loading={state.type === "loading"}+ fullWidth={false}+ size="sm"+ onClick={() => {+ if (!ref.current?.value) {+ return;+ }+ setUsername(ref.current?.value as string);+ }}>Show video- </SubmitButton>+ </BlueButton></form></div>{state.type === "error" ? (diff --git a/packages/docs/components/layout/ButtonSpinner.tsx b/packages/docs/components/layout/ButtonSpinner.tsxindex 6c9bf52d2b..9e0dd26960 100644--- a/packages/docs/components/layout/ButtonSpinner.tsx+++ b/packages/docs/components/layout/ButtonSpinner.tsx@@ -1,3 +1,4 @@+import React from "react";import styled, { keyframes } from "styled-components";const radius = 10;diff --git a/packages/docs/src/css/custom.css b/packages/docs/src/css/custom.cssindex 1c9efd6d38..12f8c3dee0 100644--- a/packages/docs/src/css/custom.css+++ b/packages/docs/src/css/custom.css@@ -33,7 +33,7 @@--clear-hover: rgba(255, 255, 255, 0.06);--blue-button-color: white;--light-text-color: #aaa;- --box-shadow: 0 1px 4px rgba(255, 255, 255, 0.2);+ --box-shadow: 0 1px 8px rgba(255, 255, 255, 0.2);}[data-theme="light"] .docusaurus-highlight-code-line {