Skip to content

🎥 Make videos programmatically with React

use same label everywhere

Jonny Burger46982b544194
diff --git a/packages/cli/src/editor/components/RenderModal/SchemaEditor/SchemaLabel.tsx b/packages/cli/src/editor/components/RenderModal/SchemaEditor/SchemaLabel.tsx
index 3a5e62aaa9..8e3a5fd5ce 100644
--- a/packages/cli/src/editor/components/RenderModal/SchemaEditor/SchemaLabel.tsx
+++ b/packages/cli/src/editor/components/RenderModal/SchemaEditor/SchemaLabel.tsx
@@ -1,8 +1,7 @@
import React from 'react';
import {LIGHT_TEXT} from '../../../helpers/colors';
-import {Flex, Spacing} from '../../layout';
+import {Flex} from '../../layout';
import {InlineRemoveButton} from '../InlineRemoveButton';
-import {fieldsetLabel} from '../layout';
import {getSchemaLabel} from './get-schema-label';
import {SchemaResetButton} from './SchemaResetButton';
import {SchemaSaveButton} from './SchemaSaveButton';
@@ -38,6 +37,7 @@ export const SchemaLabel: React.FC<{
saving: boolean;
valid: boolean;
saveDisabledByParent: boolean;
+ suffix: string | null;
}> = ({
jsonPath,
isDefaultValue,
@@ -48,12 +48,15 @@ export const SchemaLabel: React.FC<{
saving,
valid,
saveDisabledByParent,
+ suffix,
}) => {
const disableSave = saving || !valid || saveDisabledByParent;
return (
<div style={compactStyles}>
- <span style={labelStyle}>{getSchemaLabel(jsonPath)}</span>
+ <span style={labelStyle}>
+ {getSchemaLabel(jsonPath)} {suffix ? suffix : null}
+ </span>
<Flex />
{isDefaultValue ? null : <SchemaResetButton onClick={onReset} />}
{isDefaultValue ? null : showSaveButton ? (
@@ -63,25 +66,3 @@ export const SchemaLabel: React.FC<{
</div>
);
};
-
-export const SchemaFieldsetLabel: React.FC<{
- jsonPath: JSONPath;
- onRemove: null | (() => void);
- isDefaultValue: boolean;
- onReset: () => void;
- suffix: string | null;
-}> = ({jsonPath, onRemove, isDefaultValue, onReset, suffix}) => {
- return (
- <div style={fieldsetLabel}>
- {getSchemaLabel(jsonPath)}
- {suffix ? suffix : null}
- <Flex />
- {isDefaultValue ? null : <SchemaResetButton onClick={onReset} />}
- {onRemove ? (
- <>
- <Spacing x={1} /> <InlineRemoveButton onClick={onRemove} />
- </>
- ) : null}
- </div>
- );
-};
diff --git a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.tsx b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.tsx
index 374423516b..fd0a26e9a3 100644
--- a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.tsx
+++ b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.tsx
@@ -7,7 +7,6 @@ import {
import {createZodValues} from './create-zod-values';
import {deepEqual} from './deep-equal';
import {useLocalState} from './local-state';
-import {SchemaFieldsetLabel} from './SchemaLabel';
import type {JSONPath} from './zod-types';
import {ZodArrayItemEditor} from './ZodArrayItemEditor';
import type {UpdaterFunction} from './ZodSwitch';
@@ -19,6 +18,7 @@ import type {RenderInlineAction} from '../../InlineAction';
import {InlineAction} from '../../InlineAction';
import {Plus} from '../../../icons/plus';
import {ZodFieldValidation} from './ZodFieldValidation';
+import {SchemaLabel} from './SchemaLabel';
export const ZodArrayEditor: React.FC<{
schema: z.ZodTypeAny;
@@ -85,12 +85,19 @@ export const ZodArrayEditor: React.FC<{
return (
<Fieldset shouldPad={mayPad} success={localValue.zodValidation.success}>
- <SchemaFieldsetLabel
+ <SchemaLabel
onReset={reset}
isDefaultValue={isDefaultValue}
jsonPath={jsonPath}
onRemove={onRemove}
suffix={' ['}
+ onSave={() => {
+ onSave(() => localValue.value, false);
+ }}
+ saveDisabledByParent={saveDisabledByParent}
+ saving={saving}
+ showSaveButton={showSaveButton}
+ valid={localValue.zodValidation.success}
/>
<SchemaVerticalGuide isRoot={false}>
{localValue.value.map((child, i) => {
diff --git a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodBooleanEditor.tsx b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodBooleanEditor.tsx
index 26fa8a3ad7..db2704c1a1 100644
--- a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodBooleanEditor.tsx
+++ b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodBooleanEditor.tsx
@@ -69,6 +69,7 @@ export const ZodBooleanEditor: React.FC<{
saving={saving}
valid
saveDisabledByParent={saveDisabledByParent}
+ suffix={null}
/>
<div style={fullWidth}>
<Checkbox
diff --git a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodColorEditor.tsx b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodColorEditor.tsx
index e88a54192f..4a8a882e2c 100644
--- a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodColorEditor.tsx
+++ b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodColorEditor.tsx
@@ -143,6 +143,7 @@ export const ZodColorEditor: React.FC<{
saving={saving}
valid={localValue.zodValidation.success}
saveDisabledByParent={saveDisabledByParent}
+ suffix={null}
/>
<div style={fullWidth}>
<Row align="center">
diff --git a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodDateEditor.tsx b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodDateEditor.tsx
index a670c047d1..5e71fe3b6a 100644
--- a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodDateEditor.tsx
+++ b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodDateEditor.tsx
@@ -115,6 +115,7 @@ export const ZodDateEditor: React.FC<{
saving={saving}
valid={localValue.zodValidation.success}
saveDisabledByParent={saveDisabledByParent}
+ suffix={null}
/>
<div style={fullWidth}>
<RemotionInput
diff --git a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodEnumEditor.tsx b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodEnumEditor.tsx
index 0454ec8cb6..fa96cd8f82 100644
--- a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodEnumEditor.tsx
+++ b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodEnumEditor.tsx
@@ -94,6 +94,7 @@ export const ZodEnumEditor: React.FC<{
saving={saving}
valid={localValue.zodValidation.success}
saveDisabledByParent={!localValue.zodValidation.success}
+ suffix={null}
/>
<div style={isRoot ? undefined : container}>
diff --git a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodNonEditableValue.tsx b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodNonEditableValue.tsx
index 42731c06f7..dd0de7fc1b 100644
--- a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodNonEditableValue.tsx
+++ b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodNonEditableValue.tsx
@@ -41,6 +41,7 @@ export const ZonNonEditableValue: React.FC<{
saving={saving}
valid
saveDisabledByParent
+ suffix={null}
/>
<div style={fullWidth}>
<em style={wideEmptyLabel}>{label}</em>
diff --git a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodNumberEditor.tsx b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodNumberEditor.tsx
index 773cc95447..2f8f85298a 100644
--- a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodNumberEditor.tsx
+++ b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodNumberEditor.tsx
@@ -133,6 +133,7 @@ export const ZodNumberEditor: React.FC<{
saving={saving}
valid={localValue.zodValidation.success}
saveDisabledByParent={saveDisabledByParent}
+ suffix={null}
/>
<div style={fullWidth}>
<InputDragger
diff --git a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodObjectEditor.tsx b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodObjectEditor.tsx
index 4d03065410..82835128c2 100644
--- a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodObjectEditor.tsx
+++ b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodObjectEditor.tsx
@@ -2,7 +2,6 @@ import React, {useCallback} from 'react';
import type {z} from 'zod';
import {useZodIfPossible} from '../../get-zod-if-possible';
import {useLocalState} from './local-state';
-import {SchemaFieldsetLabel} from './SchemaLabel';
import type {JSONPath} from './zod-types';
import type {UpdaterFunction} from './ZodSwitch';
import {ZodSwitch} from './ZodSwitch';
@@ -10,6 +9,7 @@ import {Fieldset} from './Fieldset';
import {SchemaSeparationLine} from './SchemaSeparationLine';
import {fieldsetLabel} from '../layout';
import {SchemaVerticalGuide} from './SchemaVerticalGuide';
+import {SchemaLabel} from './SchemaLabel';
export const ZodObjectEditor: React.FC<{
schema: z.ZodTypeAny;
@@ -67,12 +67,21 @@ export const ZodObjectEditor: React.FC<{
<div>
<Fieldset shouldPad={!isRoot} success={localValue.zodValidation.success}>
{isRoot ? null : (
- <SchemaFieldsetLabel
+ <SchemaLabel
isDefaultValue
onReset={onRes}
jsonPath={jsonPath}
onRemove={onRemove}
suffix={' {'}
+ onSave={() => {
+ onSave(() => {
+ return localValue.value;
+ }, false);
+ }}
+ saveDisabledByParent={saveDisabledByParent}
+ saving={saving}
+ showSaveButton={showSaveButton}
+ valid={localValue.zodValidation.success}
/>
)}
<SchemaVerticalGuide isRoot={isRoot}>
diff --git a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodOrNullishEditor.tsx b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodOrNullishEditor.tsx
index 536ad8f9dc..36732aaa63 100644
--- a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodOrNullishEditor.tsx
+++ b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodOrNullishEditor.tsx
@@ -149,6 +149,7 @@ export const ZodOrNullishEditor: React.FC<{
saving={saving}
valid={localNonNullishValueValue.zodValidation.success}
saveDisabledByParent={saveDisabledByParent}
+ suffix={null}
/>
) : (
<ZodSwitch
diff --git a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodStaticFileEditor.tsx b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodStaticFileEditor.tsx
index 3e4d378ce7..29ab8280dc 100644
--- a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodStaticFileEditor.tsx
+++ b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodStaticFileEditor.tsx
@@ -99,6 +99,7 @@ export const ZodStaticFileEditor: React.FC<{
saving={saving}
valid={localValue.zodValidation.success}
saveDisabledByParent={saveDisabledByParent}
+ suffix={null}
/>
<div style={isRoot ? undefined : container}>
diff --git a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodStringEditor.tsx b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodStringEditor.tsx
index d7d8dfaac2..3cd33cc2c6 100644
--- a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodStringEditor.tsx
+++ b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodStringEditor.tsx
@@ -75,6 +75,7 @@ export const ZodStringEditor: React.FC<{
saving={saving}
valid={localValue.zodValidation.success}
saveDisabledByParent={saveDisabledByParent}
+ suffix={null}
/>
<div style={fullWidth}>
<RemotionInput