Skip to content

🎥 Make videos programmatically with React

Make explorer and opiton panel responsive

Chetan Karwaed42ae7332c6
diff --git a/packages/bundler/src/index-html.ts b/packages/bundler/src/index-html.ts
index b5eb5c2464..559a5748ea 100644
--- a/packages/bundler/src/index-html.ts
+++ b/packages/bundler/src/index-html.ts
@@ -109,6 +109,8 @@ export const indexHtml = ({
<div id="menuportal-3"></div>
<div id="menuportal-4"></div>
<div id="menuportal-5"></div>
+ <div id="explorer-panel"></div>
+ <div id="option-panel"></div>
<div id="remotion-error-overlay"></div>
<div id="server-disconnected-overlay"></div>
<script src="${baseDir}bundle.js"></script>
diff --git a/packages/studio/src/components/OptionsPanel.tsx b/packages/studio/src/components/OptionsPanel.tsx
index 53af625910..c462e8e61c 100644
--- a/packages/studio/src/components/OptionsPanel.tsx
+++ b/packages/studio/src/components/OptionsPanel.tsx
@@ -10,20 +10,13 @@ import type {AnyComposition} from 'remotion';
import {Internals} from 'remotion';
import {cmdOrCtrlCharacter} from '../error-overlay/remotion-overlay/ShortcutHint';
import {BACKGROUND, LIGHT_TEXT} from '../helpers/colors';
+import {useMobileLayout} from '../helpers/mobile-layout';
import {DataEditor} from './RenderModal/DataEditor';
import {deepEqual} from './RenderModal/SchemaEditor/deep-equal';
import {RenderQueue} from './RenderQueue';
import {RendersTab} from './RendersTab';
import {Tab, Tabs} from './Tabs';
-const container: React.CSSProperties = {
- height: '100%',
- width: '100%',
- position: 'absolute',
- display: 'flex',
- flexDirection: 'column',
-};
-
const circle: React.CSSProperties = {
width: 8,
height: 8,
@@ -66,6 +59,21 @@ export const OptionsPanel: React.FC<{
}> = ({readOnlyStudio}) => {
const {props, updateProps} = useContext(Internals.EditorPropsContext);
const [saving, setSaving] = useState(false);
+
+ const isMobileLayout = useMobileLayout();
+
+ const container: React.CSSProperties = useMemo(
+ () => ({
+ height: '100%',
+ width: '100%',
+ display: 'flex',
+ position: isMobileLayout ? 'relative' : 'absolute',
+ flexDirection: 'column',
+ flex: 1,
+ }),
+ [isMobileLayout],
+ );
+
const [panel, setPanel] = useState<OptionsSidebarPanel>(() =>
getSelectedPanel(readOnlyStudio),
);
diff --git a/packages/studio/src/components/TopPanel.tsx b/packages/studio/src/components/TopPanel.tsx
index 68f0d70987..745b726350 100644
--- a/packages/studio/src/components/TopPanel.tsx
+++ b/packages/studio/src/components/TopPanel.tsx
@@ -1,5 +1,6 @@
import type {Size} from '@remotion/player';
import React, {useCallback, useContext, useEffect, useMemo} from 'react';
+import {useMobileLayout} from '../helpers/mobile-layout';
import {useBreakpoint} from '../helpers/use-breakpoint';
import {RULER_WIDTH} from '../state/editor-rulers';
import {SidebarContext} from '../state/sidebar';
@@ -10,6 +11,7 @@ import {
} from './CurrentCompositionSideEffects';
import {useIsRulerVisible} from './EditorRuler/use-is-ruler-visible';
import {ExplorerPanel} from './ExplorerPanel';
+import MobilePanel from './MobilePanel';
import {OptionsPanel} from './OptionsPanel';
import {PreviewToolbar} from './PreviewToolbar';
import {SplitterContainer} from './Splitter/SplitterContainer';
@@ -50,6 +52,9 @@ export const useResponsiveSidebarStatus = (): 'collapsed' | 'expanded' => {
return actualStateLeft;
};
+const explorerPortal = document.getElementById('explorer-panel') as Element;
+const optionPortal = document.getElementById('option-panel') as Element;
+
export const TopPanel: React.FC<{
readOnlyStudio: boolean;
onMounted: () => void;
@@ -101,6 +106,8 @@ export const TopPanel: React.FC<{
setSidebarCollapsedState({left: null, right: 'collapsed'});
}, [setSidebarCollapsedState]);
+ const isMobileLayout = useMobileLayout();
+
return (
<div style={container}>
<div style={row}>
@@ -112,9 +119,15 @@ export const TopPanel: React.FC<{
orientation="vertical"
>
{actualStateLeft === 'expanded' ? (
- <SplitterElement sticky={null} type="flexer">
- <ExplorerPanel readOnlyStudio={readOnlyStudio} />
- </SplitterElement>
+ isMobileLayout ? (
+ <MobilePanel onClose={onCollapseLeft} portal={explorerPortal}>
+ <ExplorerPanel readOnlyStudio={readOnlyStudio} />
+ </MobilePanel>
+ ) : (
+ <SplitterElement sticky={null} type="flexer">
+ <ExplorerPanel readOnlyStudio={readOnlyStudio} />
+ </SplitterElement>
+ )
) : null}
{actualStateLeft === 'expanded' ? (
<SplitterHandle
@@ -142,9 +155,15 @@ export const TopPanel: React.FC<{
/>
) : null}
{actualStateRight === 'expanded' ? (
- <SplitterElement sticky={null} type="anti-flexer">
- <OptionsPanel readOnlyStudio={readOnlyStudio} />
- </SplitterElement>
+ isMobileLayout ? (
+ <MobilePanel onClose={onCollapseRight} portal={optionPortal}>
+ <OptionsPanel readOnlyStudio={readOnlyStudio} />
+ </MobilePanel>
+ ) : (
+ <SplitterElement sticky={null} type="anti-flexer">
+ <OptionsPanel readOnlyStudio={readOnlyStudio} />
+ </SplitterElement>
+ )
) : null}
</SplitterContainer>
</SplitterElement>