Skip to content

🎥 Make videos programmatically with React

new code frame style

Jonny Burgera33ad919b084
diff --git a/packages/cli/src/preview-server/error-overlay/remotion-overlay/CodeFrame.tsx b/packages/cli/src/preview-server/error-overlay/remotion-overlay/CodeFrame.tsx
index 0550423da1..4fb6fbaa6b 100644
--- a/packages/cli/src/preview-server/error-overlay/remotion-overlay/CodeFrame.tsx
+++ b/packages/cli/src/preview-server/error-overlay/remotion-overlay/CodeFrame.tsx
@@ -1,20 +1,30 @@
import React from 'react';
import type {ScriptLine} from '../react-overlay/utils/stack-frame';
+const container: React.CSSProperties = {
+ display: 'flex',
+ flexDirection: 'row',
+};
+
const frame: React.CSSProperties = {
backgroundColor: '#070707',
marginBottom: 20,
+ overflowY: 'auto',
};
const lineNumber: React.CSSProperties = {
- display: 'inline-block',
whiteSpace: 'pre',
- backgroundColor: '#121212',
- paddingLeft: 10,
+ marginRight: 6,
paddingRight: 12,
- marginRight: 12,
color: 'inherit',
fontSize: 14,
+ lineHeight: 1.7,
+ width: 60,
+ flexShrink: 0,
+ display: 'inline-flex',
+ alignItems: 'center',
+ justifyContent: 'flex-end',
+ fontFamily: 'monospace',
};
export const CodeFrame: React.FC<{
@@ -29,14 +39,22 @@ export const CodeFrame: React.FC<{
// eslint-disable-next-line react/no-array-index-key
key={j}
style={{
+ ...container,
fontFamily: 'monospace',
whiteSpace: 'pre',
tabSize: 2,
color: s.highlight ? 'white' : 'rgba(255, 255, 255, 0.6)',
+ backgroundColor: s.highlight ? 'var(--blue)' : 'transparent',
lineHeight: 1.7,
}}
>
- <div style={lineNumber}>
+ <div
+ style={{
+ ...lineNumber,
+ backgroundColor: s.highlight ? 'white' : '#121212',
+ color: s.highlight ? 'black' : 'rgba(255, 255, 255, 0.6)',
+ }}
+ >
{String(s.lineNumber).padStart(lineNumberWidth, ' ')}
</div>
{s.content}
diff --git a/packages/cli/src/preview-server/error-overlay/remotion-overlay/ErrorTitle.tsx b/packages/cli/src/preview-server/error-overlay/remotion-overlay/ErrorTitle.tsx
index 70cfacfd4c..9762f6027d 100644
--- a/packages/cli/src/preview-server/error-overlay/remotion-overlay/ErrorTitle.tsx
+++ b/packages/cli/src/preview-server/error-overlay/remotion-overlay/ErrorTitle.tsx
@@ -20,7 +20,7 @@ const left: React.CSSProperties = {
const errName: React.CSSProperties = {
fontSize: 18,
- color: '#4290f5',
+ color: 'var(--blue)',
display: 'inline-block',
};
diff --git a/packages/core/src/Composition.tsx b/packages/core/src/Composition.tsx
index 5c0b33675c..cfb68c5f50 100644
--- a/packages/core/src/Composition.tsx
+++ b/packages/core/src/Composition.tsx
@@ -166,12 +166,11 @@ export const Composition = <Schema extends z.ZodTypeAny, Props>({
compProps.calculateMetadata,
]);
- if (resolved === null) {
- return <div style={{color: 'white'}}>Loading...</div>;
- }
-
if (environment === 'preview' && video && video.component === lazy) {
const Comp = lazy;
+ if (resolved === null) {
+ return <div style={{color: 'white'}}>Loading...</div>;
+ }
return createPortal(
<ClipComposition>
@@ -194,6 +193,10 @@ export const Composition = <Schema extends z.ZodTypeAny, Props>({
if (environment === 'rendering' && video && video.component === lazy) {
const Comp = lazy;
+ if (resolved === null) {
+ return <div style={{color: 'white'}}>Loading...</div>;
+ }
+
return createPortal(
<CanUseRemotionHooksProvider>
<Suspense fallback={<Fallback />}>
diff --git a/packages/core/src/resolve-video-config.ts b/packages/core/src/resolve-video-config.ts
index 6e2f66909e..e76edc49da 100644
--- a/packages/core/src/resolve-video-config.ts
+++ b/packages/core/src/resolve-video-config.ts
@@ -26,7 +26,7 @@ export const resolveVideoConfig = async ({
const width = calculated?.width ?? comp.width ?? null;
if (!width) {
throw new TypeError(
- 'Composition width was neither specified via the `width` prop nor the `calculateMetadata` function.'
+ 'Composition width was neither specified via the `width` prop nor the `calculateMetadata()` function.'
);
}
@@ -35,7 +35,7 @@ export const resolveVideoConfig = async ({
const height = calculated?.height ?? comp.height ?? null;
if (!height) {
throw new TypeError(
- 'Composition height was neither specified via the `height` prop nor the `calculateMetadata` function.'
+ 'Composition height was neither specified via the `height` prop nor the `calculateMetadata()` function.'
);
}
@@ -44,7 +44,7 @@ export const resolveVideoConfig = async ({
const fps = calculated?.fps ?? comp.fps ?? null;
if (!fps) {
throw new TypeError(
- 'Composition fps was neither specified via the `fps` prop nor the `calculateMetadata` function.'
+ 'Composition fps was neither specified via the `fps` prop nor the `calculateMetadata()` function.'
);
}
@@ -52,7 +52,7 @@ export const resolveVideoConfig = async ({
calculated?.durationInFrames ?? comp.durationInFrames ?? null;
if (!durationInFrames) {
throw new TypeError(
- 'Composition durationInFrames was neither specified via the `durationInFrames` prop nor the `calculateMetadata` function.'
+ 'Composition durationInFrames was neither specified via the `durationInFrames` prop nor the `calculateMetadata()` function.'
);
}