Skip to content

🎥 Make videos programmatically with React

advanced settings section

Jonny Burger932e15e091da
diff --git a/packages/cli/src/editor/components/CollapsableOptions.tsx b/packages/cli/src/editor/components/CollapsableOptions.tsx
new file mode 100644
index 0000000000..3b9d9c3ecd
--- /dev/null
+++ b/packages/cli/src/editor/components/CollapsableOptions.tsx
@@ -0,0 +1,55 @@
+import React, {useCallback, useState} from 'react';
+import {LIGHT_TEXT} from '../helpers/colors';
+import {useZIndex} from '../state/z-index';
+import {Spacing} from './layout';
+import {TimelineCollapseToggle} from './Timeline/TimelineCollapseToggle';
+
+const container: React.CSSProperties = {
+ marginLeft: 16,
+ height: 40,
+ display: 'flex',
+ flexDirection: 'row',
+ alignItems: 'center',
+};
+
+const buttonStyle: React.CSSProperties = {
+ border: 'none',
+ padding: 0,
+ appearance: 'none',
+ display: 'flex',
+ flexDirection: 'row',
+ alignItems: 'center',
+ fontSize: 14,
+ color: LIGHT_TEXT,
+};
+
+export const CollapsableOptions: React.FC<{
+ children: React.ReactNode;
+ showLabel: string;
+ hideLabel: string;
+}> = ({children, showLabel, hideLabel}) => {
+ const [show, setShow] = useState(false);
+ const {tabIndex} = useZIndex();
+
+ const onClick = useCallback(() => {
+ setShow((s) => !s);
+ }, []);
+
+ return (
+ <>
+ <div style={container}>
+ <button
+ style={buttonStyle}
+ tabIndex={tabIndex}
+ onClick={onClick}
+ type="button"
+ >
+ <TimelineCollapseToggle color={LIGHT_TEXT} collapsed={!show} />
+ <Spacing block x={1} />
+ {show ? hideLabel : showLabel}
+ </button>
+ </div>
+ {show ? children : null}
+ </>
+ );
+};
diff --git a/packages/cli/src/editor/components/RenderModal/RenderModal.tsx b/packages/cli/src/editor/components/RenderModal/RenderModal.tsx
index e1f7e22ce7..9304594d27 100644
--- a/packages/cli/src/editor/components/RenderModal/RenderModal.tsx
+++ b/packages/cli/src/editor/components/RenderModal/RenderModal.tsx
@@ -15,6 +15,7 @@ import {Button} from '../../../preview-server/error-overlay/remotion-overlay/But
import {LIGHT_TEXT} from '../../helpers/colors';
import {useFileExistence} from '../../helpers/use-file-existence';
import {ModalsContext} from '../../state/modals';
+import {CollapsableOptions} from '../CollapsableOptions';
import {Spacing} from '../layout';
import {ModalContainer} from '../ModalContainer';
import {NewCompHeader} from '../ModalHeader';
@@ -305,41 +306,45 @@ export const RenderModal: React.FC<{composition: TCompMetadata}> = ({
</div>
</div>
</div>
- <div style={optionRow}>
- <div style={label}>Scale</div>
- <div style={rightRow}>
- <InputDragger
- value={scale}
- onChange={onScaleChanged}
- placeholder="0.1-10"
- // TODO: Does not allow non-integer steps
- // TODO: Cannot click and type in 0.2
- onValueChange={onScaleSetDirectly}
- name="scale"
- step={0.05}
- min={MIN_SCALE}
- max={MAX_SCALE}
- />
- </div>
- </div>
- {imageFormat === 'jpeg' && (
+ <CollapsableOptions
+ showLabel="Show advanced settings"
+ hideLabel="Hide advanced settings"
+ >
<div style={optionRow}>
- <div style={label}>Quality</div>
+ <div style={label}>Scale</div>
<div style={rightRow}>
<InputDragger
- value={quality}
- onChange={onQualityChanged}
- placeholder="0-100"
- onValueChange={onQualityChangedDirectly}
- name="quality"
- step={1}
- min={MIN_QUALITY}
- max={MAX_QUALITY}
+ value={scale}
+ onChange={onScaleChanged}
+ placeholder="0.1-10"
+ // TODO: Does not allow non-integer steps
+ // TODO: Cannot click and type in 0.2
+ onValueChange={onScaleSetDirectly}
+ name="scale"
+ step={0.05}
+ min={MIN_SCALE}
+ max={MAX_SCALE}
/>
</div>
</div>
- )}
-
+ {imageFormat === 'jpeg' && (
+ <div style={optionRow}>
+ <div style={label}>JPEG Quality</div>
+ <div style={rightRow}>
+ <InputDragger
+ value={quality}
+ onChange={onQualityChanged}
+ placeholder="0-100"
+ onValueChange={onQualityChangedDirectly}
+ name="quality"
+ step={1}
+ min={MIN_QUALITY}
+ max={MAX_QUALITY}
+ />
+ </div>
+ </div>
+ )}
+ </CollapsableOptions>
<Spacing block y={0.5} />
<div style={buttonRow}>
<Button onClick={onClick} disabled={state.type === 'load'}>
diff --git a/packages/cli/src/editor/components/Timeline/TimelineCollapseToggle.tsx b/packages/cli/src/editor/components/Timeline/TimelineCollapseToggle.tsx
index 20dc804f27..4daceb19a5 100644
--- a/packages/cli/src/editor/components/Timeline/TimelineCollapseToggle.tsx
+++ b/packages/cli/src/editor/components/Timeline/TimelineCollapseToggle.tsx
@@ -1,6 +1,5 @@
import type {SVGProps} from 'react';
import React from 'react';
-import {LIGHT_COLOR} from '../../helpers/colors';
const container: React.CSSProperties = {
height: 10,
@@ -10,22 +9,27 @@ const container: React.CSSProperties = {
alignItems: 'center',
};
-const Icon: React.FC<SVGProps<SVGSVGElement>> = (props) => {
+const Icon: React.FC<
+ SVGProps<SVGSVGElement> & {
+ color: string;
+ }
+> = ({color, ...props}) => {
return (
<svg viewBox="0 0 8 10" {...props} style={{height: 10, width: 8}}>
- <path d="M 0 0 L 8 5 L 0 10 z" fill={LIGHT_COLOR} />
+ <path d="M 0 0 L 8 5 L 0 10 z" fill={color} />
</svg>
);
};
export const TimelineCollapseToggle: React.FC<{
collapsed: boolean;
-}> = ({collapsed}) => {
+ color: string;
+}> = ({collapsed, color}) => {
return (
<div
style={collapsed ? container : {...container, transform: 'rotate(90deg)'}}
>
- <Icon />
+ <Icon color={color} />
</div>
);
};
diff --git a/packages/cli/src/editor/components/Timeline/TimelineListItem.tsx b/packages/cli/src/editor/components/Timeline/TimelineListItem.tsx
index 205face34c..54ef4fea72 100644
--- a/packages/cli/src/editor/components/Timeline/TimelineListItem.tsx
+++ b/packages/cli/src/editor/components/Timeline/TimelineListItem.tsx
@@ -1,5 +1,6 @@
import React, {useCallback, useMemo} from 'react';
import type {TSequence} from 'remotion';
+import {LIGHT_COLOR} from '../../helpers/colors';
import {
TIMELINE_BORDER,
TIMELINE_LAYER_HEIGHT,
@@ -135,7 +136,7 @@ export const TimelineListItem: React.FC<{
style={collapserButton}
onClick={toggleCollapse}
>
- <TimelineCollapseToggle collapsed={collapsed} />
+ <TimelineCollapseToggle color={LIGHT_COLOR} collapsed={collapsed} />
</button>
) : (
<div style={collapser} />