🎥 Make videos programmatically with React
nice, also fix homepage bug
Jonny Burger13ff1c69c06a
diff --git a/packages/create-video/src/templates.ts b/packages/create-video/src/templates.tsindex 99f5365984..79ace9531d 100644--- a/packages/create-video/src/templates.ts+++ b/packages/create-video/src/templates.ts@@ -156,7 +156,7 @@ export const FEATURED_TEMPLATES: Template[] = [cliId: 'blank' as const,type: 'video' as const,defaultBranch: 'main',- featuredOnHomePage: null,+ featuredOnHomePage: 'Blank',previewURL: 'https://template-empty.vercel.app/?/MyComp',templateInMonorepo: 'template-blank',allowEnableTailwind: true,@@ -177,7 +177,7 @@ export const FEATURED_TEMPLATES: Template[] = [cliId: 'javascript' as const,type: 'video' as const,defaultBranch: 'main',- featuredOnHomePage: 'JavaScript',+ featuredOnHomePage: null,previewURL:'https://template-helloworld-javascript.vercel.app/?/HelloWorld',templateInMonorepo: 'template-javascript',diff --git a/packages/docs/static/img/compose.mp4 b/packages/docs/static/img/compose.mp4new file mode 100644index 0000000000..e3bf05c03cBinary files /dev/null and b/packages/docs/static/img/compose.mp4 differdiff --git a/packages/docs/static/img/compose.webm b/packages/docs/static/img/compose.webmnew file mode 100644index 0000000000..320f338100Binary files /dev/null and b/packages/docs/static/img/compose.webm differdiff --git a/packages/example/src/Compose/Compose.tsx b/packages/example/src/Compose/Compose.tsxindex a117fd8a75..7c31964c77 100644--- a/packages/example/src/Compose/Compose.tsx+++ b/packages/example/src/Compose/Compose.tsx@@ -260,30 +260,50 @@ export const Compose = () => {return (<AbsoluteFill className="flex justify-center items-center">- <Scale factor={1.3}>- <TranslateX px={firstX}>- <TranslateZ px={1.5 * depth * layerDownProgress}>+ <Scale factor={1.1}>+ <AbsoluteFill+ style={{+ maskImage:+ frame > 100+ ? 'linear-gradient( -98deg, red 80%, transparent 90%)'+ : 'none',+ }}+ >+ <TranslateX px={firstX}>+ <TranslateZ px={1.5 * depth * layerDownProgress}>+ <VideoLayers+ footage+ codeFrame+ delay={animationStart}+ boxHeight={actual.height}+ boxWidth={actual.width}+ label="<Video />"+ />+ </TranslateZ>+ </TranslateX>+ </AbsoluteFill>+ <AbsoluteFill+ style={{+ maskImage:+ 'linear-gradient( -7deg, transparent 6%, red 15%, red 84%, transparent 94%)',+ }}+ >+ <TranslateY+ px={interpolate(+ bRollEnter + bRollExit,+ [0, 1, 2],+ [1500, 0, -1500],+ )}+ ><VideoLayers- footage- codeFrame+ bRoll+ boxWidth={width}+ boxHeight={height}delay={animationStart}- boxHeight={actual.height}- boxWidth={actual.width}- label="<Video />"+ label="<BRoll />"/>- </TranslateZ>- </TranslateX>- <TranslateY- px={interpolate(bRollEnter + bRollExit, [0, 1, 2], [1500, 0, -1500])}- >- <VideoLayers- bRoll- boxWidth={width}- boxHeight={height}- delay={animationStart}- label="<BRoll />"- />- </TranslateY>+ </TranslateY>+ </AbsoluteFill>{endCard > 0 && (<TranslateX px={secondX}><RotateY radians={Math.PI * outAnimation}>diff --git a/packages/promo-pages/public/img/compose.mp4 b/packages/promo-pages/public/img/compose.mp4new file mode 100644index 0000000000..e3bf05c03cBinary files /dev/null and b/packages/promo-pages/public/img/compose.mp4 differdiff --git a/packages/promo-pages/public/img/compose.webm b/packages/promo-pages/public/img/compose.webmnew file mode 100644index 0000000000..320f338100Binary files /dev/null and b/packages/promo-pages/public/img/compose.webm differdiff --git a/packages/promo-pages/src/components/Homepage.tsx b/packages/promo-pages/src/components/Homepage.tsxindex 35a4bc5b06..5fc9c6be93 100644--- a/packages/promo-pages/src/components/Homepage.tsx+++ b/packages/promo-pages/src/components/Homepage.tsx@@ -37,12 +37,6 @@ export const NewLanding: React.FC<{<WriteInReact /><br /><IfYouKnowReact />- <br />- <br />- <br />- <br />- <br />- <br /><RealMP4Videos /><br /><br />diff --git a/packages/promo-pages/src/components/homepage/ChooseTemplate.tsx b/packages/promo-pages/src/components/homepage/ChooseTemplate.tsxindex acb2190793..c4cddf9822 100644--- a/packages/promo-pages/src/components/homepage/ChooseTemplate.tsx+++ b/packages/promo-pages/src/components/homepage/ChooseTemplate.tsx@@ -22,7 +22,7 @@ export const ChooseTemplate: React.FC = () => {<divclassName="no-scroll-bar"style={{- backgroundColor: 'var(--background)',+ backgroundColor: 'var(--plain-button)',display: 'inline-flex',flexDirection: 'row',justifyContent: 'space-around',diff --git a/packages/promo-pages/src/components/homepage/CodeExample.tsx b/packages/promo-pages/src/components/homepage/CodeExample.tsxdeleted file mode 100644index 9b8a025fd1..0000000000--- a/packages/promo-pages/src/components/homepage/CodeExample.tsx+++ /dev/null@@ -1,89 +0,0 @@-'use client';--import {Player} from '@remotion/player';-import React, {useState} from 'react';-import {interpolate, useCurrentFrame} from 'remotion';--const IMG_WIDTH = 1120;-const IMG_HEIGHT = 760;-const ASPECT = IMG_WIDTH / IMG_HEIGHT;--const Demo: React.FC = () => {- const frame = useCurrentFrame();- const scale = interpolate(frame, [0, 10, 40, 49], [0, 1, 1, 0]);- return (- <div- style={{- display: 'flex',- justifyContent: 'center',- alignItems: 'center',- flex: 1,- backgroundColor: 'black',- }}- >- <img style={{transform: `scale(${scale})`}} src="/img/logo-small.png" />- </div>- );-};--const container = {- maxWidth: 500,- height: (1 / ASPECT) * 500,- position: 'relative' as const,-};--const Preview: React.FC = () => {- return (- <Player- component={Demo}- compositionHeight={IMG_HEIGHT}- compositionWidth={IMG_WIDTH}- durationInFrames={50}- style={container}- controls- fps={30}- />- );-};--const tabStyle = {- appearance: 'none',- backgroundColor: 'transparent',- fontFamily: 'inherit',- border: 'none',- cursor: 'pointer',- color: 'var(--text-color)',-} as const;--type Tab = 'code' | 'preview';--export const CodeExample: React.FC = () => {- const [tab, setTab] = useState<Tab>('code');- return (- <div style={{flex: 1, textAlign: 'left', maxWidth: 700}}>- <button- type="button"- style={{...tabStyle, opacity: tab === 'code' ? 1 : 0.5}}- onClick={() => setTab('code')}- >- Code- </button>- |- <button- type="button"- style={{...tabStyle, opacity: tab === 'preview' ? 1 : 0.5}}- onClick={() => setTab('preview')}- >- Preview- </button>- <div>- {tab === 'code' && (- <div style={container}>- <img src="/img/code-sample-new.png" className="w-full" />- </div>- )}- {tab === 'preview' && <Preview />}- </div>- </div>- );-};diff --git a/packages/promo-pages/src/components/homepage/IfYouKnowReact.tsx b/packages/promo-pages/src/components/homepage/IfYouKnowReact.tsxindex 1bff1d0544..5b16158b18 100644--- a/packages/promo-pages/src/components/homepage/IfYouKnowReact.tsx+++ b/packages/promo-pages/src/components/homepage/IfYouKnowReact.tsx@@ -1,22 +1,41 @@import React from 'react';-import {CodeExample} from './CodeExample';import {BlueButton} from './layout/Button';+export const isWebkit = () => {+ if (typeof window === 'undefined') {+ return false;+ }++ const isSafariUserAgent = Boolean(+ navigator.userAgent.match(/Version\/[\d.]+.*Safari/),+ );++ const isChrome = Boolean(navigator.userAgent.match(/CriOS\//));+ return isSafariUserAgent || isChrome;+};+export const IfYouKnowReact: React.FC = () => {return (- <div className="flex flex-col-reverse lg:flex-row text-left lg:text-right justify-start lg:justify-end items-start lg:items-center">- <CodeExample />- <div className="h-10 lg:w-10" />+ <div className="flex flex-col lg:flex-row text-left lg:text-right justify-start lg:justify-end items-start lg:mb-0">+ <video+ src={isWebkit() ? '/img/compose.mp4' : '/img/compose.webm'}+ muted+ autoPlay+ playsInline+ loop+ className="w-[600px] h-[600px] cursor-default! relative lg:-translate-x-8 -mb-50 -mt-10 lg:mt-0 lg:mb-0"+ />+ <div className="h-10 lg:flex-1" /><div className="lg:text-right">- <h2 className="text-4xl fontbrand">- Leverage <span className="text-brand">React</span> <br />- to express yourself.+ <h2 className="text-4xl fontbrand pt-20">+ <span className="text-brand">Compose</span> your+ <br />+ video with code.</h2><p className="leading-relaxed">- Remotion gives you the tools for video creation, <br /> but the rules- of React stay the same. <br />+ Use React, a powerful frontend technology, to create sophisticated+ videos with code.</p>- Learn the fundamentals in just a few minutes.<div className="h-7" /><a className="no-underline inline-block" href="/docs/the-fundamentals"><BlueButton size="sm" loading={false}>diff --git a/packages/promo-pages/src/components/homepage/RealMp4Videos.tsx b/packages/promo-pages/src/components/homepage/RealMp4Videos.tsxindex a6e5afc7cf..f9ec7a3a62 100644--- a/packages/promo-pages/src/components/homepage/RealMp4Videos.tsx+++ b/packages/promo-pages/src/components/homepage/RealMp4Videos.tsx@@ -24,7 +24,7 @@ export const RealMP4Videos: React.FC = () => {}, [callback]);return (- <div ref={ref} className={'flex flex-col lg:flex-row'}>+ <div ref={ref} className={'flex flex-col lg:flex-row mt-20 lg:mt-0'}><div><h2 className="text-4xl fontbrand">Real <span className={'text-brand'}>.mp4</span> videosdiff --git a/packages/promo-pages/src/components/homepage/VideoAppsShowcase.tsx b/packages/promo-pages/src/components/homepage/VideoAppsShowcase.tsxindex 6351da800c..c0428404f6 100644--- a/packages/promo-pages/src/components/homepage/VideoAppsShowcase.tsx+++ b/packages/promo-pages/src/components/homepage/VideoAppsShowcase.tsx@@ -179,7 +179,7 @@ const VideoAppsShowcase: React.FC = () => {key={tab}type="button"data-active={index === activeTab}- className={`bg-transparent border-none mx-3 my-4 cursor-pointer text-base fontbrand font-bold transition-colors text-muted data-[active=true]:text-brand`}+ className={`bg-transparent border-none lg:mx-3 my-4 cursor-pointer text-base fontbrand font-bold transition-colors text-muted data-[active=true]:text-brand`}onClick={() => setActiveTab(index)}>{tab}