🎥 Make videos programmatically with React
add a schema test
Jonny Burger41889808f3ea
diff --git a/packages/cli/src/editor/components/NewComposition/ValidationMessage.tsx b/packages/cli/src/editor/components/NewComposition/ValidationMessage.tsxindex f4b8820dab..da05061264 100644--- a/packages/cli/src/editor/components/NewComposition/ValidationMessage.tsx+++ b/packages/cli/src/editor/components/NewComposition/ValidationMessage.tsx@@ -22,6 +22,8 @@ const container: React.CSSProperties = {const label: React.CSSProperties = {fontSize: 13,+ color: 'white',+ fontFamily: 'sans-serif',};export const ValidationMessage: React.FC<{diff --git a/packages/cli/src/editor/components/RenderModal/RenderModalJSONInputPropsEditor.tsx b/packages/cli/src/editor/components/RenderModal/RenderModalJSONInputPropsEditor.tsxindex e94f6fc7a3..592d565697 100644--- a/packages/cli/src/editor/components/RenderModal/RenderModalJSONInputPropsEditor.tsx+++ b/packages/cli/src/editor/components/RenderModal/RenderModalJSONInputPropsEditor.tsx@@ -65,17 +65,22 @@ export const RenderModalJSONInputPropsEditor: React.FC<{setLocalValue({...localValue, value: JSON.stringify(parsed, null, 2)});}, [localValue]);+ const onChange: React.ChangeEventHandler<HTMLTextAreaElement> = useCallback(+ (e) => {+ const parsed = parseJSON(e.target.value);+ setLocalValue({value: e.target.value, validJSON: parsed.validJSON});++ if (parsed.validJSON) {+ setValue(parsed.value);+ }+ },+ [setValue]+ );+return (<div><RemTextarea- onChange={(e) => {- const parsed = parseJSON(e.target.value);- setLocalValue({value: e.target.value, validJSON: parsed.validJSON});-- if (parsed.validJSON) {- setValue(parsed.value);- }- }}+ onChange={onChange}value={localValue.value}status={localValue.validJSON ? 'ok' : 'error'}style={style}diff --git a/packages/example/src/SchemaTest/index.tsx b/packages/example/src/SchemaTest/index.tsxnew file mode 100644index 0000000000..42780a930d--- /dev/null+++ b/packages/example/src/SchemaTest/index.tsx@@ -0,0 +1,24 @@+import React from 'react';+import {AbsoluteFill, Sequence, z} from 'remotion';++export const schemaTestSchema = z.object({+ title: z.string(),+ delay: z.number().min(0).max(1000).step(1),+});++export const SchemaTest: React.FC<z.infer<typeof schemaTestSchema>> = ({+ delay,+ title,+}) => {+ return (+ <AbsoluteFill+ style={{+ justifyContent: 'center',+ alignItems: 'center',+ fontSize: 80,+ }}+ >+ <Sequence from={delay}>{title}</Sequence>+ </AbsoluteFill>+ );+};diff --git a/packages/example/src/Video.tsx b/packages/example/src/Video.tsxindex e007caec0f..c1003602f2 100644--- a/packages/example/src/Video.tsx+++ b/packages/example/src/Video.tsx@@ -21,6 +21,7 @@ import InfinityVideo from './ReallyLongVideo';import RemoteVideo from './RemoteVideo';import RiveVehicle from './Rive/RiveExample';import {ScalePath} from './ScalePath';+import {SchemaTest, schemaTestSchema} from './SchemaTest';import {Scripts} from './Scripts';import CircleTest from './Shapes/CircleTest';import EllipseTest from './Shapes/EllipseTest';@@ -706,6 +707,21 @@ export const Index: React.FC = () => {durationInFrames={150}/></Folder>+ <Folder name="Schema">+ <Composition+ id="schema-test"+ component={SchemaTest}+ width={1200}+ height={630}+ fps={30}+ durationInFrames={150}+ schema={schemaTestSchema}+ defaultProps={{+ title: 'Hello World!',+ delay: 50,+ }}+ />+ </Folder></>);};