🎥 Make videos programmatically with React
@remotion/brand: Refine coding handoff windows
Jonny Burgerdc7ad2b1c5d7
diff --git a/packages/brand/src/Root.tsx b/packages/brand/src/Root.tsxindex a5435677c6..19d5be007e 100644--- a/packages/brand/src/Root.tsx+++ b/packages/brand/src/Root.tsx@@ -412,7 +412,7 @@ export const RemotionRoot: React.FC = () => {width={785}height={928}schema={codexSchema}- defaultProps={{height: 928, width: 785}}+ defaultProps={{borderRadius: 6, height: 928, width: 785}}calculateMetadata={({props}) => ({height: props.height,width: props.width,@@ -423,10 +423,11 @@ export const RemotionRoot: React.FC = () => {component={TextEditor}durationInFrames={1}fps={30}- width={1237}- height={1250}+ width={720}+ height={822}schema={textEditorSchema}defaultProps={{+ borderRadius: 6,code: `import {Video} from '@remotion/media';import {interpolate, useVideoConfig} from 'remotion';import {assetUrl} from './assets';@@ -467,9 +468,9 @@ export const Scene11: React.FC<{platform: EndCardPlatform}> = ({platform}) => {};`,fileName: 'Scene11.tsx',- height: 1250,+ height: 822,highlightedLines: '39',- width: 1237,+ width: 720,}}calculateMetadata={({props}) => ({height: props.height,diff --git a/packages/brand/src/video-elements/Codex.tsx b/packages/brand/src/video-elements/Codex.tsxindex a769d8dd56..a718b8dafe 100644--- a/packages/brand/src/video-elements/Codex.tsx+++ b/packages/brand/src/video-elements/Codex.tsx@@ -22,6 +22,7 @@ import {} from './codex-icons';export const codexSchema = z.object({+ borderRadius: z.number().nonnegative(),height: z.number().int().positive(),width: z.number().int().positive(),});@@ -529,7 +530,7 @@ const Composer: React.FC<{readonly top: number}> = ({top}) => {);};-export const Codex: React.FC<CodexProps> = ({height, width}) => {+export const Codex: React.FC<CodexProps> = ({borderRadius, height, width}) => {const scale = Math.min(width / MINIMUM_WIDTH, height / MINIMUM_HEIGHT);const scaledWidth = MINIMUM_WIDTH * scale;const scaledHeight = MINIMUM_HEIGHT * scale;@@ -539,7 +540,7 @@ export const Codex: React.FC<CodexProps> = ({height, width}) => {style={{WebkitFontSmoothing: 'antialiased',backgroundColor: '#ffffff',- borderRadius: 10 * scale,+ borderRadius,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif',fontWeight: 400,@@ -550,7 +551,7 @@ export const Codex: React.FC<CodexProps> = ({height, width}) => {name="Codex window"style={{backgroundColor: '#ffffff',- borderRadius: 10,+ borderRadius: borderRadius / scale,height: MINIMUM_HEIGHT,left: (width - scaledWidth) / 2,overflow: 'hidden',diff --git a/packages/brand/src/video-elements/StudioCodeHandoff.tsx b/packages/brand/src/video-elements/StudioCodeHandoff.tsxindex 6ad0c81bb6..b07b104696 100644--- a/packages/brand/src/video-elements/StudioCodeHandoff.tsx+++ b/packages/brand/src/video-elements/StudioCodeHandoff.tsx@@ -57,6 +57,7 @@ export const StudioCodeHandoff: React.FC = () => {<Interactive.Divname="VS Code"style={{+ borderRadius: windowBorderRadius,height: 748,left: 0,overflow: 'hidden',@@ -76,6 +77,7 @@ export const StudioCodeHandoff: React.FC = () => {}}><TextEditor+ borderRadius={windowBorderRadius}code={`import {Video} from '@remotion/media';import {interpolate, useVideoConfig} from 'remotion';import {assetUrl} from './assets';@@ -120,6 +122,7 @@ export const Scene11: React.FC = () => {<Interactive.Divname="Codex"style={{+ borderRadius: windowBorderRadius,height: 748,left: 0,overflow: 'hidden',@@ -142,7 +145,11 @@ export const Scene11: React.FC = () => {width: 667,}}>- <Codex height={748} width={667} />+ <Codex+ borderRadius={windowBorderRadius}+ height={748}+ width={667}+ /></Interactive.Div><Interactive.Divdiff --git a/packages/brand/src/video-elements/TextEditor.tsx b/packages/brand/src/video-elements/TextEditor.tsxindex ce4a70c133..2fb9be3005 100644--- a/packages/brand/src/video-elements/TextEditor.tsx+++ b/packages/brand/src/video-elements/TextEditor.tsx@@ -5,10 +5,8 @@ import {Interactive, useDelayRender} from 'remotion';import {z} from 'zod';import {ReactFileIcon, VscodeIcon} from './vscode-icons';-const REFERENCE_WIDTH = 1237;-const REFERENCE_HEIGHT = 1250;-export const textEditorSchema = z.object({+ borderRadius: z.number().nonnegative(),code: z.string().describe('Code shown in the editor'),fileName: z.string().describe('Active file name'),height: z.number().int().min(320).max(4096).describe('Output height'),@@ -21,13 +19,23 @@ export const textEditorSchema = z.object({export type TextEditorProps = z.infer<typeof textEditorSchema>;export const TextEditor: React.FC<TextEditorProps> = ({+ borderRadius,code,fileName,height,highlightedLines,width,}) => {- const scale = Math.min(width / REFERENCE_WIDTH, height / REFERENCE_HEIGHT);+ const codeLines = code.split('\n');+ const referenceWidth = Math.max(+ 720,+ Math.max(...codeLines.map((line) => line.replaceAll('\t', ' ').length)) *+ 7.25 ++ 100,+ );+ const referenceHeight = Math.max(320, codeLines.length * 18 + 120);+ const scale = Math.min(width / referenceWidth, height / referenceHeight);+ const scaledWidth = referenceWidth * scale;const titleBarHeight = 28 * scale;const tabBarHeight = 34 * scale;const breadcrumbHeight = 22 * scale;@@ -139,10 +147,13 @@ export const TextEditor: React.FC<TextEditorProps> = ({name="Backdrop"style={{backgroundColor: '#000000',- borderRadius: 10 * scale,- inset: 0,+ borderRadius,+ height,+ left: (width - scaledWidth) / 2,overflow: 'hidden',position: 'absolute',+ top: 0,+ width: scaledWidth,}}><Interactive.Div@@ -150,7 +161,7 @@ export const TextEditor: React.FC<TextEditorProps> = ({style={{backgroundColor: '#131414',border: `${scale}px solid #454545`,- borderRadius: 10 * scale,+ borderRadius,boxSizing: 'border-box',color: '#cccccc',fontFamily:@@ -160,7 +171,7 @@ export const TextEditor: React.FC<TextEditorProps> = ({overflow: 'hidden',position: 'absolute',top: 0,- width,+ width: scaledWidth,}}><Interactive.Div@@ -387,7 +398,7 @@ export const TextEditor: React.FC<TextEditorProps> = ({paddingRight: 14 * scale,}}>- <span>Ln {code.split('\n').length}, Col 1</span>+ <span>Ln {codeLines.length}, Col 1</span><span>Tab Size: 4</span><span>UTF-8</span><span>LF</span>