Skip to content

🎥 Make videos programmatically with React

fix color picker not working

Jonny Burgerbc52a3f45c04
diff --git a/packages/core/src/ResolveCompositionConfig.tsx b/packages/core/src/ResolveCompositionConfig.tsx
index 7004f8030c..5601d782dd 100644
--- a/packages/core/src/ResolveCompositionConfig.tsx
+++ b/packages/core/src/ResolveCompositionConfig.tsx
@@ -11,6 +11,7 @@ import {
} from 'react';
import type {AnyComposition} from './CompositionManager.js';
import {CompositionManager} from './CompositionManagerContext.js';
+import {getInputProps} from './config/input-props.js';
import {EditorPropsContext} from './EditorProps.js';
import {resolveVideoConfig} from './resolve-video-config.js';
import type {VideoConfig} from './video-config.js';
@@ -214,11 +215,16 @@ export const useResolvedVideoConfig = (
const context = useContext(
ResolveCompositionContext
) as ResolveCompositionConfigContect;
+ const {props: allEditorProps} = useContext(EditorPropsContext);
const {compositions, currentComposition} = useContext(CompositionManager);
const compositionId = preferredCompositionId ?? currentComposition;
const composition = compositions.find((c) => c.id === compositionId);
+ const selectedEditorProps = useMemo(() => {
+ return composition ? allEditorProps[composition.id] ?? {} : {};
+ }, [allEditorProps, composition]);
+
return useMemo(() => {
if (!composition) {
return null;
@@ -228,7 +234,14 @@ export const useResolvedVideoConfig = (
if (needsResolution === null) {
return {
type: 'success',
- result: {...composition, defaultProps: composition.defaultProps ?? {}},
+ result: {
+ ...composition,
+ defaultProps: {
+ ...(composition.defaultProps ?? {}),
+ ...(selectedEditorProps ?? {}),
+ ...(getInputProps() ?? {}),
+ },
+ },
};
}
@@ -237,5 +250,5 @@ export const useResolvedVideoConfig = (
}
return context[composition.id] as VideoConfigState;
- }, [composition, context]);
+ }, [composition, context, selectedEditorProps]);
};
diff --git a/packages/example/src/SchemaTest/index.tsx b/packages/example/src/SchemaTest/index.tsx
index c45fde8574..3e0af96f2d 100644
--- a/packages/example/src/SchemaTest/index.tsx
+++ b/packages/example/src/SchemaTest/index.tsx
@@ -1,3 +1,4 @@
+import {zColor} from '@remotion/zod-types';
import React from 'react';
import {AbsoluteFill, Sequence} from 'remotion';
import {z} from 'zod';
@@ -5,6 +6,7 @@ import {z} from 'zod';
export const schemaTestSchema = z.object({
title: z.string().nullable(),
delay: z.number().min(0).max(1000).step(0.1),
+ color: zColor(),
});
export const schemaArrayTestSchema = z.array(z.number());
@@ -24,6 +26,7 @@ export const ArrayTest: React.FC = () => {
export const SchemaTest: React.FC<z.infer<typeof schemaTestSchema>> = ({
delay,
title,
+ color,
}) => {
return (
<AbsoluteFill
@@ -33,7 +36,9 @@ export const SchemaTest: React.FC<z.infer<typeof schemaTestSchema>> = ({
fontSize: 80,
}}
>
- <Sequence from={delay}>{title}</Sequence>
+ <Sequence from={delay}>
+ <span style={{color}}>{title}</span>
+ </Sequence>
</AbsoluteFill>
);
};
diff --git a/packages/example/src/Video.tsx b/packages/example/src/Video.tsx
index a2da87f71a..8666ac8767 100644
--- a/packages/example/src/Video.tsx
+++ b/packages/example/src/Video.tsx
@@ -886,7 +886,7 @@ export const Index: React.FC = () => {
fps={30}
durationInFrames={150}
schema={schemaTestSchema}
- defaultProps={{title: 'fsdfsdfsdfsdf', delay: 5.2}}
+ defaultProps={{title: 'sdasdsd', delay: 5.2, color: '#df822a'}}
/>
{/**
// @ts-expect-error */}