Skip to content

🎥 Make videos programmatically with React

Remotion Studio: Make composition list full height if no composition is currently selected

Jonny Burgerf1cd91db63ed
diff --git a/packages/cli/src/editor/components/CompositionSelector.tsx b/packages/cli/src/editor/components/CompositionSelector.tsx
index 3b0bb3d673..15563c7fad 100644
--- a/packages/cli/src/editor/components/CompositionSelector.tsx
+++ b/packages/cli/src/editor/components/CompositionSelector.tsx
@@ -20,7 +20,10 @@ import {
} from '../helpers/persist-open-folders';
import {useZIndex} from '../state/z-index';
import {CompositionSelectorItem} from './CompositionSelectorItem';
-import {CurrentComposition} from './CurrentComposition';
+import {
+ CurrentComposition,
+ CURRENT_COMPOSITION_HEIGHT,
+} from './CurrentComposition';
import {useSelectComposition} from './InitialCompositionLoader';
const container: React.CSSProperties = {
@@ -31,11 +34,6 @@ const container: React.CSSProperties = {
backgroundColor: BACKGROUND,
};
-const list: React.CSSProperties = {
- height: 'calc(100% - 80px)',
- overflowY: 'auto',
-};
-
export const getKeysToExpand = (
initialFolderName: string,
parentFolderName: string | null,
@@ -136,11 +134,21 @@ export const CompositionSelector: React.FC = () => {
return createFolderTree(compositions, folders, foldersExpanded);
}, [compositions, folders, foldersExpanded]);
+ const showCurrentComposition =
+ canvasContent && canvasContent.type === 'composition';
+
+ const list: React.CSSProperties = useMemo(() => {
+ return {
+ height: showCurrentComposition
+ ? `calc(100% - ${CURRENT_COMPOSITION_HEIGHT}px)`
+ : '100%',
+ overflowY: 'auto',
+ };
+ }, [showCurrentComposition]);
+
return (
<div style={container}>
- {canvasContent && canvasContent.type === 'composition' ? (
- <CurrentComposition />
- ) : null}
+ {showCurrentComposition ? <CurrentComposition /> : null}
<div className="__remotion-vertical-scrollbar" style={list}>
{items.map((c) => {
return (
@@ -148,9 +156,7 @@ export const CompositionSelector: React.FC = () => {
key={c.key + c.type}
level={0}
currentComposition={
- canvasContent && canvasContent.type === 'composition'
- ? canvasContent.compositionId
- : null
+ showCurrentComposition ? canvasContent.compositionId : null
}
selectComposition={selectComposition}
toggleFolder={toggleFolder}
diff --git a/packages/cli/src/editor/components/CurrentComposition.tsx b/packages/cli/src/editor/components/CurrentComposition.tsx
index 0727aef7eb..0baf1f420d 100644
--- a/packages/cli/src/editor/components/CurrentComposition.tsx
+++ b/packages/cli/src/editor/components/CurrentComposition.tsx
@@ -4,8 +4,10 @@ import {BACKGROUND, BORDER_COLOR} from '../helpers/colors';
import {isCompositionStill} from '../helpers/is-composition-still';
import {renderFrame} from '../state/render-frame';
+export const CURRENT_COMPOSITION_HEIGHT = 80;
+
const container: React.CSSProperties = {
- height: 80,
+ height: CURRENT_COMPOSITION_HEIGHT,
display: 'block',
borderBottom: `1px solid ${BORDER_COLOR}`,
padding: 12,