Skip to content

🎥 Make videos programmatically with React

show only if connected

Jonny Burgerb94c855c008d
diff --git a/packages/cli/src/editor/components/MenuBuildIndicator.tsx b/packages/cli/src/editor/components/MenuBuildIndicator.tsx
index a816b4c193..74bfa7fd90 100644
--- a/packages/cli/src/editor/components/MenuBuildIndicator.tsx
+++ b/packages/cli/src/editor/components/MenuBuildIndicator.tsx
@@ -1,4 +1,5 @@
-import React, {useEffect, useState} from 'react';
+import React, {useContext, useEffect, useState} from 'react';
+import {PreviewServerConnectionCtx} from '../helpers/client-id';
import {Spacing} from './layout';
import {OpenEditorButton} from './OpenEditorButton';
@@ -11,8 +12,9 @@ const cwd: React.CSSProperties = {
export const MenuBuildIndicator: React.FC = () => {
const [isBuilding, setIsBuilding] = useState(false);
+ const ctx = useContext(PreviewServerConnectionCtx);
- const editorFound = window.remotion_editorName;
+ const showButton = window.remotion_editorName && ctx.type === 'connected';
useEffect(() => {
window.remotion_isBuilding = () => {
setIsBuilding(true);
@@ -30,9 +32,9 @@ export const MenuBuildIndicator: React.FC = () => {
return (
<div style={cwd} title={window.remotion_cwd}>
- {editorFound ? <Spacing x={5} /> : null}
+ {showButton ? <Spacing x={5} /> : null}
{isBuilding ? 'Building...' : window.remotion_projectName}
- <OpenEditorButton />
+ {showButton ? <OpenEditorButton /> : null}
</div>
);
};
diff --git a/packages/cli/src/editor/components/OpenEditorButton.tsx b/packages/cli/src/editor/components/OpenEditorButton.tsx
index 961aebffdc..2ea9476f4a 100644
--- a/packages/cli/src/editor/components/OpenEditorButton.tsx
+++ b/packages/cli/src/editor/components/OpenEditorButton.tsx
@@ -42,11 +42,7 @@ export const OpenEditorButton: React.FC<{}> = () => {
const buttonTooltip = `Open in ${window.remotion_editorName}`;
const openInEditorSvg = (
- <svg
- xmlns="http://www.w3.org/2000/svg"
- viewBox="0 0 512 512"
- style={svgStyle}
- >
+ <svg viewBox="0 0 512 512" style={svgStyle}>
<path
fill={svgFillColor}
d="M320 0c-17.7 0-32 14.3-32 32s14.3 32 32 32h82.7L201.4 265.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L448 109.3V192c0 17.7 14.3 32 32 32s32-14.3 32-32V32c0-17.7-14.3-32-32-32H320zM80 32C35.8 32 0 67.8 0 112V432c0 44.2 35.8 80 80 80H400c44.2 0 80-35.8 80-80V320c0-17.7-14.3-32-32-32s-32 14.3-32 32V432c0 8.8-7.2 16-16 16H80c-8.8 0-16-7.2-16-16V112c0-8.8 7.2-16 16-16H192c17.7 0 32-14.3 32-32s-14.3-32-32-32H80z"
@@ -61,10 +57,6 @@ export const OpenEditorButton: React.FC<{}> = () => {
setHovered(false);
}, []);
- if (!window.remotion_editorName) {
- return null;
- }
-
return (
<button
title={buttonTooltip}