Skip to content

🎥 Make videos programmatically with React

finish update command

Jonny Burger67a792b429c7
diff --git a/packages/cli/src/editor/components/CopyButton.tsx b/packages/cli/src/editor/components/CopyButton.tsx
new file mode 100644
index 0000000000..2e7245ad08
--- /dev/null
+++ b/packages/cli/src/editor/components/CopyButton.tsx
@@ -0,0 +1,60 @@
+import React, {useCallback, useState} from 'react';
+import {copyCmd} from '../helpers/copy-text';
+import {Row, Spacing} from './layout';
+
+const copyIcon = (
+ <svg
+ aria-hidden="true"
+ focusable="false"
+ data-prefix="far"
+ data-icon="clipboard"
+ className="svg-inline--fa fa-clipboard fa-w-12"
+ role="img"
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 384 512"
+ style={{width: 16, height: 16, color: 'white'}}
+ >
+ <path
+ fill="currentColor"
+ d="M336 64h-80c0-35.3-28.7-64-64-64s-64 28.7-64 64H48C21.5 64 0 85.5 0 112v352c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V112c0-26.5-21.5-48-48-48zM192 40c13.3 0 24 10.7 24 24s-10.7 24-24 24-24-10.7-24-24 10.7-24 24-24zm144 418c0 3.3-2.7 6-6 6H54c-3.3 0-6-2.7-6-6V118c0-3.3 2.7-6 6-6h42v36c0 6.6 5.4 12 12 12h168c6.6 0 12-5.4 12-12v-36h42c3.3 0 6 2.7 6 6z"
+ />
+ </svg>
+);
+
+const container: React.CSSProperties = {
+ border: `2px solid rgba(255, 255, 255, 0.2)`,
+ borderRadius: 4,
+ padding: 10,
+ cursor: 'pointer',
+};
+
+const button: React.CSSProperties = {
+ backgroundColor: 'transparent',
+ appearance: 'none',
+ border: 'none',
+ fontFamily: 'inherit',
+ fontSize: 16,
+ color: 'white',
+};
+
+export const CopyButton: React.FC<{
+ textToCopy: string;
+ label: string;
+ labelWhenCopied: string;
+}> = ({textToCopy, label, labelWhenCopied}) => {
+ const [copied, setCopied] = useState(false);
+
+ const onClick = useCallback(() => {
+ copyCmd(textToCopy);
+ setCopied(true);
+ }, [textToCopy]);
+
+ return (
+ <button onClick={onClick} style={button} type="button">
+ <Row style={container}>
+ {copyIcon}
+ <Spacing x={1} /> {copied ? labelWhenCopied : label}
+ </Row>
+ </button>
+ );
+};
diff --git a/packages/cli/src/editor/components/MenuToolbar.tsx b/packages/cli/src/editor/components/MenuToolbar.tsx
index dd8edbeaec..c2878e1b37 100644
--- a/packages/cli/src/editor/components/MenuToolbar.tsx
+++ b/packages/cli/src/editor/components/MenuToolbar.tsx
@@ -133,7 +133,7 @@ export const MenuToolbar: React.FC = () => {
onClick: () => {
close();
setSelectedModal({
- compType: 'composition',
+ compType: 'still',
type: 'new-comp',
});
},
diff --git a/packages/cli/src/editor/components/UpdateCheck.tsx b/packages/cli/src/editor/components/UpdateCheck.tsx
index 6bbbfb65a2..aeac0f71c0 100644
--- a/packages/cli/src/editor/components/UpdateCheck.tsx
+++ b/packages/cli/src/editor/components/UpdateCheck.tsx
@@ -1,31 +1,6 @@
import React, {useCallback, useContext, useEffect, useState} from 'react';
-import styled from 'styled-components';
-import {copyCmd} from '../helpers/copy-text';
import {ModalsContext} from '../state/modals';
-export const Container = styled.div`
- background: linear-gradient(to right, #4290f5, #42e9f5);
- font-family: ---apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
- Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
- color: white;
- text-align: center;
- font-weight: bold;
- font-size: 14px;
- a {
- color: white;
- text-decoration: underline;
- cursor: pointer;
- }
- code {
- background-color: rgba(255, 255, 255, 0.3);
- border-radius: 4px;
- padding: 3px 8px;
- &:active {
- color: black;
- }
- }
-`;
-
type PackageManager = 'npm' | 'yarn' | 'unknown';
export type UpdateInfo = {
@@ -36,14 +11,13 @@ export type UpdateInfo = {
packageManager: PackageManager;
};
-const makeLocalStorageKey = (version: string) => `update-dismiss-${version}`;
-
-const dismissVersion = (version: string) => {
- window.localStorage.setItem(makeLocalStorageKey(version), 'true');
-};
-
-const isVersionDismissed = (version: string) => {
- return window.localStorage.getItem(makeLocalStorageKey(version)) === 'true';
+const buttonStyle: React.CSSProperties = {
+ appearance: 'none',
+ color: '#4290f5',
+ border: 'none',
+ fontWeight: 'bold',
+ backgroundColor: 'transparent',
+ cursor: 'pointer',
};
export const UpdateCheck = () => {
@@ -59,19 +33,6 @@ export const UpdateCheck = () => {
});
}, []);
- const dismiss = useCallback(() => {
- if (info === null) {
- return;
- }
-
- dismissVersion(info.latestVersion);
- setInfo(null);
- }, [info]);
-
- const remindLater = useCallback(() => {
- setInfo(null);
- }, []);
-
useEffect(() => {
checkForUpdates();
}, [checkForUpdates]);
@@ -91,43 +52,9 @@ export const UpdateCheck = () => {
return null;
}
- if (isVersionDismissed(info.latestVersion)) {
- return null;
- }
-
return (
- <Container>
- Update available! {info.currentVersion} ➡️{' '}
- <span style={{width: 8, display: 'inline-block'}} />
- {info.latestVersion}. Run{' '}
- {info.packageManager === 'yarn' ? (
- <code
- onClick={() => copyCmd('yarn upgrade')}
- style={{cursor: 'pointer'}}
- >
- yarn upgrade
- </code>
- ) : (
- <code
- onClick={() => copyCmd('npm run upgrade')}
- style={{cursor: 'pointer'}}
- >
- npm run upgrade
- </code>
- )}{' '}
- to get it. <br />
- <a
- href="https://github.com/remotion-dev/remotion/releases"
- target="_blank"
- >
- Release notes
- </a>
- <span style={{width: 8, display: 'inline-block'}} />
- <a onClick={remindLater}>Remind me next time</a>
- <span style={{width: 8, display: 'inline-block'}} />
- <a onClick={dismiss}>Skip this version</a>
- <span style={{width: 8, display: 'inline-block'}} />
- <a onClick={openModal}>Open modal</a>
- </Container>
+ <button style={buttonStyle} onClick={openModal} type="button">
+ Update available!
+ </button>
);
};
diff --git a/packages/cli/src/editor/components/UpdateModal/UpdateModal.tsx b/packages/cli/src/editor/components/UpdateModal/UpdateModal.tsx
index 91ad3237a3..0de1aff607 100644
--- a/packages/cli/src/editor/components/UpdateModal/UpdateModal.tsx
+++ b/packages/cli/src/editor/components/UpdateModal/UpdateModal.tsx
@@ -2,6 +2,8 @@ import React, {useCallback, useContext} from 'react';
import {SELECTED_BACKGROUND} from '../../helpers/colors';
import {copyCmd} from '../../helpers/copy-text';
import {ModalsContext} from '../../state/modals';
+import {CopyButton} from '../CopyButton';
+import {Flex, Row, Spacing} from '../layout';
import {ModalContainer} from '../ModalContainer';
import {NewCompHeader} from '../ModalHeader';
import {UpdateInfo} from '../UpdateCheck';
@@ -33,20 +35,28 @@ export const UpdateModal: React.FC<{
const onQuit = useCallback(() => {
setSelectedModal(null);
}, [setSelectedModal]);
+
+ const command =
+ info.packageManager === 'yarn' ? 'yarn upgrade' : 'npm run upgrade';
+
return (
<ModalContainer onOutsideClick={onQuit} onEscape={onQuit}>
<NewCompHeader title="Update available" />
<div style={container}>
<p>A new update to Remotion is available! Run the following command:</p>
- {info.packageManager === 'yarn' ? (
- <pre onClick={() => copyCmd('yarn upgrade')} style={code}>
- yarn upgrade
- </pre>
- ) : (
- <pre onClick={() => copyCmd('npm run upgrade')} style={code}>
- npm run upgrade
- </pre>
- )}{' '}
+ <Row align="center">
+ <Flex>
+ <pre onClick={() => copyCmd('yarn upgrade')} style={code}>
+ {command}
+ </pre>
+ </Flex>
+ <Spacing x={1} />
+ <CopyButton
+ textToCopy={command}
+ label="Copy command"
+ labelWhenCopied="Copied!"
+ />
+ </Row>
<p>
This will upgrade Remotion from {info.currentVersion} to{' '}
{info.latestVersion}.
diff --git a/packages/cli/src/editor/components/layout.tsx b/packages/cli/src/editor/components/layout.tsx
index b0f44b5b9a..686f56ad99 100644
--- a/packages/cli/src/editor/components/layout.tsx
+++ b/packages/cli/src/editor/components/layout.tsx
@@ -19,11 +19,23 @@ export const Spacing: React.FC<{
const flex: React.CSSProperties = {flex: 1};
-export const Flex = () => <div style={flex} />;
+export const Flex: React.FC = ({children}) => (
+ <div style={flex}>{children}</div>
+);
-const row: React.CSSProperties = {
- display: 'flex',
- flexDirection: 'row',
+export const Row: React.FC<{
+ justify?: 'center';
+ align?: 'center';
+ style?: React.CSSProperties;
+}> = ({children, justify, align, style = {}}) => {
+ const finalStyle: React.CSSProperties = useMemo(() => {
+ return {
+ ...style,
+ display: 'flex',
+ flexDirection: 'row',
+ justifyContent: justify ?? 'flex-start',
+ alignItems: align ?? 'flex-start',
+ };
+ }, [align, justify, style]);
+ return <div style={finalStyle}>{children}</div>;
};
-
-export const Row: React.FC = ({children}) => <div style={row}>{children}</div>;