🎥 Make videos programmatically with React
explainer
Jonny Burger7ea2055eeb1f
diff --git a/packages/cli/src/editor/components/Menu/styles.ts b/packages/cli/src/editor/components/Menu/styles.tsindex cb392b8743..fe2c644f3c 100644--- a/packages/cli/src/editor/components/Menu/styles.ts+++ b/packages/cli/src/editor/components/Menu/styles.ts@@ -37,3 +37,9 @@ export const fullScreenOverlay: React.CSSProperties = {export const outerPortal: React.CSSProperties = {position: 'fixed',};++export const inlineCodeSnippet: React.CSSProperties = {+ fontSize: 14,+ color: 'var(--blue)',+ fontFamily: 'monospace',+};diff --git a/packages/cli/src/editor/components/RenderModal/RenderModal.tsx b/packages/cli/src/editor/components/RenderModal/RenderModal.tsxindex e0a2b68fe8..13fe58b7a2 100644--- a/packages/cli/src/editor/components/RenderModal/RenderModal.tsx+++ b/packages/cli/src/editor/components/RenderModal/RenderModal.tsx@@ -39,9 +39,12 @@ import {GearIcon} from '../../icons/gear';import {GifIcon} from '../../icons/gif';import type {ZodTypeAny} from 'zod';+import {LIGHT_TEXT} from '../../helpers/colors';import {ModalsContext} from '../../state/modals';import {SidebarContext} from '../../state/sidebar';+import {Spacing} from '../layout';import {VERTICAL_SCROLLBAR_CLASSNAME} from '../Menu/is-menu-item';+import {inlineCodeSnippet} from '../Menu/styles';import {getMaxModalHeight,getMaxModalWidth,@@ -1120,7 +1123,13 @@ export const RenderModalWithLoader: React.FC<RenderModalProps> = (props) => {if (!resolved) {return (<ModalContainer onOutsideClick={onQuit} onEscape={onQuit}>- <Spinner duration={1} size={50} />+ <div style={loaderContainer}>+ <Spinner duration={1} size={30} />+ <Spacing y={2} />+ <div style={loaderLabel}>+ Running <code style={inlineCodeSnippet}>calculateMetadata()</code>+ </div>+ </div></ModalContainer>);}@@ -1136,3 +1145,21 @@ export const RenderModalWithLoader: React.FC<RenderModalProps> = (props) => {</ModalContainer>);};++const loaderContainer: React.CSSProperties = {+ paddingTop: 40,+ paddingBottom: 40,+ paddingLeft: 100,+ paddingRight: 100,+ display: 'flex',+ justifyContent: 'center',+ alignItems: 'center',+ flexDirection: 'column',+};++const loaderLabel: React.CSSProperties = {+ fontSize: 14,+ color: LIGHT_TEXT,+ fontFamily: 'sans-serif',+ lineHeight: 1.5,+};diff --git a/packages/cli/src/editor/components/RenderModal/SchemaEditor/SchemaErrorMessages.tsx b/packages/cli/src/editor/components/RenderModal/SchemaEditor/SchemaErrorMessages.tsxindex 55380f5e6f..e29b7e083a 100644--- a/packages/cli/src/editor/components/RenderModal/SchemaEditor/SchemaErrorMessages.tsx+++ b/packages/cli/src/editor/components/RenderModal/SchemaEditor/SchemaErrorMessages.tsx@@ -2,6 +2,7 @@ import type {z} from 'zod';import {Button} from '../../../../preview-server/error-overlay/remotion-overlay/Button';import {LIGHT_TEXT} from '../../../helpers/colors';import {Spacing} from '../../layout';+import {inlineCodeSnippet} from '../../Menu/styles';import {SchemaEmptyStateGraphic} from './SchemaEmptyStateGraphic';import {ZodErrorMessages} from './ZodErrorMessages';@@ -22,12 +23,6 @@ const errorExplanation: React.CSSProperties = {lineHeight: 1.5,};-const codeSnippet: React.CSSProperties = {- fontSize: 14,- color: 'var(--blue)',- fontFamily: 'monospace',-};-const errorContainer: React.CSSProperties = {padding: '8px 12px',overflowY: 'auto',@@ -44,7 +39,7 @@ export const ZodNotInstalled = () => {return (<div style={explainer}><div style={errorExplanation}>- Install <code style={codeSnippet}>zod</code> as a dependency to+ Install <code style={inlineCodeSnippet}>zod</code> as a dependency tointeractively control the props of the composition.</div><Spacing y={2} block />@@ -60,8 +55,8 @@ export const NoSchemaDefined = () => {<Spacing y={5} /><div style={errorExplanation}>Make the props of this composition interactively editable by adding a{' '}- <code style={codeSnippet}>schema</code> prop to the{' '}- <code style={codeSnippet}>{'<Composition>'}</code> component.+ <code style={inlineCodeSnippet}>schema</code> prop to the{' '}+ <code style={inlineCodeSnippet}>{'<Composition>'}</code> component.</div><Spacing y={2} block /><Button onClick={openDocs}>Learn how</Button>@@ -74,13 +69,14 @@ export const NoDefaultProps = () => {<div style={explainer}><div style={errorExplanation}>The schema can not be edited because the{' '}- <code style={codeSnippet}>defaultProps</code> prop in the{' '}- <code style={codeSnippet}>{'<Composition>'}</code> does not exist.+ <code style={inlineCodeSnippet}>defaultProps</code> prop in the{' '}+ <code style={inlineCodeSnippet}>{'<Composition>'}</code> does not exist.</div><Spacing y={1} /><div style={errorExplanation}>- Fix the schema by adding a <code style={codeSnippet}>defaultProps</code>{' '}- prop to your composition.+ Fix the schema by adding a{' '}+ <code style={inlineCodeSnippet}>defaultProps</code> prop to your+ composition.</div><Spacing y={2} block /><Button onClick={openDocs}>Learn more</Button>@@ -97,16 +93,16 @@ export const InvalidDefaultProps: React.FC<{<div style={errorContainer}><div style={errorExplanation}>The schema can not be edited because the{' '}- <code style={codeSnippet}>defaultProps</code> prop in the{' '}- <code style={codeSnippet}>{'<Composition>'}</code> is not valid:+ <code style={inlineCodeSnippet}>defaultProps</code> prop in the{' '}+ <code style={inlineCodeSnippet}>{'<Composition>'}</code> is not valid:</div><Spacing y={1} block /><ZodErrorMessages zodValidationResult={zodValidationResult} /><Spacing y={1} block /><div style={errorExplanation}>Fix the schema by changing the{' '}- <code style={codeSnippet}>defaultProps</code> prop in your composition- so it does not give a type error.+ <code style={inlineCodeSnippet}>defaultProps</code> prop in your+ composition so it does not give a type error.</div></div>);@@ -126,7 +122,8 @@ export const InvalidSchema: React.FC<{<Spacing y={1} block /><div style={errorExplanation}>Alternatively, reset the data to the{' '}- <code style={codeSnippet}>defaultProps</code> that you have defined.+ <code style={inlineCodeSnippet}>defaultProps</code> that you have+ defined.</div><Spacing y={1} block /><Button onClick={reset}>Reset props</Button>diff --git a/packages/core/src/ResolveCompositionConfig.tsx b/packages/core/src/ResolveCompositionConfig.tsxindex 7765a3cf8e..9addca15b1 100644--- a/packages/core/src/ResolveCompositionConfig.tsx+++ b/packages/core/src/ResolveCompositionConfig.tsx@@ -92,6 +92,8 @@ export const ResolveCompositionConfig: React.FC<[]);+ const isTheSame = selectedComposition?.id === renderModalComposition?.id;+useEffect(() => {if (selectedComposition) {doResolution(selectedComposition, selectedEditorProps);@@ -99,10 +101,10 @@ export const ResolveCompositionConfig: React.FC<}, [doResolution, selectedComposition, selectedEditorProps]);useEffect(() => {- if (renderModalComposition) {+ if (renderModalComposition && !isTheSame) {doResolution(renderModalComposition, renderModalProps);}- }, [doResolution, renderModalComposition, renderModalProps]);+ }, [doResolution, isTheSame, renderModalComposition, renderModalProps]);return (<ResolveCompositionContext.Provider value={resolvedConfigs}>