Skip to content

🎥 Make videos programmatically with React

add a spinner!

Jonny Burgerd29e4dc4a306
diff --git a/packages/cli/src/editor/components/MenuBuildIndicator.tsx b/packages/cli/src/editor/components/MenuBuildIndicator.tsx
index 74bfa7fd90..e622184c19 100644
--- a/packages/cli/src/editor/components/MenuBuildIndicator.tsx
+++ b/packages/cli/src/editor/components/MenuBuildIndicator.tsx
@@ -2,12 +2,27 @@ import React, {useContext, useEffect, useState} from 'react';
import {PreviewServerConnectionCtx} from '../helpers/client-id';
import {Spacing} from './layout';
import {OpenEditorButton} from './OpenEditorButton';
+import {Spinner} from './Spinner';
const cwd: React.CSSProperties = {
fontSize: 13,
opacity: 0.8,
display: 'flex',
alignItems: 'center',
+ justifyContent: 'center',
+};
+
+const spinnerSize = 14;
+
+const spinner: React.CSSProperties = {
+ position: 'relative',
+ width: spinnerSize,
+ marginTop: 4,
+};
+
+const noSpinner: React.CSSProperties = {
+ position: 'relative',
+ width: spinnerSize,
};
export const MenuBuildIndicator: React.FC = () => {
@@ -32,8 +47,16 @@ export const MenuBuildIndicator: React.FC = () => {
return (
<div style={cwd} title={window.remotion_cwd}>
- {showButton ? <Spacing x={5} /> : null}
- {isBuilding ? 'Building...' : window.remotion_projectName}
+ {showButton ? <Spacing x={2} /> : null}
+ {isBuilding ? (
+ <div style={spinner}>
+ <Spinner size={spinnerSize} />
+ </div>
+ ) : (
+ <div style={noSpinner} />
+ )}
+ {showButton ? <Spacing x={0.5} /> : null}
+ {window.remotion_projectName}
{showButton ? <OpenEditorButton /> : null}
</div>
);
diff --git a/packages/cli/src/editor/components/Spinner.tsx b/packages/cli/src/editor/components/Spinner.tsx
new file mode 100644
index 0000000000..7e52824eb1
--- /dev/null
+++ b/packages/cli/src/editor/components/Spinner.tsx
@@ -0,0 +1,62 @@
+import React, {useMemo} from 'react';
+import {LIGHT_TEXT} from '../helpers/colors';
+
+const viewBox = 100;
+const lines = 6;
+const className = '__remotion_spinner_line';
+const remotionSpinnerAnimation = '__remotion_spinner_animation';
+
+// Generated from https://github.com/remotion-dev/template-next/commit/9282c93f7c51ada31a42e18a94680fa09a14eee3
+const translated =
+ 'M 44 0 L 50 0 a 6 6 0 0 1 6 6 L 56 26 a 6 6 0 0 1 -6 6 L 50 32 a 6 6 0 0 1 -6 -6 L 44 6 a 6 6 0 0 1 6 -6 Z';
+
+const totalDuration = 0.5;
+export const Spinner: React.FC<{
+ size: number;
+}> = ({size}) => {
+ const style = useMemo(() => {
+ return {
+ width: size,
+ height: size,
+ };
+ }, [size]);
+
+ return (
+ <>
+ <style type="text/css">{`
+ @keyframes ${remotionSpinnerAnimation} {
+ 0% {
+ opacity: 1;
+ }
+ 100% {
+ opacity: 0.15;
+ }
+ }
+
+ .${className} {
+ animation: ${remotionSpinnerAnimation} ${totalDuration}s linear infinite;
+ }
+ `}</style>
+ <svg style={style} viewBox={`0 0 ${viewBox} ${viewBox}`}>
+ {new Array(lines).fill(true).map((_, index) => {
+ return (
+ <path
+ // eslint-disable-next-line react/no-array-index-key
+ key={index}
+ className={className}
+ style={{
+ rotate: `${(index * Math.PI * 2) / lines}rad`,
+ transformOrigin: 'center center',
+ animationDelay: `${
+ index * (totalDuration / lines) - totalDuration
+ }s`,
+ }}
+ d={translated}
+ fill={LIGHT_TEXT}
+ />
+ );
+ })}
+ </svg>
+ </>
+ );
+};