Skip to content

🎥 Make videos programmatically with React

template page

Jonny Burgerd80afcca0c7f
diff --git a/packages/docs/render-cards.mjs b/packages/docs/render-cards.mjs
index 3457c2d47d..f419558885 100644
--- a/packages/docs/render-cards.mjs
+++ b/packages/docs/render-cards.mjs
@@ -8,8 +8,8 @@ const serveUrl = await bundle({
});
const compositions = await getCompositions(serveUrl);
-for (const composition of compositions.filter((c) =>
- c.id.startsWith("expert")
+for (const composition of compositions.filter(
+ (c) => c.id.startsWith("expert") || c.id.startsWith("template")
)) {
await renderStill({
composition,
diff --git a/packages/docs/route-plugin/index.js b/packages/docs/route-plugin/index.js
index cca3a77d9d..b4186a790b 100644
--- a/packages/docs/route-plugin/index.js
+++ b/packages/docs/route-plugin/index.js
@@ -9,16 +9,39 @@ module.exports = function () {
path.join(__dirname, "../src/data/experts.tsx"),
"utf-8"
);
- const slugs = experts
+ const templates = fs.readFileSync(
+ path.join(
+ __dirname,
+ "../../../packages/create-video/src/templates.tsx"
+ ),
+ "utf-8"
+ );
+ const expertSlugs = experts
.split("\n")
.map((a) => {
return a.match(/slug:\s"(.*)"/)?.[1];
})
.filter(Boolean);
- return slugs;
+
+ const templateSlugs = templates
+ .split("\n")
+ .map((a) => {
+ return a.match(/cliId:\s'(.*)'/)?.[1];
+ })
+ .filter(Boolean);
+
+ if (templateSlugs.length === 0) {
+ throw new Error("expected templates");
+ }
+
+ if (expertSlugs.length === 0) {
+ throw new Error("expected experts");
+ }
+
+ return { expertSlugs, templateSlugs };
},
- contentLoaded({ content, actions }) {
- content.forEach((c) => {
+ contentLoaded({ content: { expertSlugs, templateSlugs }, actions }) {
+ expertSlugs.forEach((c) => {
actions.addRoute({
path: "/experts/" + c,
component: "@site/src/components/ExpertPage.tsx",
@@ -26,6 +49,15 @@ module.exports = function () {
exact: true,
});
});
+ console.log(templateSlugs);
+ templateSlugs.forEach((c) => {
+ actions.addRoute({
+ path: "/templates/" + c,
+ component: "@site/src/components/TemplatePage.tsx",
+ modules: {},
+ exact: true,
+ });
+ });
},
};
};
diff --git a/packages/docs/src/components/BackButton.tsx b/packages/docs/src/components/BackButton.tsx
new file mode 100644
index 0000000000..8c2299d007
--- /dev/null
+++ b/packages/docs/src/components/BackButton.tsx
@@ -0,0 +1,38 @@
+import React from "react";
+
+export const BackButton: React.FC<{
+ color: string;
+ text: string;
+ link: string;
+}> = ({ color, text, link }) => {
+ const backLink: React.CSSProperties = {
+ color,
+ fontFamily: "GTPlanar",
+ fontWeight: 500,
+ display: "inline-flex",
+ justifyContent: "center",
+ alignItems: "center",
+ };
+
+ const backIcon: React.CSSProperties = {
+ height: 20,
+ color,
+ marginRight: 15,
+ display: "inline-block",
+ };
+ return (
+ <a style={backLink} href={link}>
+ <svg
+ style={backIcon}
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 448 512"
+ >
+ <path
+ fill="currentcolor"
+ d="M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.2 288 416 288c17.7 0 32-14.3 32-32s-14.3-32-32-32l-306.7 0L214.6 118.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-160 160z"
+ />
+ </svg>{" "}
+ {text}
+ </a>
+ );
+};
diff --git a/packages/docs/src/components/ChooseTemplate.tsx b/packages/docs/src/components/ChooseTemplate.tsx
index ea656416f3..3a90ad6479 100644
--- a/packages/docs/src/components/ChooseTemplate.tsx
+++ b/packages/docs/src/components/ChooseTemplate.tsx
@@ -1,25 +1,15 @@
-import type { Template } from "create-video";
+import Link from "@docusaurus/Link";
import { CreateVideoInternals } from "create-video";
import React, { useCallback, useEffect, useRef, useState } from "react";
+
import { chunk } from "../helpers/chunk";
import { NavigateLeft, NavigateRight } from "./ArrowRight";
import { IconForTemplate } from "./IconForTemplate";
import { TemplateIcon } from "./TemplateIcon";
-import { TemplateModal } from "./TemplateModal";
export const ChooseTemplate: React.FC = () => {
- const [modal, setModal] = useState<Template | null>(null);
-
const mobileLayout = true;
- const onClick = useCallback((template: Template) => {
- setModal(template);
- }, []);
-
- const onDismiss = useCallback(() => {
- setModal(null);
- }, []);
-
const [rightVisible, setRightVisible] = useState(true);
const [leftVisible, setLeftVisible] = useState(false);
@@ -66,9 +56,6 @@ export const ChooseTemplate: React.FC = () => {
flexDirection: "column",
}}
>
- {modal ? (
- <TemplateModal selectedTemplate={modal} onDismiss={onDismiss} />
- ) : null}
<div
style={{
position: "relative",
@@ -100,13 +87,14 @@ export const ChooseTemplate: React.FC = () => {
>
{c.map((template) => {
return (
- <TemplateIcon
+ <Link
key={template.cliId}
- onClick={() => onClick(template)}
- label={template.homePageLabel}
+ to={`/templates/${template.cliId}`}
>
- <IconForTemplate template={template} />
- </TemplateIcon>
+ <TemplateIcon label={template.homePageLabel}>
+ <IconForTemplate scale={1} template={template} />
+ </TemplateIcon>
+ </Link>
);
})}
</div>
diff --git a/packages/docs/src/components/ExpertPage.tsx b/packages/docs/src/components/ExpertPage.tsx
index 03277e629a..dd600f083c 100644
--- a/packages/docs/src/components/ExpertPage.tsx
+++ b/packages/docs/src/components/ExpertPage.tsx
@@ -8,6 +8,7 @@ import { Spacer } from "../../components/layout/Spacer";
import { experts } from "../data/experts";
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
+import { BackButton } from "./BackButton";
import { Seo } from "./Seo";
const layout: React.CSSProperties = {
@@ -46,22 +47,6 @@ const title: React.CSSProperties = {
marginBottom: 16,
};
-const backLink: React.CSSProperties = {
- color: "white",
- fontFamily: "GTPlanar",
- fontWeight: 500,
- display: "inline-flex",
- justifyContent: "center",
- alignItems: "center",
-};
-
-const backIcon: React.CSSProperties = {
- height: 20,
- color: "white",
- marginRight: 15,
- display: "inline-block",
-};
-
const emailButton: React.CSSProperties = {
marginBottom: 16,
marginRight: 16,
@@ -138,19 +123,7 @@ export default () => {
</Head>
<div style={header}>
<div style={layout}>
- <a style={backLink} href="/experts">
- <svg
- style={backIcon}
- xmlns="http://www.w3.org/2000/svg"
- viewBox="0 0 448 512"
- >
- <path
- fill="currentcolor"
- d="M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.2 288 416 288c17.7 0 32-14.3 32-32s-14.3-32-32-32l-306.7 0L214.6 118.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-160 160z"
- />
- </svg>{" "}
- Back to Experts
- </a>
+ <BackButton link="/experts" color="white" text="Back to Experts" />
<div style={headerRow}>
<img style={img} src={expert.image} />
<h2 className="big-title-on-desktop" style={title}>
diff --git a/packages/docs/src/components/TemplateIcon.tsx b/packages/docs/src/components/TemplateIcon.tsx
index affff2bd56..afa8aa7161 100644
--- a/packages/docs/src/components/TemplateIcon.tsx
+++ b/packages/docs/src/components/TemplateIcon.tsx
@@ -27,10 +27,9 @@ const labelStyle: React.CSSProperties = {
export const TemplateIcon: React.FC<{
label: string;
children: React.ReactNode;
- onClick: () => void;
-}> = ({ children, label, onClick }) => {
+}> = ({ children, label }) => {
return (
- <a style={outer} onClick={onClick}>
+ <a style={outer}>
<div style={icon}>{children}</div>
<div style={labelStyle}>{label}</div>
</a>
diff --git a/packages/docs/src/components/TemplateModal.tsx b/packages/docs/src/components/TemplateModal.tsx
deleted file mode 100644
index dbfd01560b..0000000000
--- a/packages/docs/src/components/TemplateModal.tsx
+++ /dev/null
@@ -1,63 +0,0 @@
-import type { Template } from "create-video";
-import React, { useEffect, useRef } from "react";
-import { TemplateModalContent } from "./TemplateModalContent";
-
-const container: React.CSSProperties = {
- position: "fixed",
- top: 0,
- bottom: 0,
- left: 0,
- right: 0,
- backgroundColor: "rgba(0, 0, 0, 0.6)",
- // Higher than Docusaurus highest
- zIndex: 1000,
- display: "flex",
- justifyContent: "center",
- alignItems: "center",
- flexDirection: "row",
-};
-
-export const TemplateModal: React.FC<{
- onDismiss: () => void;
- selectedTemplate: Template;
-}> = ({ onDismiss, selectedTemplate }) => {
- const outer = useRef<HTMLDivElement>(null);
- const inner = useRef<HTMLDivElement>(null);
-
- useEffect(() => {
- const onKeyPress = (e: KeyboardEvent) => {
- if (e.key === "Escape") {
- onDismiss();
- }
- };
-
- window.addEventListener("keyup", onKeyPress);
- return () => {
- window.removeEventListener("keyup", onKeyPress);
- };
- }, [onDismiss]);
-
- useEffect(() => {
- const onClick = (event: MouseEvent) => {
- if (inner.current.contains(event.target as Node)) {
- return;
- }
-
- onDismiss();
- };
-
- window.addEventListener("click", onClick);
- return () => window.removeEventListener("click", onClick);
- }, [onDismiss]);
-
- return (
- <div ref={outer} style={container}>
- <div ref={inner}>
- <TemplateModalContent
- template={selectedTemplate}
- onDismiss={onDismiss}
- />
- </div>
- </div>
- );
-};
diff --git a/packages/docs/src/components/TemplateModalContent.tsx b/packages/docs/src/components/TemplateModalContent.tsx
index 45b4323855..acbc2502f5 100644
--- a/packages/docs/src/components/TemplateModalContent.tsx
+++ b/packages/docs/src/components/TemplateModalContent.tsx
@@ -1,18 +1,17 @@
import type { Template } from "create-video";
import React, { useCallback, useMemo, useState } from "react";
import { useMobileLayout } from "../helpers/mobile-layout";
-import { useElementSize } from "../helpers/use-el-size";
+import { BackButton } from "./BackButton";
import { CommandCopyButton } from "./CommandCopyButton";
import { MuxVideo } from "./MuxVideo";
import { Spinner } from "./Spinner";
-const RESERVED_FOR_SIDEBAR = 350;
+const RESERVED_FOR_SIDEBAR = 500;
const column: React.CSSProperties = {
width: RESERVED_FOR_SIDEBAR,
paddingLeft: 16,
paddingRight: 16,
- paddingTop: 24,
overflow: "auto",
};
@@ -34,9 +33,7 @@ const link: React.CSSProperties = {
userSelect: "none",
};
-const description: React.CSSProperties = {
- fontSize: 14,
-};
+const description: React.CSSProperties = {};
const githubrow: React.CSSProperties = {
flexDirection: "row",
@@ -49,7 +46,6 @@ const githubrow: React.CSSProperties = {
};
const loadingContainer: React.CSSProperties = {
- position: "absolute",
justifyContent: "center",
alignItems: "center",
display: "flex",
@@ -98,76 +94,39 @@ const separator: React.CSSProperties = {
let copyTimeout: NodeJS.Timeout | null = null;
-const layout = ({
- template,
- containerHeight,
- possibleVideoWidth,
-}: {
- template: Template;
- containerHeight: number;
- possibleVideoWidth: number;
-}) => {
- const dimensions =
- template.type === "video" ? template.promoVideo : template.promoBanner;
- const heightRatio = (containerHeight ?? 0) / dimensions.height;
- const widthRatio = (possibleVideoWidth ?? 0) / dimensions.width;
-
- const ratio = Math.min(heightRatio, widthRatio);
-
- const height = ratio * dimensions.height;
- const width = ratio * dimensions.width;
-
- return { height, width };
-};
-
export const TemplateModalContent: React.FC<{
template: Template;
- onDismiss: () => void;
-}> = ({ template, onDismiss }) => {
+}> = ({ template }) => {
const [copied, setCopied] = useState<string | false>(false);
const [showPkgManagers, setShowPackageManagers] = useState(false);
const [loaded, setLoaded] = useState(false);
- const containerSize = useElementSize(
- typeof document === "undefined" ? null : document.body
- );
const mobileLayout = useMobileLayout();
const containerCss: React.CSSProperties = useMemo(() => {
return {
- backgroundColor: "var(--ifm-hero-background-color)",
marginBottom: 0,
display: "flex",
flexDirection: mobileLayout ? "column" : "row",
overflow: "auto",
height: mobileLayout ? "100%" : undefined,
- position: mobileLayout ? "absolute" : undefined,
left: mobileLayout ? 0 : undefined,
top: mobileLayout ? 0 : undefined,
};
}, [mobileLayout]);
- const possibleVideoWidth = mobileLayout
- ? containerSize?.width
- : Math.min(containerSize?.width ?? 0, 1200) -
- (mobileLayout ? 0 : RESERVED_FOR_SIDEBAR);
- const containerHeight = mobileLayout
- ? Infinity
- : Math.min(containerSize?.height ?? 0, 800);
-
- const { height, width } = layout({
- template,
- containerHeight,
- possibleVideoWidth,
- });
-
const loadingStyle = useMemo(() => {
return {
...loadingContainer,
- height,
- width,
+ width: "100%",
+ border: "1px solid var(--ifm-color-emphasis-300)",
+ borderRadius: 5,
+ aspectRatio:
+ template.type === "video"
+ ? `${template.promoVideo.width} / ${template.promoVideo.height}`
+ : "",
};
- }, [height, width]);
+ }, [template]);
const onLoadedMetadata = useCallback(() => {
setLoaded(true);
@@ -204,178 +163,165 @@ export const TemplateModalContent: React.FC<{
const pnpmCommand = `pnpm create video --${template.cliId}`;
return (
- <div style={containerCss}>
- <div
- style={{
- display: "inline-flex",
- }}
- >
- {loaded ? null : (
- <div style={loadingStyle}>
- <Spinner style={spinner} />
- </div>
- )}
- {template.type === "video" ? (
- <MuxVideo
- muxId={template.promoVideo.muxId}
- loop
- height={height}
- width={width}
- autoPlay
- muted
- playsInline
- style={{
- display: "inline-flex",
- }}
- onLoadedMetadata={onLoadedMetadata}
- />
- ) : (
- <img
- src={template.promoBanner.src}
- height={height}
- width={width}
- style={{
- display: "inline-flex",
- }}
- onLoad={onLoadedMetadata}
- />
- )}
- </div>
- <div
- style={{
- ...column,
- width: mobileLayout ? "100%" : RESERVED_FOR_SIDEBAR,
- }}
- >
+ <div>
+ <BackButton
+ link="/templates"
+ text="Back to Templates"
+ color="currentcolor"
+ />
+ <br />
+ <br />
+ <div style={containerCss}>
<div
style={{
display: "flex",
- flexDirection: "row",
- alignItems: "center",
+ width: "100%",
}}
>
- <div style={{ flex: 1 }}>
- <h1
+ {loaded ? null : (
+ <div style={loadingStyle}>
+ <Spinner style={spinner} />
+ </div>
+ )}
+ {template.type === "video" ? (
+ <MuxVideo
+ muxId={template.promoVideo.muxId}
+ loop
+ autoPlay
+ muted
+ playsInline
style={{
- marginTop: 0,
- marginBottom: 0,
+ aspectRatio: `${template.promoVideo.width} / ${template.promoVideo.height}`,
+ width: "100%",
+ height: "auto",
+ opacity: Number(loaded),
+ display: loaded ? "inline-flex" : "none",
+ borderRadius: 5,
+ border: "1px solid var(--ifm-color-emphasis-300)",
}}
- >
- {template.shortName}
- </h1>
- </div>
- <a
- style={{
- cursor: "pointer",
- opacity: 0.4,
- display: "inline-flex",
- color: "var(--text-color)",
- }}
- onClick={onDismiss}
- >
- <svg
- xmlns="http://www.w3.org/2000/svg"
- viewBox="0 0 320 512"
+ onLoadedMetadata={onLoadedMetadata}
+ />
+ ) : (
+ <img
+ src={template.promoBanner.src}
style={{
- height: 24,
+ display: "inline-flex",
+ borderRadius: 5,
+ width: "100%",
+ border: "1px solid var(--ifm-color-emphasis-300)",
}}
- >
- <path
- fill="currentColor"
- d="M310.6 361.4c12.5 12.5 12.5 32.75 0 45.25C304.4 412.9 296.2 416 288 416s-16.38-3.125-22.62-9.375L160 301.3L54.63 406.6C48.38 412.9 40.19 416 32 416S15.63 412.9 9.375 406.6c-12.5-12.5-12.5-32.75 0-45.25l105.4-105.4L9.375 150.6c-12.5-12.5-12.5-32.75 0-45.25s32.75-12.5 45.25 0L160 210.8l105.4-105.4c12.5-12.5 32.75-12.5 45.25 0s12.5 32.75 0 45.25l-105.4 105.4L310.6 361.4z"
- />
- </svg>
- </a>
- </div>
- <br />
- <div style={description}>{template.longerDescription}</div>
- <br />
- <div style={githubrow}>
- <a style={link} onPointerDown={() => copyCommand(npmCommand)}>
- <div style={iconContainer}>
- <CommandCopyButton copied={copied === npmCommand} />
- </div>
- <div style={installCommand}>{npmCommand}</div>
- </a>
- <div style={{ flex: 1 }} />
- {showPkgManagers ? null : (
- <a style={link} onPointerDown={togglePkgManagers}>
- <span
- style={{ whiteSpace: "pre", color: "var(--light-text-color)" }}
- >
- More
- </span>{" "}
- </a>
+ onLoad={onLoadedMetadata}
+ />
)}
- <div
- style={{
- width: 8,
- }}
- />
</div>
- {showPkgManagers ? (
+ <div
+ style={{
+ ...column,
+ width: mobileLayout ? "100%" : RESERVED_FOR_SIDEBAR,
+ }}
+ >
<div style={githubrow}>
- <a style={link} onPointerDown={() => copyCommand(pnpmCommand)}>
+ <a style={link} onPointerDown={() => copyCommand(npmCommand)}>
<div style={iconContainer}>
- <CommandCopyButton copied={copied === pnpmCommand} />
+ <CommandCopyButton copied={copied === npmCommand} />
</div>
- <div style={installCommand}>{pnpmCommand}</div>
+ <div style={installCommand}>{npmCommand}</div>
</a>
+ <div style={{ width: 2 }} />
+ {showPkgManagers ? null : (
+ <a style={link} onPointerDown={togglePkgManagers}>
+ <span
+ style={{
+ whiteSpace: "pre",
+ color: "var(--light-text-color)",
+ }}
+ >
+ More
+ </span>{" "}
+ </a>
+ )}
+ <div
+ style={{
+ width: 8,
+ }}
+ />
</div>
- ) : null}
- {showPkgManagers ? (
+ {showPkgManagers ? (
+ <div style={githubrow}>
+ <a style={link} onPointerDown={() => copyCommand(pnpmCommand)}>
+ <div style={iconContainer}>
+ <CommandCopyButton copied={copied === pnpmCommand} />
+ </div>
+ <div style={installCommand}>{pnpmCommand}</div>
+ </a>
+ </div>
+ ) : null}
+ {showPkgManagers ? (
+ <div style={githubrow}>
+ <a
+ target={"_blank"}
+ style={link}
+ onPointerDown={() => copyCommand(yarnCommand)}
+ >
+ <div style={iconContainer}>
+ <CommandCopyButton copied={copied === yarnCommand} />
+ </div>
+ <div style={installCommand}>{yarnCommand}</div>
+ </a>
+ </div>
+ ) : null}
<div style={githubrow}>
<a
target={"_blank"}
style={link}
- onPointerDown={() => copyCommand(yarnCommand)}
+ href={`https://github.com/${template.org}/${template.repoName}/generate`}
>
<div style={iconContainer}>
- <CommandCopyButton copied={copied === yarnCommand} />
- </div>
- <div style={installCommand}>{yarnCommand}</div>
+ <GithubIcon />
+ </div>{" "}
+ Use template
+ </a>
+ <div style={separator} />
+ <a
+ target={"_blank"}
+ style={link}
+ href={`https://github.com/${template.org}/${template.repoName}`}
+ >
+ View source
</a>
</div>
- ) : null}
- <div style={githubrow}>
<a
target={"_blank"}
style={link}
- href={`https://github.com/${template.org}/${template.repoName}/generate`}
+ href={`https://stackblitz.com/github/${template.org}/${template.repoName}`}
>
- <div style={iconContainer}>
- <GithubIcon />
- </div>{" "}
- Use template
- </a>
- <div style={separator} />
- <a
- target={"_blank"}
- style={link}
- href={`https://github.com/${template.org}/${template.repoName}`}
- >
- View source
+ <div style={githubrow}>
+ <div style={iconContainer}>
+ <StackBlitzIcon />
+ </div>
+ Try online{" "}
+ <span
+ style={{ whiteSpace: "pre", color: "var(--light-text-color)" }}
+ >
+ {" "}
+ via StackBlitz
+ </span>
+ </div>
</a>
</div>
- <a
- target={"_blank"}
- style={link}
- href={`https://stackblitz.com/github/${template.org}/${template.repoName}`}
- >
- <div style={githubrow}>
- <div style={iconContainer}>
- <StackBlitzIcon />
- </div>
- Try online{" "}
- <span
- style={{ whiteSpace: "pre", color: "var(--light-text-color)" }}
- >
- {" "}
- via StackBlitz
- </span>
- </div>
- </a>
- </div>
+ </div>{" "}
+ <br />
+ <br />
+ <h1
+ style={{
+ marginTop: 0,
+ }}
+ >
+ {template.shortName}
+ </h1>
+ <div style={description}>{template.longerDescription}</div>
+ <br />
+ <br />
</div>
);
};
diff --git a/packages/docs/src/components/TemplatePage.tsx b/packages/docs/src/components/TemplatePage.tsx
new file mode 100644
index 0000000000..4726a0c0b9
--- /dev/null
+++ b/packages/docs/src/components/TemplatePage.tsx
@@ -0,0 +1,46 @@
+import Head from "@docusaurus/Head";
+import { useLocation } from "@docusaurus/router";
+import Layout from "@theme/Layout";
+import React from "react";
+
+import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
+import { CreateVideoInternals } from "create-video";
+import { Seo } from "./Seo";
+import { TemplateModalContent } from "./TemplateModalContent";
+
+const layout: React.CSSProperties = {
+ maxWidth: 1200,
+ margin: "auto",
+ paddingLeft: 16,
+ paddingRight: 16,
+};
+
+export default () => {
+ const location = useLocation();
+ const context = useDocusaurusContext();
+
+ const templatePathname = location.pathname.match(/templates\/([a-zA-Z-]+)/);
+
+ if (!templatePathname) {
+ throw new Error("no expert slug found");
+ }
+
+ const template = CreateVideoInternals.FEATURED_TEMPLATES.find(
+ (e) => e.cliId === templatePathname[1]
+ );
+ const imgSrc = `/generated/template-${template.cliId}.png`;
+
+ return (
+ <Layout>
+ <Head>
+ {Seo.renderTitle(`${template.shortName} | Remotion Template`)}
+ {Seo.renderDescription(template.description)}
+ {Seo.renderImage(imgSrc, context.siteConfig.url)}
+ </Head>
+ <br />
+ <div style={layout}>
+ <TemplateModalContent template={template} />
+ </div>
+ </Layout>
+ );
+};
diff --git a/packages/docs/src/pages/templates/index.tsx b/packages/docs/src/pages/templates/index.tsx
index b7d4b80d06..d3d7f75889 100644
--- a/packages/docs/src/pages/templates/index.tsx
+++ b/packages/docs/src/pages/templates/index.tsx
@@ -1,3 +1,4 @@
+import Link from "@docusaurus/Link";
import Layout from "@theme/Layout";
import { CreateVideoInternals } from "create-video";
import React from "react";
@@ -30,14 +31,19 @@ export default () => {
<div className={styles.grid}>
{CreateVideoInternals.FEATURED_TEMPLATES.map((template) => {
return (
- <Item
+ <Link
key={template.cliId}
- onClick={() => onClick(template)}
- label={template.homePageLabel}
- description={template.description}
+ className={styles.item}
+ style={outer}
+ to={`/templates/${template.cliId}`}
>
- <IconForTemplate scale={0.7} template={template} />
- </Item>
+ <Item
+ label={template.homePageLabel}
+ description={template.description}
+ >
+ <IconForTemplate scale={0.7} template={template} />
+ </Item>
+ </Link>
);
})}
</div>
@@ -54,10 +60,9 @@ const Item: React.FC<{
label: string;
description: React.ReactNode;
children: React.ReactNode;
- onClick: () => void;
-}> = ({ children, label, onClick, description }) => {
+}> = ({ children, label, description }) => {
return (
- <a className={styles.item} style={outer} onClick={onClick}>
+ <div>
<div
style={{ flexDirection: "row", display: "flex", alignItems: "center" }}
>
@@ -67,13 +72,15 @@ const Item: React.FC<{
<div>
<p style={descriptionStyle}>{description}</p>
</div>
- </a>
+ </div>
);
};
const outer: React.CSSProperties = {
display: "flex",
cursor: "pointer",
+ color: "var(--text-color)",
+ textDecoration: "none",
};
const icon: React.CSSProperties = {
diff --git a/packages/docs/src/remotion/Root.tsx b/packages/docs/src/remotion/Root.tsx
index 70bdba0574..d9cecbe8a1 100644
--- a/packages/docs/src/remotion/Root.tsx
+++ b/packages/docs/src/remotion/Root.tsx
@@ -1,9 +1,11 @@
+import { CreateVideoInternals } from "create-video";
import React from "react";
import { Folder, Still } from "remotion";
import { articles } from "../data/articles";
import { experts } from "../data/experts";
import { Article } from "./Article";
import { Expert } from "./Expert";
+import { TemplateComp } from "./Template";
export const RemotionRoot: React.FC = () => {
return (
@@ -40,6 +42,22 @@ export const RemotionRoot: React.FC = () => {
);
})}
</Folder>
+ <Folder name="templates">
+ {CreateVideoInternals.FEATURED_TEMPLATES.map((e) => {
+ return (
+ <Still
+ key={e.cliId}
+ component={TemplateComp}
+ defaultProps={{
+ templateId: e.cliId,
+ }}
+ height={630}
+ width={1200}
+ id={`template-${e.cliId}`}
+ />
+ );
+ })}
+ </Folder>
</>
);
};
diff --git a/packages/docs/src/remotion/Template.tsx b/packages/docs/src/remotion/Template.tsx
new file mode 100644
index 0000000000..619c27d3c5
--- /dev/null
+++ b/packages/docs/src/remotion/Template.tsx
@@ -0,0 +1,122 @@
+import { CreateVideoInternals } from "create-video";
+import React from "react";
+import { AbsoluteFill, Img } from "remotion";
+import "./font.css";
+
+export const TemplateComp: React.FC<{
+ templateId: string;
+}> = ({ templateId }) => {
+ const template = CreateVideoInternals.FEATURED_TEMPLATES.find(
+ (t) => t.cliId === templateId
+ );
+ return (
+ <AbsoluteFill
+ style={{
+ height: "100%",
+ width: "100%",
+ display: "flex",
+ backgroundColor: "#fff",
+ fontSize: 32,
+ fontWeight: 700,
+ justifyContent: "center",
+ alignItems: "center",
+ padding: 60,
+ fontFamily: "GTPlanar",
+ }}
+ >
+ <div>
+ <div
+ style={{
+ flexDirection: "row",
+ display: "flex",
+ paddingLeft: 30,
+ }}
+ >
+ <div
+ style={{
+ display: "inline-flex",
+ flexDirection: "row",
+ alignItems: "center",
+ padding: "15px 30px",
+ translate: "0px 30px",
+ backgroundColor: "white",
+ }}
+ >
+ Jumpstart your Remotion Project
+ </div>
+ </div>
+
+ <div
+ style={{
+ display: "flex",
+ flex: 1,
+ flexDirection: "row",
+ }}
+ >
+ <div
+ style={{
+ backgroundColor: "#0B84F3",
+ display: "flex",
+ padding: 50,
+ minWidth: 500,
+ width: "100%",
+ }}
+ >
+ <div
+ style={{
+ color: "white",
+ fontFamily: "GTPlanar",
+ fontSize: 80,
+ }}
+ >
+ {template.shortName} Template
+ </div>
+ </div>
+ </div>
+
+ <div
+ style={{
+ display: "flex",
+ flexDirection: "row",
+ alignItems: "center",
+ height: 120,
+ backgroundColor: "#222",
+ paddingRight: 40,
+ }}
+ >
+ <div
+ style={{
+ flex: 1,
+ fontFamily: "GTPlanar",
+ color: "white",
+ height: "100%",
+ display: "flex",
+ alignItems: "center",
+ paddingLeft: 40,
+ fontWeight: 300,
+ fontSize: 20,
+ marginRight: 200,
+ }}
+ >
+ npx create-video --template {template.cliId}
+ </div>
+ <div
+ style={{
+ height: "100%",
+ display: "flex",
+ justifyContent: "center",
+ alignItems: "center",
+ }}
+ >
+ <Img
+ style={{
+ height: 60,
+ }}
+ src="https://www.remotion.dev/img/remotion-white.png"
+ />
+ </div>
+ </div>
+ </div>
+ </AbsoluteFill>
+ );
+};
diff --git a/packages/docs/static/generated/template-audiogram.png b/packages/docs/static/generated/template-audiogram.png
new file mode 100644
index 0000000000..52324f8e58
Binary files /dev/null and b/packages/docs/static/generated/template-audiogram.png differ
diff --git a/packages/docs/static/generated/template-blank.png b/packages/docs/static/generated/template-blank.png
new file mode 100644
index 0000000000..01d91500ac
Binary files /dev/null and b/packages/docs/static/generated/template-blank.png differ
diff --git a/packages/docs/static/generated/template-hello-world.png b/packages/docs/static/generated/template-hello-world.png
new file mode 100644
index 0000000000..2169b86aad
Binary files /dev/null and b/packages/docs/static/generated/template-hello-world.png differ
diff --git a/packages/docs/static/generated/template-javascript.png b/packages/docs/static/generated/template-javascript.png
new file mode 100644
index 0000000000..8b12de31e6
Binary files /dev/null and b/packages/docs/static/generated/template-javascript.png differ
diff --git a/packages/docs/static/generated/template-next.png b/packages/docs/static/generated/template-next.png
new file mode 100644
index 0000000000..79db5cc9d6
Binary files /dev/null and b/packages/docs/static/generated/template-next.png differ
diff --git a/packages/docs/static/generated/template-overlay.png b/packages/docs/static/generated/template-overlay.png
new file mode 100644
index 0000000000..0e7725b5ec
Binary files /dev/null and b/packages/docs/static/generated/template-overlay.png differ
diff --git a/packages/docs/static/generated/template-remix.png b/packages/docs/static/generated/template-remix.png
new file mode 100644
index 0000000000..cf1110af62
Binary files /dev/null and b/packages/docs/static/generated/template-remix.png differ
diff --git a/packages/docs/static/generated/template-skia.png b/packages/docs/static/generated/template-skia.png
new file mode 100644
index 0000000000..0e26549335
Binary files /dev/null and b/packages/docs/static/generated/template-skia.png differ
diff --git a/packages/docs/static/generated/template-still.png b/packages/docs/static/generated/template-still.png
new file mode 100644
index 0000000000..e7e0bf1cd3
Binary files /dev/null and b/packages/docs/static/generated/template-still.png differ
diff --git a/packages/docs/static/generated/template-tailwind.png b/packages/docs/static/generated/template-tailwind.png
new file mode 100644
index 0000000000..a2937b570a
Binary files /dev/null and b/packages/docs/static/generated/template-tailwind.png differ
diff --git a/packages/docs/static/generated/template-three.png b/packages/docs/static/generated/template-three.png
new file mode 100644
index 0000000000..33ac2057bb
Binary files /dev/null and b/packages/docs/static/generated/template-three.png differ
diff --git a/packages/docs/static/generated/template-tts.png b/packages/docs/static/generated/template-tts.png
new file mode 100644
index 0000000000..4907a56d82
Binary files /dev/null and b/packages/docs/static/generated/template-tts.png differ