🎥 Make videos programmatically with React
templates page
Jonny Burger399db1992475
diff --git a/packages/create-video/src/templates.tsx b/packages/create-video/src/templates.tsxindex 3e8af1c06c..dcfa8623b8 100644--- a/packages/create-video/src/templates.tsx+++ b/packages/create-video/src/templates.tsx@@ -47,7 +47,7 @@ export const FEATURED_TEMPLATES: Template[] = [shortName: 'Hello World',org: 'remotion-dev',repoName: 'template-helloworld',- description: 'The default starter template (recommended)',+ description: 'A "Hello World" starter template',longerDescription:'A basic template with TypeScript, Prettier and ESLint preconfigured. Our recommended choice for beginners.',promoVideo: {@@ -59,21 +59,23 @@ export const FEATURED_TEMPLATES: Template[] = [type: 'video',defaultBranch: 'main',},+{- homePageLabel: 'JavaScript',- shortName: 'Hello World (JavaScript)',+ homePageLabel: 'Next.js',+ shortName: 'Next.js',org: 'remotion-dev',- repoName: 'template-helloworld-javascript',- description: 'The default starter template in plain JS',+ repoName: 'template-next',+ description: 'SaaS template for video generation apps',longerDescription:- 'The Hello World template, but in plain JavaScript. Recommended for people who detest TypeScript.',- promoVideo: {- muxId: 'dRIuc00f8QWnKedM8GBGPqXJWqU01DPJFgPTHpJgixxas',- width: 1920,- height: 1080,+ 'A software-as-a-service starter kit which has the Remotion Player and rendering via Remotion Lambda built-in. Our recommended choice for people who want to build a video generation app.',+ promoBanner: {+ width: 1280,+ height: 720,+ // TODO: Update this image+ src: '/img/remix-template.png',},- cliId: 'javascript',- type: 'video',+ cliId: 'next',+ type: 'image',defaultBranch: 'main',},{@@ -94,21 +96,20 @@ export const FEATURED_TEMPLATES: Template[] = [defaultBranch: 'main',},{- homePageLabel: 'Next.js',- shortName: 'Next.js',+ homePageLabel: 'JavaScript',+ shortName: 'Hello World (JavaScript)',org: 'remotion-dev',- repoName: 'template-next',- description: 'SaaS template for video generation apps',+ repoName: 'template-helloworld-javascript',+ description: 'The default starter template in plain JS',longerDescription:- 'A software-as-a-service starter kit which has the Remotion Player and rendering via Remotion Lambda built-in. Our recommended choice for people who want to build a video generation app.',- promoBanner: {- width: 1280,- height: 720,- // TODO: Update this image- src: '/img/remix-template.png',+ 'The Hello World template, but in plain JavaScript. Recommended for people who detest TypeScript.',+ promoVideo: {+ muxId: 'dRIuc00f8QWnKedM8GBGPqXJWqU01DPJFgPTHpJgixxas',+ width: 1920,+ height: 1080,},- cliId: 'next',- type: 'image',+ cliId: 'javascript',+ type: 'video',defaultBranch: 'main',},{diff --git a/packages/docs/src/components/ChooseTemplate.tsx b/packages/docs/src/components/ChooseTemplate.tsxindex 63bfefc564..ea656416f3 100644--- a/packages/docs/src/components/ChooseTemplate.tsx+++ b/packages/docs/src/components/ChooseTemplate.tsx@@ -2,142 +2,15 @@ import type { Template } from "create-video";import { CreateVideoInternals } from "create-video";import React, { useCallback, useEffect, useRef, useState } from "react";import { chunk } from "../helpers/chunk";-import { useMobileLayout } from "../helpers/mobile-layout";import { NavigateLeft, NavigateRight } from "./ArrowRight";-import { Blank } from "./icons/blank";-import { Cubes } from "./icons/cubes";-import { JSIcon } from "./icons/js";-import { OverlayIcon } from "./icons/overlay";-import { RemixIcon } from "./icons/remix";-import { SkiaIcon } from "./icons/skia";-import { StillIcon } from "./icons/still";-import { Tailwind } from "./icons/tailwind";-import { TypeScriptIcon } from "./icons/ts";-import { TTSIcon } from "./icons/tts";-import { Waveform } from "./icons/waveform";+import { IconForTemplate } from "./IconForTemplate";import { TemplateIcon } from "./TemplateIcon";import { TemplateModal } from "./TemplateModal";-const IconForTemplate: React.FC<{- template: Template;-}> = ({ template }) => {- if (template.homePageLabel === "TypeScript") {- return (- <TypeScriptIcon- style={{- height: 48,- }}- />- );- }-- if (template.homePageLabel === "Blank") {- return (- <Blank- style={{- height: 36,- }}- />- );- }-- if (template.homePageLabel === "JavaScript") {- return (- <JSIcon- style={{- height: 40,- }}- />- );- }-- if (template.homePageLabel === "3D") {- return (- <Cubes- style={{- height: 36,- }}- />- );- }-- if (template.homePageLabel === "Stills") {- return (- <StillIcon- style={{- height: 36,- }}- />- );- }-- if (template.homePageLabel === "Audiogram") {- return (- <Waveform- style={{- height: 36,- }}- />- );- }-- if (template.homePageLabel === "TTS") {- return (- <TTSIcon- style={{- height: 36,- }}- />- );- }-- if (template.homePageLabel === "Tailwind") {- return (- <Tailwind- style={{- height: 36,- }}- />- );- }-- if (template.homePageLabel === "Skia") {- return (- <SkiaIcon- style={{- height: 32,- }}- />- );- }-- if (template.homePageLabel === "Remix") {- return (- <RemixIcon- style={{- height: 32,- }}- />- );- }-- if (template.homePageLabel === "Overlay") {- return <OverlayIcon style={{ height: 42 }} />;- }-- return (- <Blank- style={{- height: 40,- }}- />- );-};-export const ChooseTemplate: React.FC = () => {const [modal, setModal] = useState<Template | null>(null);- const mobileLayout = useMobileLayout();+ const mobileLayout = true;const onClick = useCallback((template: Template) => {setModal(template);@@ -157,7 +30,7 @@ export const ChooseTemplate: React.FC = () => {const onClickRight = useCallback(() => {scrollable.current.scrollTo({- left: 1000,+ left: 1900,});}, []);diff --git a/packages/docs/src/components/IconForTemplate.tsx b/packages/docs/src/components/IconForTemplate.tsxnew file mode 100644index 0000000000..1b35057150--- /dev/null+++ b/packages/docs/src/components/IconForTemplate.tsx@@ -0,0 +1,135 @@+import type { Template } from "create-video";+import React from "react";+import { Blank } from "./icons/blank";+import { Cubes } from "./icons/cubes";+import { JSIcon } from "./icons/js";+import { NextIcon } from "./icons/next";+import { OverlayIcon } from "./icons/overlay";+import { RemixIcon } from "./icons/remix";+import { SkiaIcon } from "./icons/skia";+import { StillIcon } from "./icons/still";+import { Tailwind } from "./icons/tailwind";+import { TypeScriptIcon } from "./icons/ts";+import { TTSIcon } from "./icons/tts";+import { Waveform } from "./icons/waveform";++export const IconForTemplate: React.FC<{+ template: Template;+ scale: number;+}> = ({ template, scale = 1 }) => {+ if (template.homePageLabel === "TypeScript") {+ return (+ <TypeScriptIcon+ style={{+ height: scale * 48,+ }}+ />+ );+ }++ if (template.homePageLabel === "Blank") {+ return (+ <Blank+ style={{+ height: scale * 36,+ }}+ />+ );+ }++ if (template.homePageLabel === "JavaScript") {+ return (+ <JSIcon+ style={{+ height: scale * 40,+ }}+ />+ );+ }++ if (template.homePageLabel === "3D") {+ return (+ <Cubes+ style={{+ height: scale * 36,+ }}+ />+ );+ }++ if (template.homePageLabel === "Stills") {+ return (+ <StillIcon+ style={{+ height: scale * 36,+ }}+ />+ );+ }++ if (template.homePageLabel === "Audiogram") {+ return (+ <Waveform+ style={{+ height: scale * 36,+ }}+ />+ );+ }++ if (template.homePageLabel === "TTS") {+ return (+ <TTSIcon+ style={{+ height: scale * 36,+ }}+ />+ );+ }++ if (template.homePageLabel === "Tailwind") {+ return (+ <Tailwind+ style={{+ height: scale * 36,+ }}+ />+ );+ }++ if (template.homePageLabel === "Skia") {+ return (+ <SkiaIcon+ style={{+ height: scale * 32,+ }}+ />+ );+ }++ if (template.homePageLabel === "Remix") {+ return (+ <RemixIcon+ style={{+ height: scale * 32,+ }}+ />+ );+ }++ if (template.homePageLabel === "Overlay") {+ return <OverlayIcon style={{ height: scale * 42 }} />;+ }++ if (template.cliId === "next") {+ return <NextIcon style={{ height: scale * 42 }} />;+ }++ return (+ <Blank+ style={{+ height: scale * 40,+ }}+ />+ );+};diff --git a/packages/docs/src/components/icons/next.tsx b/packages/docs/src/components/icons/next.tsxnew file mode 100644index 0000000000..2464bd59c8--- /dev/null+++ b/packages/docs/src/components/icons/next.tsx@@ -0,0 +1,64 @@+import React from "react";++export const NextIcon: React.FC<{+ style: React.CSSProperties;+}> = ({ style }) => {+ return (+ <svg+ fill="none"+ viewBox="0 0 180 180"+ style={style}+ xmlns="http://www.w3.org/2000/svg"+ >+ <mask+ height="180"+ id="mask0_292_250"+ maskUnits="userSpaceOnUse"+ style={{ maskType: "alpha" }}+ width="180"+ x="0"+ y="0"+ >+ <circle cx="90" cy="90" fill="currentcolor" r="90" />+ </mask>+ <g mask="url(#mask0_292_250)">+ <circle cx="90" cy="90" fill="currentcolor" r="90" />+ <path+ d="M149.508 157.52L69.142 54H54V125.97H66.1136V69.3836L139.999 164.845C143.333 162.614 146.509 160.165 149.508 157.52Z"+ fill="url(#paint0_linear_292_250)"+ />+ <rect+ fill="url(#paint1_linear_292_250)"+ height="72"+ width="12"+ x="115"+ y="54"+ />+ </g>+ <defs>+ <linearGradient+ gradientUnits="userSpaceOnUse"+ id="paint0_linear_292_250"+ x1="109"+ x2="144.5"+ y1="116.5"+ y2="160.5"+ >+ <stop stopColor="var(--background)" />+ <stop offset="1" stopColor="var(--background)" stopOpacity="0" />+ </linearGradient>+ <linearGradient+ gradientUnits="userSpaceOnUse"+ id="paint1_linear_292_250"+ x1="121"+ x2="120.799"+ y1="54"+ y2="106.875"+ >+ <stop stopColor="var(--background)" />+ <stop offset="1" stopColor="var(--background)" stopOpacity="0" />+ </linearGradient>+ </defs>+ </svg>+ );+};diff --git a/packages/docs/src/components/icons/overlay.tsx b/packages/docs/src/components/icons/overlay.tsxindex b69b3f7ee0..8c599f7784 100644--- a/packages/docs/src/components/icons/overlay.tsx+++ b/packages/docs/src/components/icons/overlay.tsx@@ -4,8 +4,6 @@ import React from "react";export const OverlayIcon: React.FC<SVGProps<SVGSVGElement>> = (props) => {return (<svg- width="576"- height="512"viewBox="0 0 576 512"fill="none"xmlns="http://www.w3.org/2000/svg"diff --git a/packages/docs/src/pages/templates/index.tsx b/packages/docs/src/pages/templates/index.tsxnew file mode 100644index 0000000000..b7d4b80d06--- /dev/null+++ b/packages/docs/src/pages/templates/index.tsx@@ -0,0 +1,98 @@+import Layout from "@theme/Layout";+import { CreateVideoInternals } from "create-video";+import React from "react";+import { IconForTemplate } from "../../components/IconForTemplate";+import styles from "./styles.module.css";++const content: React.CSSProperties = {+ maxWidth: 1000,+ margin: "auto",+ padding: "0 20px",+};++const para: React.CSSProperties = {+ textAlign: "center",+ marginBottom: 50,+};++export default () => {+ return (+ <Layout>+ <div style={content}>+ <h1 className={styles.title}>+ Find the right+ <br />+ template+ </h1>+ <p style={para}>+ Jumpstart your project with a template that fits your usecase.+ </p>+ <div className={styles.grid}>+ {CreateVideoInternals.FEATURED_TEMPLATES.map((template) => {+ return (+ <Item+ key={template.cliId}+ onClick={() => onClick(template)}+ label={template.homePageLabel}+ description={template.description}+ >+ <IconForTemplate scale={0.7} template={template} />+ </Item>+ );+ })}+ </div>+ </div>+ <br />+ <br />+ <br />+ <br />+ </Layout>+ );+};++const Item: React.FC<{+ label: string;+ description: React.ReactNode;+ children: React.ReactNode;+ onClick: () => void;+}> = ({ children, label, onClick, description }) => {+ return (+ <a className={styles.item} style={outer} onClick={onClick}>+ <div+ style={{ flexDirection: "row", display: "flex", alignItems: "center" }}+ >+ <div style={icon}>{children}</div>+ <div style={labelStyle}>{label}</div>+ </div>+ <div>+ <p style={descriptionStyle}>{description}</p>+ </div>+ </a>+ );+};++const outer: React.CSSProperties = {+ display: "flex",+ cursor: "pointer",+};++const icon: React.CSSProperties = {+ display: "flex",+ margin: 0,+ marginRight: 10,+ height: 30,+ width: 30,+ justifyContent: "center",+ alignItems: "center",+};++const labelStyle: React.CSSProperties = {+ fontWeight: "bold",+};++const descriptionStyle: React.CSSProperties = {+ fontSize: 14,+ marginTop: 10,+ color: "var(--light-text-color)",+ marginBottom: 10,+};diff --git a/packages/docs/src/pages/templates/styles.module.css b/packages/docs/src/pages/templates/styles.module.cssnew file mode 100644index 0000000000..f6537aa16d--- /dev/null+++ b/packages/docs/src/pages/templates/styles.module.css@@ -0,0 +1,26 @@+.title {+ font-size: 5em;+ font-weight: 900;+ line-height: 1;+ margin-top: 75px;+ text-align: center;+ margin-bottom: 40px;+}++.grid {+ display: grid;+ grid-template-columns: 1fr 1fr 1fr;+ grid-auto-rows: 1fr;+ grid-gap: 15px;+}++.item {+ border-radius: 5px;+ display: flex;+ flex-direction: column;+ overflow: hidden;+ position: relative;+ color: var(--text-color);+ border: 1px solid var(--ifm-color-emphasis-300);+ padding: 14px;+}