🎥 Make videos programmatically with React
alright
Jonny Burger0116146d1717
diff --git a/packages/docs/src/components/Demo/ActionRow.tsx b/packages/docs/src/components/Demo/ActionRow.tsxindex fb2e81df4f..e1a930ca3e 100644--- a/packages/docs/src/components/Demo/ActionRow.tsx+++ b/packages/docs/src/components/Demo/ActionRow.tsx@@ -17,16 +17,13 @@ export const ActionRow: React.FC = () => {return (<div className={styles.row}><div className={styles.action}>- <h2 className={styles['action-title']}>Drag & Drop</h2>- <p>- The video is interactive. Drag the cards around to change the video.- </p>+ <h2 className={styles['action-title']}>Interactive</h2>+ <p>Drag and drop the cards around to change the video.</p></div><div className={styles.action}>- <h2 className={styles['action-title']}>- {colorMode === 'dark' ? 'Light theme' : 'Dark theme'}- </h2>+ <h2 className={styles['action-title']}>Data-driven</h2><p>+ The preview is driven by dynamic data.{' '}<a style={link} onClick={toggleTheme}>Switch to {colorMode === 'dark' ? 'light' : 'dark'} mode</a>{' '}diff --git a/packages/docs/src/components/Demo/action-row.module.css b/packages/docs/src/components/Demo/action-row.module.cssindex 215814bf93..473d7030d7 100644--- a/packages/docs/src/components/Demo/action-row.module.css+++ b/packages/docs/src/components/Demo/action-row.module.css@@ -1,7 +1,7 @@.row {display: flex;flex-direction: row;- align-items: center;+ align-items: flex-start;margin-top: 40px;}diff --git a/packages/docs/src/remotion/HomepageVideo/CurrentCountry.tsx b/packages/docs/src/remotion/HomepageVideo/CurrentCountry.tsxindex b8340e608c..526acb9817 100644--- a/packages/docs/src/remotion/HomepageVideo/CurrentCountry.tsx+++ b/packages/docs/src/remotion/HomepageVideo/CurrentCountry.tsx@@ -1,6 +1,6 @@import {getBoundingBox, resetPath} from '@remotion/paths';import React from 'react';-import {AbsoluteFill} from 'remotion';+import {AbsoluteFill, spring, useCurrentFrame, useVideoConfig} from 'remotion';import {ISO_3166_ALPHA_2_MAPPINGS, countriesPaths} from './paths';import type {Location} from './types';@@ -13,9 +13,28 @@ export const CurrentCountry: React.FC<{const reset = resetPath(joined);const boundingBox = getBoundingBox(reset);+ const {fps} = useVideoConfig();+ const frame = useCurrentFrame();++ const progress = spring({+ fps,+ frame,+ delay: 10,+ });++ const progress2 = spring({+ fps,+ frame,+ delay: 20,+ });+return (<AbsoluteFill>- <AbsoluteFill style={{}}>+ <AbsoluteFill+ style={{+ transform: `scale(${progress})`,+ }}+ ><svgviewBox={boundingBox.viewBox}style={{@@ -31,6 +50,7 @@ export const CurrentCountry: React.FC<{justifyContent: 'center',paddingLeft: 20,paddingRight: 20,+ transform: `scale(${progress2})`,}}><divdiff --git a/packages/docs/src/remotion/HomepageVideo/TrendingRepos.tsx b/packages/docs/src/remotion/HomepageVideo/TrendingRepos.tsxindex 248abb5e04..bff3928f28 100644--- a/packages/docs/src/remotion/HomepageVideo/TrendingRepos.tsx+++ b/packages/docs/src/remotion/HomepageVideo/TrendingRepos.tsx@@ -1,20 +1,58 @@-import React from 'react';-import {AbsoluteFill} from 'remotion';+import React, {useMemo} from 'react';+import {AbsoluteFill, spring, useCurrentFrame, useVideoConfig} from 'remotion';import type {Trending} from './Comp';+const TrendingRepoItem: React.FC<{+ repo: string;+ theme: 'dark' | 'light';+ number: number;+}> = ({repo, theme, number}) => {+ const frame = useCurrentFrame();+ const {fps} = useVideoConfig();++ const progress = spring({+ fps,+ frame,+ config: {+ damping: 200,+ },+ delay: number * 10 + 20,+ });++ const item: React.CSSProperties = useMemo(() => {+ return {+ lineHeight: 1.1,+ fontFamily: 'GT Planar',+ fontWeight: '500',+ color: theme === 'dark' ? 'white' : 'black',+ fontFeatureSettings: "'ss03' 1",+ opacity: progress,+ };+ }, [progress, theme]);++ return (+ <div style={item}>+ {number}. {repo}+ </div>+ );+};+export const TrendingRepos: React.FC<{readonly theme: 'dark' | 'light';readonly trending: Trending;}> = ({theme, trending}) => {- const item: React.CSSProperties = {- lineHeight: 1.1,- fontFamily: 'GT Planar',- fontWeight: '500',- color: theme === 'dark' ? 'white' : 'black',- fontFeatureSettings: "'ss03' 1",- };-const fill = theme === 'light' ? '#666' : '#999';+ const frame = useCurrentFrame();+ const {fps} = useVideoConfig();++ const progress1 = spring({+ fps,+ frame,+ config: {+ damping: 200,+ },+ delay: 0,+ });return (<AbsoluteFill>@@ -32,6 +70,7 @@ export const TrendingRepos: React.FC<{fontFamily: 'GT Planar',fontWeight: '500',fontSize: 12,+ opacity: progress1,}}>{new Intl.DateTimeFormat('en-US', {@@ -46,14 +85,16 @@ export const TrendingRepos: React.FC<{fontFamily: 'GT Planar',fontWeight: '500',fontSize: 16,- marginBottom: 10,+ marginBottom: 15,+ opacity: progress1,+ lineHeight: 1,}}>Trending repositories</div>- <div style={item}>1. {trending.repos[0]}</div>- <div style={item}>2. {trending.repos[1]}</div>- <div style={item}>3. {trending.repos[2]}</div>+ <TrendingRepoItem number={1} repo={trending.repos[0]} theme={theme} />+ <TrendingRepoItem number={2} repo={trending.repos[1]} theme={theme} />+ <TrendingRepoItem number={3} repo={trending.repos[2]} theme={theme} /></div></AbsoluteFill></AbsoluteFill>