Skip to content

🎥 Make videos programmatically with React

better loading indiciator

Jonny Burger6ac09701ebab
diff --git a/packages/cli/src/editor/components/LoadingIndicator.tsx b/packages/cli/src/editor/components/LoadingIndicator.tsx
new file mode 100644
index 0000000000..2179087532
--- /dev/null
+++ b/packages/cli/src/editor/components/LoadingIndicator.tsx
@@ -0,0 +1,55 @@
+import React from 'react';
+import {AbsoluteFill} from 'remotion';
+import {FONT_FAMILY} from '../helpers/font';
+
+const rotate: React.CSSProperties = {
+ transform: `rotate(90deg)`,
+};
+const ICON_SIZE = 40;
+
+const label: React.CSSProperties = {
+ fontFamily: FONT_FAMILY,
+ color: '#555',
+ fontSize: 14,
+};
+
+const container: React.CSSProperties = {
+ justifyContent: 'center',
+ alignItems: 'center',
+};
+
+export const Loading: React.FC = () => {
+ return (
+ <AbsoluteFill style={container} id="remotion-comp-loading">
+ <style type="text/css">{`
+ @keyframes anim {
+ from {
+ opacity: 0
+ }
+ to {
+ opacity: 1
+ }
+ }
+ #remotion-comp-loading {
+ animation: anim 2s;
+ animation-fill-mode: forwards;
+ }
+ `}</style>
+ <svg
+ width={ICON_SIZE}
+ height={ICON_SIZE}
+ viewBox="-100 -100 400 400"
+ style={rotate}
+ >
+ <path
+ fill="#555"
+ stroke="#555"
+ strokeWidth="100"
+ strokeLinejoin="round"
+ d="M 2 172 a 196 100 0 0 0 195 5 A 196 240 0 0 0 100 2.259 A 196 240 0 0 0 2 172 z"
+ />
+ </svg>
+ <p style={label}>Loading...</p>
+ </AbsoluteFill>
+ );
+};
diff --git a/packages/cli/src/editor/components/Preview.tsx b/packages/cli/src/editor/components/Preview.tsx
index c01185d4a2..d64ff7b2a7 100644
--- a/packages/cli/src/editor/components/Preview.tsx
+++ b/packages/cli/src/editor/components/Preview.tsx
@@ -9,6 +9,7 @@ import {
} from '../helpers/checkerboard-background';
import {CheckerboardContext} from '../state/checkerboard';
import {PreviewSizeContext} from '../state/preview-size';
+import {Loading} from './LoadingIndicator';
const checkerboardSize = 49;
@@ -96,7 +97,7 @@ const Inner: React.FC<{
const inputProps = getInputProps();
return (
- <Suspense fallback={<div>loading...</div>}>
+ <Suspense fallback={<Loading />}>
<div style={outer}>
<div style={style}>
{Component ? (