Skip to content

🎥 Make videos programmatically with React

enable strict mode for docs

Jonny Burgerf7931df76427
diff --git a/packages/docs/components/DocsDark.tsx b/packages/docs/components/DocsDark.tsx
index feb288584c..9c1f03d952 100644
--- a/packages/docs/components/DocsDark.tsx
+++ b/packages/docs/components/DocsDark.tsx
@@ -35,10 +35,10 @@ export const SingleVideoDemo: React.FC<{
}, [colorMode]);
useEffect(() => {
- ref1.current.addEventListener(
+ ref1.current?.addEventListener(
'canplay',
() => {
- ref1.current.play();
+ ref1.current?.play();
},
{
once: true,
@@ -80,7 +80,7 @@ export const DualVideoDemo: React.FC<{
shouldApplyCssTransforms: true,
});
- const mobile = size?.width < 700;
+ const mobile = (size?.width ?? 0) < 700;
const style: React.CSSProperties = useMemo(
() => ({
@@ -107,20 +107,20 @@ export const DualVideoDemo: React.FC<{
}, [colorMode, mobile]);
const playAll = useCallback(() => {
- ref1.current.play();
- ref2.current.play();
+ ref1.current?.play();
+ ref2.current?.play();
setPlayed(true);
}, []);
useEffect(() => {
Promise.all([
new Promise<void>((resolve) => {
- ref1.current.addEventListener('canplay', () => resolve(), {
+ ref1.current?.addEventListener('canplay', () => resolve(), {
once: true,
});
}),
new Promise<void>((resolve) => {
- ref2.current.addEventListener('canplay', () => resolve(), {
+ ref2.current?.addEventListener('canplay', () => resolve(), {
once: true,
});
}),
diff --git a/packages/docs/components/InlineStep.tsx b/packages/docs/components/InlineStep.tsx
index 088458c4b9..c9ba5385f8 100644
--- a/packages/docs/components/InlineStep.tsx
+++ b/packages/docs/components/InlineStep.tsx
@@ -2,79 +2,79 @@ import React from 'react';
import {RED} from './layout/colors';
export const TitleStep: React.FC<{
- readonly children: React.ReactNode;
- readonly error?: boolean;
+ readonly children: React.ReactNode;
+ readonly error?: boolean;
}> = ({children, error}) => {
- return (
- <div
- style={{
- backgroundColor: error ? RED : 'var(--ifm-color-primary)',
- height: '1em',
- width: '1em',
- borderRadius: '50%',
- padding: 6,
- fontSize: '0.7em',
- lineHeight: '1',
- display: 'inline-flex',
- color: 'white',
- justifyContent: 'center',
- alignItems: 'center',
- fontWeight: 'bold',
- fontFeatureSettings: '"ss03" on',
- boxSizing: 'content-box',
- marginRight: 8,
- }}
- >
- {children}
- </div>
- );
+ return (
+ <div
+ style={{
+ backgroundColor: error ? RED : 'var(--ifm-color-primary)',
+ height: '1em',
+ width: '1em',
+ borderRadius: '50%',
+ padding: 6,
+ fontSize: '0.7em',
+ lineHeight: '1',
+ display: 'inline-flex',
+ color: 'white',
+ justifyContent: 'center',
+ alignItems: 'center',
+ fontWeight: 'bold',
+ fontFeatureSettings: '"ss03" on',
+ boxSizing: 'content-box',
+ marginRight: 8,
+ }}
+ >
+ {children}
+ </div>
+ );
};
export const InlineStep: React.FC<{
- readonly children: React.ReactNode;
- readonly error?: boolean;
+ readonly children: React.ReactNode;
+ readonly error?: boolean;
}> = ({children, error}) => {
- return (
- <div
- style={{
- backgroundColor: error ? RED : 'var(--ifm-color-primary)',
- height: 24,
- width: 24,
- display: 'inline-flex',
- color: 'white',
- justifyContent: 'center',
- alignItems: 'center',
- borderRadius: 12,
- fontSize: 13,
- fontWeight: 'bold',
- verticalAlign: 'top',
- fontFeatureSettings: '"ss03" on',
- }}
- >
- {children}
- </div>
- );
+ return (
+ <div
+ style={{
+ backgroundColor: error ? RED : 'var(--ifm-color-primary)',
+ height: 24,
+ width: 24,
+ display: 'inline-flex',
+ color: 'white',
+ justifyContent: 'center',
+ alignItems: 'center',
+ borderRadius: 12,
+ fontSize: 13,
+ fontWeight: 'bold',
+ verticalAlign: 'top',
+ fontFeatureSettings: '"ss03" on',
+ }}
+ >
+ {children}
+ </div>
+ );
};
export const Step: React.FC<{
- readonly children: React.ReactNode;
- readonly error?: boolean;
+ readonly children: React.ReactNode;
+ readonly error?: boolean;
}> = ({children, error}) => {
- return (
- <a
- id={children.toString()}
- style={{
- marginRight: 7,
- display: 'inline-block',
- position: 'relative',
- marginTop: 4,
- marginBottom: 4,
- cursor: 'pointer',
- textDecoration: 'none',
- }}
- href={`#${children.toString()}`}
- >
- <InlineStep error={error}>{children}</InlineStep>{' '}
- </a>
- );
+ return (
+ <a
+ id={children!.toString()}
+ style={{
+ marginRight: 7,
+ display: 'inline-block',
+ position: 'relative',
+ marginTop: 4,
+ marginBottom: 4,
+ cursor: 'pointer',
+ textDecoration: 'none',
+ }}
+ href={`#${children!.toString()}`}
+ >
+ <InlineStep error={error}>{children}</InlineStep>{' '}
+ </a>
+ );
};
diff --git a/packages/docs/components/LandingPage/EvaluateRemotionSection.tsx b/packages/docs/components/LandingPage/EvaluateRemotionSection.tsx
index 4c5bf0f7be..542d7c2e6b 100644
--- a/packages/docs/components/LandingPage/EvaluateRemotionSection.tsx
+++ b/packages/docs/components/LandingPage/EvaluateRemotionSection.tsx
@@ -29,7 +29,7 @@ const EvaluateRemotionSection: React.FC = () => {
// Add more avatar paths here
];
- const selectedAvatars = [];
+ const selectedAvatars: string[] = [];
for (let i = 0; i < 3; i++) {
const index = Math.floor(Math.random() * avatars.length);
selectedAvatars.push(avatars[index]);
diff --git a/packages/docs/components/TableOfContents/transitions/presentations.tsx b/packages/docs/components/TableOfContents/transitions/presentations.tsx
index 8ee7430425..760acecd46 100644
--- a/packages/docs/components/TableOfContents/transitions/presentations.tsx
+++ b/packages/docs/components/TableOfContents/transitions/presentations.tsx
@@ -85,6 +85,8 @@ export const Presentations: React.FC<{
<div style={row}>
<PresentationPreview
durationRestThreshold={0.001}
+ // @ts-expect-error
+
effect={clockWipe({
width: presentationCompositionWidth,
height: presentationCompositionHeight,
@@ -102,7 +104,7 @@ export const Presentations: React.FC<{
<TOCItem link="/docs/transitions/presentations/cube">
<div style={row}>
<PresentationPreview
- durationRestThreshold={0.001}
+ durationRestThreshold={0.001} // @ts-expect-error
effect={cube({
direction: 'from-left',
})}
diff --git a/packages/docs/components/TextInput.tsx b/packages/docs/components/TextInput.tsx
index 4037d7dc9b..9dcff7a86c 100644
--- a/packages/docs/components/TextInput.tsx
+++ b/packages/docs/components/TextInput.tsx
@@ -1,62 +1,62 @@
-import type { DetailedHTMLProps } from "react";
-import React, { useCallback, useState } from "react";
+import type {DetailedHTMLProps} from 'react';
+import React, {useCallback, useState} from 'react';
const inputStyle: React.CSSProperties = {
- padding: 16,
- border: "none",
- outline: "none",
- borderRadius: 4,
- minWidth: 35,
- fontSize: 16,
- background: "var(--background)",
+ padding: 16,
+ border: 'none',
+ outline: 'none',
+ borderRadius: 4,
+ minWidth: 35,
+ fontSize: 16,
+ background: 'var(--background)',
};
const backgroundStyle = (
- focused: boolean,
- fullWidth: boolean,
+ focused: boolean,
+ fullWidth: boolean,
): React.CSSProperties => {
- return {
- padding: 2,
- background: focused
- ? "var(--ifm-color-primary)"
- : "var(--ifm-font-color-base)",
- display: fullWidth ? "block" : "inline-block",
- transition: "0.2s background-color",
- borderRadius: 7,
- overflow: "hidden",
- width: fullWidth ? "100%" : undefined,
- };
+ return {
+ padding: 2,
+ background: focused
+ ? 'var(--ifm-color-primary)'
+ : 'var(--ifm-font-color-base)',
+ display: fullWidth ? 'block' : 'inline-block',
+ transition: '0.2s background-color',
+ borderRadius: 7,
+ overflow: 'hidden',
+ width: fullWidth ? '100%' : undefined,
+ };
};
type Props = Omit<
- DetailedHTMLProps<
- React.InputHTMLAttributes<HTMLInputElement>,
- HTMLInputElement
- >,
- "onFocus" | "onBlur"
+ DetailedHTMLProps<
+ React.InputHTMLAttributes<HTMLInputElement>,
+ HTMLInputElement
+ >,
+ 'onFocus' | 'onBlur'
> & {
- fullWidth?: boolean;
+ fullWidth?: boolean;
};
-export const CoolInput: React.FC<Props> = ({ style, fullWidth, ...props }) => {
- const [focus, setFocused] = useState(false);
+export const CoolInput: React.FC<Props> = ({style, fullWidth, ...props}) => {
+ const [focus, setFocused] = useState(false);
- const onFocus = useCallback(() => {
- setFocused(true);
- }, [setFocused]);
+ const onFocus = useCallback(() => {
+ setFocused(true);
+ }, [setFocused]);
- const onBlur = useCallback(() => {
- setFocused(false);
- }, [setFocused]);
+ const onBlur = useCallback(() => {
+ setFocused(false);
+ }, [setFocused]);
- return (
- <div style={backgroundStyle(focus, fullWidth)}>
- <input
- style={{ ...inputStyle, ...style }}
- {...props}
- onFocus={onFocus}
- onBlur={onBlur}
- />
- </div>
- );
+ return (
+ <div style={backgroundStyle(focus, fullWidth!)}>
+ <input
+ style={{...inputStyle, ...style}}
+ {...props}
+ onFocus={onFocus}
+ onBlur={onBlur}
+ />
+ </div>
+ );
};
diff --git a/packages/docs/components/demos/control.tsx b/packages/docs/components/demos/control.tsx
index dc737407aa..ee262d2198 100644
--- a/packages/docs/components/demos/control.tsx
+++ b/packages/docs/components/demos/control.tsx
@@ -1,113 +1,113 @@
-import React, { useMemo } from "react";
-import styles from "./styles.module.css";
-import type { Option } from "./types";
+import React, {useMemo} from 'react';
+import styles from './styles.module.css';
+import type {Option} from './types';
const left: React.CSSProperties = {
- fontFamily: "GTPlanar",
- flex: 1,
- flexDirection: "row",
- display: "flex",
- alignItems: "center",
+ fontFamily: 'GTPlanar',
+ flex: 1,
+ flexDirection: 'row',
+ display: 'flex',
+ alignItems: 'center',
};
const check: React.CSSProperties = {
- marginRight: 4,
+ marginRight: 4,
};
const right: React.CSSProperties = {
- width: 45,
- textAlign: "right",
- fontVariantNumeric: "tabular-nums",
+ width: 45,
+ textAlign: 'right',
+ fontVariantNumeric: 'tabular-nums',
};
export const Control = ({
- option,
- value,
- setValue,
+ option,
+ value,
+ setValue,
}: {
- option: Option;
- value: number | string | boolean;
- setValue: (value: number | string | boolean) => void;
+ option: Option;
+ value: number | string | boolean;
+ setValue: (value: number | string | boolean | null) => void;
}) => {
- const enabled = value !== null;
+ const enabled = value !== null;
- const labelStyle = useMemo<React.CSSProperties>(
- () => ({
- display: "flex",
- flexDirection: "row",
- alignItems: "center",
- }),
- [],
- );
+ const labelStyle = useMemo<React.CSSProperties>(
+ () => ({
+ display: 'flex',
+ flexDirection: 'row',
+ alignItems: 'center',
+ }),
+ [],
+ );
- const inputStyle = useMemo<React.CSSProperties>(
- () => ({
- width: 80,
- marginRight: 2,
- }),
- [],
- );
+ const inputStyle = useMemo<React.CSSProperties>(
+ () => ({
+ width: 80,
+ marginRight: 2,
+ }),
+ [],
+ );
- return (
- <label style={labelStyle} className={styles.item}>
- <div style={left}>
- {option.optional === "no" ? null : (
- <input
- onChange={(c) => {
- if (c.target.checked) {
- setValue(option.default);
- } else {
- setValue(null);
- }
- }}
- style={check}
- checked={enabled}
- type={"checkbox"}
- />
- )}
- {`${option.name}`}
- </div>
- {option.type === "numeric" && enabled ? (
- <input
- type="range"
- min={option.min}
- max={option.max}
- step={option.step}
- value={value as number}
- style={inputStyle}
- onChange={(e) => setValue(Number(e.target.value))}
- />
- ) : null}
- {option.type === "numeric" ? (
- <div style={right}>
- <code>{value}</code>
- </div>
- ) : option.type === "enum" ? (
- <div>
- <select
- onChange={(e) => {
- setValue(e.target.value);
- }}
- >
- {option.values.map((v) => {
- return (
- <option key={v} selected={value === v}>
- {v}
- </option>
- );
- })}
- </select>
- </div>
- ) : option.type === "boolean" ? (
- <input
- onChange={(c) => {
- setValue(c.target.checked);
- }}
- style={check}
- checked={value as boolean}
- type={"checkbox"}
- />
- ) : null}
- </label>
- );
+ return (
+ <label style={labelStyle} className={styles.item}>
+ <div style={left}>
+ {option.optional === 'no' ? null : (
+ <input
+ onChange={(c) => {
+ if (c.target.checked) {
+ setValue(option.default);
+ } else {
+ setValue(null);
+ }
+ }}
+ style={check}
+ checked={enabled}
+ type={'checkbox'}
+ />
+ )}
+ {`${option.name}`}
+ </div>
+ {option.type === 'numeric' && enabled ? (
+ <input
+ type="range"
+ min={option.min}
+ max={option.max}
+ step={option.step}
+ value={value as number}
+ style={inputStyle}
+ onChange={(e) => setValue(Number(e.target.value))}
+ />
+ ) : null}
+ {option.type === 'numeric' ? (
+ <div style={right}>
+ <code>{value}</code>
+ </div>
+ ) : option.type === 'enum' ? (
+ <div>
+ <select
+ onChange={(e) => {
+ setValue(e.target.value);
+ }}
+ >
+ {option.values.map((v) => {
+ return (
+ <option key={v} selected={value === v}>
+ {v}
+ </option>
+ );
+ })}
+ </select>
+ </div>
+ ) : option.type === 'boolean' ? (
+ <input
+ onChange={(c) => {
+ setValue(c.target.checked);
+ }}
+ style={check}
+ checked={value as boolean}
+ type={'checkbox'}
+ />
+ ) : null}
+ </label>
+ );
};
diff --git a/packages/docs/components/demos/index.tsx b/packages/docs/components/demos/index.tsx
index 52c8309f6b..6737bb717a 100644
--- a/packages/docs/components/demos/index.tsx
+++ b/packages/docs/components/demos/index.tsx
@@ -1,169 +1,173 @@
-import { useColorMode } from "@docusaurus/theme-common";
-import { Player } from "@remotion/player";
-import React, { useCallback, useMemo, useState } from "react";
-import { AbsoluteFill } from "remotion";
-import { Control } from "./control";
-import styles from "./styles.module.css";
-import type { DemoType } from "./types";
+import {useColorMode} from '@docusaurus/theme-common';
+import {Player} from '@remotion/player';
+import React, {useCallback, useMemo, useState} from 'react';
+import {AbsoluteFill} from 'remotion';
+import {Control} from './control';
+import styles from './styles.module.css';
+import type {DemoType} from './types';
import {
- animationMathDemo,
- circleDemo,
- clockWipePresentationDemo,
- cubePresentationDemo,
- customPresentationDemo,
- customTimingDemo,
- ellipseDemo,
- fadePresentationDemo,
- flipPresentationDemo,
- noiseDemo,
- nonePresentationDemo,
- opacityDemo,
- pieDemo,
- polygonDemo,
- rectDemo,
- rotateDemo,
- scaleDemo,
- skewDemo,
- slidePresentationDemo,
- slidePresentationDemoLongThreshold,
- starDemo,
- translateDemo,
- triangleDemo,
- wipePresentationDemo,
-} from "./types";
+ animationMathDemo,
+ circleDemo,
+ clockWipePresentationDemo,
+ cubePresentationDemo,
+ customPresentationDemo,
+ customTimingDemo,
+ ellipseDemo,
+ fadePresentationDemo,
+ flipPresentationDemo,
+ noiseDemo,
+ nonePresentationDemo,
+ opacityDemo,
+ pieDemo,
+ polygonDemo,
+ rectDemo,
+ rotateDemo,
+ scaleDemo,
+ skewDemo,
+ slidePresentationDemo,
+ slidePresentationDemoLongThreshold,
+ starDemo,
+ translateDemo,
+ triangleDemo,
+ wipePresentationDemo,
+} from './types';
const container: React.CSSProperties = {
- overflow: "hidden",
- width: "100%",
- border: "1px solid var(--ifm-color-emphasis-300)",
- borderRadius: "var(--ifm-pre-border-radius)",
- marginBottom: 40,
+ overflow: 'hidden',
+ width: '100%',
+ border: '1px solid var(--ifm-color-emphasis-300)',
+ borderRadius: 'var(--ifm-pre-border-radius)',
+ marginBottom: 40,
};
const demos: DemoType[] = [
- noiseDemo,
- triangleDemo,
- rectDemo,
- circleDemo,
- ellipseDemo,
- starDemo,
- polygonDemo,
- pieDemo,
- translateDemo,
- skewDemo,
- rotateDemo,
- scaleDemo,
- opacityDemo,
- fadePresentationDemo,
- wipePresentationDemo,
- slidePresentationDemo,
- slidePresentationDemoLongThreshold,
- flipPresentationDemo,
- nonePresentationDemo,
- customPresentationDemo,
- customTimingDemo,
- clockWipePresentationDemo,
- cubePresentationDemo,
- animationMathDemo,
+ noiseDemo,
+ triangleDemo,
+ rectDemo,
+ circleDemo,
+ ellipseDemo,
+ starDemo,
+ polygonDemo,
+ pieDemo,
+ translateDemo,
+ skewDemo,
+ rotateDemo,
+ scaleDemo,
+ opacityDemo,
+ fadePresentationDemo,
+ wipePresentationDemo,
+ slidePresentationDemo,
+ slidePresentationDemoLongThreshold,
+ flipPresentationDemo,
+ nonePresentationDemo,
+ customPresentationDemo,
+ customTimingDemo,
+ clockWipePresentationDemo,
+ cubePresentationDemo,
+ animationMathDemo,
];
export const Demo: React.FC<{
- readonly type: string;
-}> = ({ type }) => {
- const demo = demos.find((d) => d.id === type);
- const { colorMode } = useColorMode();
+ readonly type: string;
+}> = ({type}) => {
+ const demo = demos.find((d) => d.id === type);
+ if (!demo) {
+ throw new Error('no demo');
+ }
- const [key, setKey] = useState(() => 0);
+ const {colorMode} = useColorMode();
- const initialState = useMemo(() => {
- return demo.options
- .map(
- (o) =>
- [
- o.name,
- o.optional === "default-disabled" ? null : o.default,
- ] as const,
- )
- .reduce((a, b) => {
- a[b[0]] = b[1];
- return a;
- }, {});
- }, [demo.options]);
+ const [key, setKey] = useState(() => 0);
- const [state, setState] = useState(() => initialState);
+ const initialState = useMemo(() => {
+ return demo.options
+ .map(
+ (o) =>
+ [
+ o.name,
+ o.optional === 'default-disabled' ? null : o.default,
+ ] as const,
+ )
+ .reduce((a, b) => {
+ a[b[0]] = b[1];
+ return a;
+ }, {});
+ }, [demo.options]);
- const restart = useCallback(() => {
- setState(initialState);
- setKey((k) => k + 1);
- }, [initialState]);
+ const [state, setState] = useState(() => initialState);
- if (!demo) {
- throw new Error("Demo not found");
- }
+ const restart = useCallback(() => {
+ setState(initialState);
+ setKey((k) => k + 1);
+ }, [initialState]);
- return (
- <div style={container}>
- <Player
- key={key}
- component={demo.comp}
- compositionWidth={demo.compWidth}
- compositionHeight={demo.compHeight}
- durationInFrames={demo.durationInFrames}
- fps={demo.fps}
- style={{
- width: "100%",
- aspectRatio: demo.compWidth / demo.compHeight,
- borderBottom:
- demo.options.length > 0
- ? "1px solid var(--ifm-color-emphasis-300)"
- : 0,
- }}
- errorFallback={({ error }) => {
- return (
- <AbsoluteFill
- style={{
- justifyContent: "center",
- alignItems: "center",
- fontSize: 30,
- textAlign: "center",
- lineHeight: 1.5,
- }}
- >
- {error.message}
- <br />
- <button
- style={{
- fontSize: 30,
- }}
- onClick={restart}
- type="button"
- >
- Restart
- </button>
- </AbsoluteFill>
- );
- }}
- inputProps={{ ...state, darkMode: colorMode === "dark" }}
- autoPlay={demo.autoPlay}
- loop
- />
- <div className={styles.containerrow}>
- {demo.options.map((option) => {
- return (
- <Control
- key={option.name}
- option={option}
- value={state[option.name]}
- setValue={(value) => {
- setState((s) => ({
- ...s,
- [option.name]: value,
- }));
- }}
- />
- );
- })}
- </div>
- </div>
- );
+ if (!demo) {
+ throw new Error('Demo not found');
+ }
+
+ return (
+ <div style={container}>
+ <Player
+ key={key}
+ component={demo.comp}
+ compositionWidth={demo.compWidth}
+ compositionHeight={demo.compHeight}
+ durationInFrames={demo.durationInFrames}
+ fps={demo.fps}
+ style={{
+ width: '100%',
+ aspectRatio: demo.compWidth / demo.compHeight,
+ borderBottom:
+ demo.options.length > 0
+ ? '1px solid var(--ifm-color-emphasis-300)'
+ : 0,
+ }}
+ errorFallback={({error}) => {
+ return (
+ <AbsoluteFill
+ style={{
+ justifyContent: 'center',
+ alignItems: 'center',
+ fontSize: 30,
+ textAlign: 'center',
+ lineHeight: 1.5,
+ }}
+ >
+ {error.message}
+ <br />
+ <button
+ style={{
+ fontSize: 30,
+ }}
+ onClick={restart}
+ type="button"
+ >
+ Restart
+ </button>
+ </AbsoluteFill>
+ );
+ }}
+ inputProps={{...state, darkMode: colorMode === 'dark'}}
+ autoPlay={demo.autoPlay}
+ loop
+ />
+ <div className={styles.containerrow}>
+ {demo.options.map((option) => {
+ return (
+ <Control
+ key={option.name}
+ option={option}
+ value={state[option.name]}
+ setValue={(value) => {
+ setState((s) => ({
+ ...s,
+ [option.name]: value,
+ }));
+ }}
+ />
+ );
+ })}
+ </div>
+ </div>
+ );
};
diff --git a/packages/docs/components/shapes/shapes-info.tsx b/packages/docs/components/shapes/shapes-info.tsx
index 2c36ea7a0c..d20a41f1a2 100644
--- a/packages/docs/components/shapes/shapes-info.tsx
+++ b/packages/docs/components/shapes/shapes-info.tsx
@@ -1,440 +1,456 @@
import {
- makeCircle,
- makeEllipse,
- makePie,
- makePolygon,
- makeRect,
- makeStar,
- makeTriangle,
-} from "@remotion/shapes";
-import React from "react";
+ makeCircle,
+ makeEllipse,
+ makePie,
+ makePolygon,
+ makeRect,
+ makeStar,
+ makeTriangle,
+} from '@remotion/shapes';
+import React from 'react';
import {
- DebugOption,
- RectEdgeRoundness,
- TriangleEdgeRoundness,
-} from "./edge-roundness";
+ DebugOption,
+ RectEdgeRoundness,
+ TriangleEdgeRoundness,
+} from './edge-roundness';
type Param = {
- name: string;
- type: string;
- description: React.ReactNode;
+ name: string;
+ type: string;
+ description: React.ReactNode;
};
export type ShapeComponent = {
- shape: string;
- fn: (options: unknown) => unknown;
- params: Param[];
+ shape: string;
+ fn: (options: unknown) => unknown;
+ params: Param[];
};
export const shapeComponents: ShapeComponent[] = [
- {
- shape: "Rect",
- fn: makeRect,
- params: [
- {
- name: "width",
- type: "number",
- description: "The width of the rectangle.",
- },
- {
- name: "height",
- type: "number",
- description: "The height of the rectangle.",
- },
- ],
- },
- {
- shape: "Circle",
- fn: makeCircle,
- params: [
- {
- name: "radius",
- type: "number",
- description: "The radius of the circle.",
- },
- ],
- },
- {
- shape: "Pie",
- fn: makePie,
- params: [
- {
- name: "radius",
- type: "number",
- description: "The radius of the circle.",
- },
- {
- name: "progress",
- type: "number",
- description: (
- <>
- The percentage of the circle that is filled. <code>0</code> means
- fully empty, <code>1</code> means fully filled.
- </>
- ),
- },
- {
- name: "counterClockwise",
- type: "boolean",
- description:
- "If set, the circle gets filled counterclockwise instead of clockwise. Default false.",
- },
- {
- name: "closePath",
- type: "boolean",
- description: (
- <>
- If set to <code>false</code>, no path to the middle of the circle
- will be drawn, leading to an open arc. Default <code>true</code>.
- </>
- ),
- },
- {
- name: "rotation",
- type: "boolean",
- description: (
- <>
- Add rotation to the path. <code>0</code> means no rotation,{" "}
- <code>Math.PI * 2</code> means 1 full clockwise rotation{" "}
- </>
- ),
- },
- ],
- },
- {
- shape: "Ellipse",
- fn: makeEllipse,
- params: [
- {
- name: "rx",
- type: "number",
- description: "The radius of the ellipse on the X axis.",
- },
- {
- name: "ry",
- type: "number",
- description: "The radius of the ellipse on the Y axis.",
- },
- ],
- },
- {
- shape: "Triangle",
- fn: makeTriangle,
- params: [
- {
- name: "length",
- type: "number",
- description: "The length of one triangle side.",
- },
- {
- name: "direction",
- type: '"left" | "right" | "up" | "down"',
- description: "The direction of the triangle.",
- },
- ],
- },
- {
- shape: "Star",
- fn: makeStar,
- params: [
- {
- name: "points",
- type: "number",
- description: "The amount of points of the star.",
- },
- {
- name: "innerRadius",
- type: "number",
- description: "The inner radius of the star.",
- },
- {
- name: "outerRadius",
- type: "number",
- description: "The outer radius of the star.",
- },
- ],
- },
- {
- shape: "Polygon",
- fn: makePolygon,
- params: [
- {
- name: "points",
- type: "number",
- description: "The number of points in the polygon.",
- },
- {
- name: "radius",
- type: "number",
- description: "The radius of the polygon.",
- },
- {
- name: "edgeRoundness",
- type: "number | null",
- description:
- "Allows to modify the shape by rounding the edges using bezier curves. Default null.",
- },
- {
- name: "cornerRadius",
- type: "number",
- description:
- "Rounds the corner using an arc. Similar to CSS's border-radius. Cannot be used together with edgeRoundness.",
- },
- ],
- },
+ {
+ shape: 'Rect',
+ fn: makeRect,
+ params: [
+ {
+ name: 'width',
+ type: 'number',
+ description: 'The width of the rectangle.',
+ },
+ {
+ name: 'height',
+ type: 'number',
+ description: 'The height of the rectangle.',
+ },
+ ],
+ },
+ {
+ shape: 'Circle',
+ fn: makeCircle,
+ params: [
+ {
+ name: 'radius',
+ type: 'number',
+ description: 'The radius of the circle.',
+ },
+ ],
+ },
+ {
+ shape: 'Pie',
+ fn: makePie,
+ params: [
+ {
+ name: 'radius',
+ type: 'number',
+ description: 'The radius of the circle.',
+ },
+ {
+ name: 'progress',
+ type: 'number',
+ description: (
+ <>
+ The percentage of the circle that is filled. <code>0</code> means
+ fully empty, <code>1</code> means fully filled.
+ </>
+ ),
+ },
+ {
+ name: 'counterClockwise',
+ type: 'boolean',
+ description:
+ 'If set, the circle gets filled counterclockwise instead of clockwise. Default false.',
+ },
+ {
+ name: 'closePath',
+ type: 'boolean',
+ description: (
+ <>
+ If set to <code>false</code>, no path to the middle of the circle
+ will be drawn, leading to an open arc. Default <code>true</code>.
+ </>
+ ),
+ },
+ {
+ name: 'rotation',
+ type: 'boolean',
+ description: (
+ <>
+ Add rotation to the path. <code>0</code> means no rotation,{' '}
+ <code>Math.PI * 2</code> means 1 full clockwise rotation{' '}
+ </>
+ ),
+ },
+ ],
+ },
+ {
+ shape: 'Ellipse',
+ fn: makeEllipse,
+ params: [
+ {
+ name: 'rx',
+ type: 'number',
+ description: 'The radius of the ellipse on the X axis.',
+ },
+ {
+ name: 'ry',
+ type: 'number',
+ description: 'The radius of the ellipse on the Y axis.',
+ },
+ ],
+ },
+ {
+ shape: 'Triangle',
+ fn: makeTriangle,
+ params: [
+ {
+ name: 'length',
+ type: 'number',
+ description: 'The length of one triangle side.',
+ },
+ {
+ name: 'direction',
+ type: '"left" | "right" | "up" | "down"',
+ description: 'The direction of the triangle.',
+ },
+ ],
+ },
+ {
+ shape: 'Star',
+ fn: makeStar,
+ params: [
+ {
+ name: 'points',
+ type: 'number',
+ description: 'The amount of points of the star.',
+ },
+ {
+ name: 'innerRadius',
+ type: 'number',
+ description: 'The inner radius of the star.',
+ },
+ {
+ name: 'outerRadius',
+ type: 'number',
+ description: 'The outer radius of the star.',
+ },
+ ],
+ },
+ {
+ shape: 'Polygon',
+ fn: makePolygon,
+ params: [
+ {
+ name: 'points',
+ type: 'number',
+ description: 'The number of points in the polygon.',
+ },
+ {
+ name: 'radius',
+ type: 'number',
+ description: 'The radius of the polygon.',
+ },
+ {
+ name: 'edgeRoundness',
+ type: 'number | null',
+ description:
+ 'Allows to modify the shape by rounding the edges using bezier curves. Default null.',
+ },
+ {
+ name: 'cornerRadius',
+ type: 'number',
+ description:
+ "Rounds the corner using an arc. Similar to CSS's border-radius. Cannot be used together with edgeRoundness.",
+ },
+ ],
+ },
];
const globalParams: Param[] = [
- {
- name: "fill",
- type: "string",
- description: "The color of the shape.",
- },
- {
- name: "stroke",
- type: "string",
- description: (
- <>
- The color of the stroke. Should be used together with{" "}
- <code>strokeWidth</code>.
- </>
- ),
- },
- {
- name: "strokeWidth",
- type: "string",
- description: (
- <>
- The width of the stroke. Should be used together with{" "}
- <code>stroke</code>.
- </>
- ),
- },
- {
- name: "style",
- type: "string",
- description: (
- <>
- CSS properties that will be applied to the <code>{"<svg>"}</code> tag.
- Default style: <code>{"overflow: 'visible'"}</code>
- </>
- ),
- },
- {
- name: "pathStyle",
- type: "string",
- description: (
- <>
- CSS properties that will be applied to the <code>{"<path>"}</code> tag.
- Default style: <code>{"transform-box: 'fill-box'"}</code> and a
- dynamically calculated <code>{"transform-origin"}</code> which is the
- center of the shape, so that the shape rotates around its center by
- default.
- </>
- ),
- },
+ {
+ name: 'fill',
+ type: 'string',
+ description: 'The color of the shape.',
+ },
+ {
+ name: 'stroke',
+ type: 'string',
+ description: (
+ <>
+ The color of the stroke. Should be used together with{' '}
+ <code>strokeWidth</code>.
+ </>
+ ),
+ },
+ {
+ name: 'strokeWidth',
+ type: 'string',
+ description: (
+ <>
+ The width of the stroke. Should be used together with{' '}
+ <code>stroke</code>.
+ </>
+ ),
+ },
+ {
+ name: 'style',
+ type: 'string',
+ description: (
+ <>
+ CSS properties that will be applied to the <code>{'<svg>'}</code> tag.
+ Default style: <code>{"overflow: 'visible'"}</code>
+ </>
+ ),
+ },
+ {
+ name: 'pathStyle',
+ type: 'string',
+ description: (
+ <>
+ CSS properties that will be applied to the <code>{'<path>'}</code> tag.
+ Default style: <code>{"transform-box: 'fill-box'"}</code> and a
+ dynamically calculated <code>{'transform-origin'}</code> which is the
+ center of the shape, so that the shape rotates around its center by
+ default.
+ </>
+ ),
+ },
- {
- name: "strokeDasharray",
- type: "string",
- description: (
- <>
- Allows to animate a path. See{" "}
- <a href="/docs/paths/evolve-path">evolvePath()</a> for an example.
- </>
- ),
- },
- {
- name: "strokeDashoffset",
- type: "string",
- description: (
- <>
- Allows to animate a path. See{" "}
- <a href="/docs/paths/evolve-path">evolvePath()</a> for an example.
- </>
- ),
- },
+ {
+ name: 'strokeDasharray',
+ type: 'string',
+ description: (
+ <>
+ Allows to animate a path. See{' '}
+ <a href="/docs/paths/evolve-path">evolvePath()</a> for an example.
+ </>
+ ),
+ },
+ {
+ name: 'strokeDashoffset',
+ type: 'string',
+ description: (
+ <>
+ Allows to animate a path. See{' '}
+ <a href="/docs/paths/evolve-path">evolvePath()</a> for an example.
+ </>
+ ),
+ },
];
export const ShapeOptions: React.FC<{
- shape: string;
- all: boolean;
-}> = ({ shape, all }) => {
- const shapeComponent = shapeComponents.find(
- (c) => c.shape.toLowerCase() === shape.toLowerCase(),
- );
+ shape: string;
+ all: boolean;
+}> = ({shape, all}) => {
+ const shapeComponent = shapeComponents.find(
+ (c) => c.shape.toLowerCase() === shape.toLowerCase(),
+ );
- return (
- <React.Fragment>
- {(all
- ? [...shapeComponent.params, ...globalParams]
- : shapeComponent.params
- ).map((p) => {
- return (
- <React.Fragment key={p.name}>
- <h3>
- <code>{p.name}</code>
- </h3>
- <p>
- <em>{p.type}</em>
- </p>
- <p>{p.description}</p>
- </React.Fragment>
- );
- })}
- {all &&
- (shapeComponent.shape === "Rect" ||
- shapeComponent.shape === "Triangle" ||
- shapeComponent.shape === "Polygon") ? (
- <>
- <h3>
- <code>cornerRadius</code>
- </h3>
- <p>
- <em>number</em>
- </p>
- <p>
- Rounds the corner using an arc. Similar to {"CSS's"}{" "}
- <code>border-radius</code>. Cannot be used together with{" "}
- <code>edgeRoundness</code>.
- </p>
- </>
- ) : null}
+ if (!shapeComponent) {
+ throw new Error('no');
+ }
- {shapeComponent.shape === "Rect" ? <RectEdgeRoundness /> : null}
- {shapeComponent.shape === "Triangle" ? <TriangleEdgeRoundness /> : null}
- {all &&
- (shapeComponent.shape === "Rect" ||
- shapeComponent.shape === "Triangle") ? (
- <DebugOption />
- ) : null}
- {all ? (
- <>
- <h3>Other props</h3>{" "}
- <p>
- All other props that can be passed to a <code>{"<path>"}</code> are
- accepted and will be forwarded.
- </p>
- </>
- ) : null}
- </React.Fragment>
- );
+ return (
+ <React.Fragment>
+ {(all
+ ? [...shapeComponent.params, ...globalParams]
+ : shapeComponent.params
+ ).map((p) => {
+ return (
+ <React.Fragment key={p.name}>
+ <h3>
+ <code>{p.name}</code>
+ </h3>
+ <p>
+ <em>{p.type}</em>
+ </p>
+ <p>{p.description}</p>
+ </React.Fragment>
+ );
+ })}
+ {all &&
+ (shapeComponent.shape === 'Rect' ||
+ shapeComponent.shape === 'Triangle' ||
+ shapeComponent.shape === 'Polygon') ? (
+ <>
+ <h3>
+ <code>cornerRadius</code>
+ </h3>
+ <p>
+ <em>number</em>
+ </p>
+ <p>
+ Rounds the corner using an arc. Similar to {"CSS's"}{' '}
+ <code>border-radius</code>. Cannot be used together with{' '}
+ <code>edgeRoundness</code>.
+ </p>
+ </>
+ ) : null}
+
+ {shapeComponent.shape === 'Rect' ? <RectEdgeRoundness /> : null}
+ {shapeComponent.shape === 'Triangle' ? <TriangleEdgeRoundness /> : null}
+ {all &&
+ (shapeComponent.shape === 'Rect' ||
+ shapeComponent.shape === 'Triangle') ? (
+ <DebugOption />
+ ) : null}
+ {all ? (
+ <>
+ <h3>Other props</h3>{' '}
+ <p>
+ All other props that can be passed to a <code>{'<path>'}</code> are
+ accepted and will be forwarded.
+ </p>
+ </>
+ ) : null}
+ </React.Fragment>
+ );
};
export const MakeShapeReturnType: React.FC<{
- shape: string;
-}> = ({ shape }) => {
- const shapeComponent = shapeComponents.find(
- (c) => c.shape.toLowerCase() === shape.toLowerCase(),
- );
+ shape: string;
+}> = ({shape}) => {
+ const shapeComponent = shapeComponents.find(
+ (c) => c.shape.toLowerCase() === shape.toLowerCase(),
+ );
+
+ if (!shapeComponent) {
+ throw new Error('no');
+ }
- return (
- <div>
- <h3>
- <code>path</code>
- </h3>
- <p>
- A string that is suitable as an argument for <code>d</code> in a{" "}
- <code>{"<path>"}</code> element.
- </p>
- <h3>
- <code>width</code>
- </h3>
- <p>
- The width of the {shapeComponent.shape.toLowerCase()}. Suitable for
- defining the <code>viewBox</code> of an <code>{"<svg>"}</code> tag.
- </p>
- <h3>
- <code>height</code>
- </h3>
- <p>
- The height of the {shapeComponent.shape.toLowerCase()}. Suitable for
- defining the <code>viewBox</code> of an <code>{"<svg>"}</code> tag.
- </p>
- <h3>
- <code>instructions</code>
- </h3>
- <p>
- An array with SVG instructions. The type for a instruction can be seen
- by importing <code>Instruction</code> from <code>@remotion/shapes</code>
- .
- </p>
- <h3>
- <code>transformOrigin</code>
- </h3>
- <p>
- A string representing the point of origin if a shape should be rotated
- around itself.
- </p>
- <p>
- If you want to rotate the shape around its center, use the{" "}
- <code>transform-origin</code> CSS property and pass this value, and also
- add <code>transform-box: fill-box</code>. This is the default for{" "}
- <a href={`/docs/shapes/${shapeComponent.shape.toLowerCase()}`}>
- <code>{`<${shapeComponent.shape} />`}</code>
- </a>
- .
- </p>
- </div>
- );
+ return (
+ <div>
+ <h3>
+ <code>path</code>
+ </h3>
+ <p>
+ A string that is suitable as an argument for <code>d</code> in a{' '}
+ <code>{'<path>'}</code> element.
+ </p>
+ <h3>
+ <code>width</code>
+ </h3>
+ <p>
+ The width of the {shapeComponent.shape.toLowerCase()}. Suitable for
+ defining the <code>viewBox</code> of an <code>{'<svg>'}</code> tag.
+ </p>
+ <h3>
+ <code>height</code>
+ </h3>
+ <p>
+ The height of the {shapeComponent.shape.toLowerCase()}. Suitable for
+ defining the <code>viewBox</code> of an <code>{'<svg>'}</code> tag.
+ </p>
+ <h3>
+ <code>instructions</code>
+ </h3>
+ <p>
+ An array with SVG instructions. The type for a instruction can be seen
+ by importing <code>Instruction</code> from <code>@remotion/shapes</code>
+ .
+ </p>
+ <h3>
+ <code>transformOrigin</code>
+ </h3>
+ <p>
+ A string representing the point of origin if a shape should be rotated
+ around itself.
+ </p>
+ <p>
+ If you want to rotate the shape around its center, use the{' '}
+ <code>transform-origin</code> CSS property and pass this value, and also
+ add <code>transform-box: fill-box</code>. This is the default for{' '}
+ <a href={`/docs/shapes/${shapeComponent.shape.toLowerCase()}`}>
+ <code>{`<${shapeComponent.shape} />`}</code>
+ </a>
+ .
+ </p>
+ </div>
+ );
};
export const MakeShapeSeeAlso: React.FC<{
- shape: string;
-}> = ({ shape }) => {
- const shapeComponent = shapeComponents.find(
- (c) => c.shape.toLowerCase() === shape.toLowerCase(),
- );
+ shape: string;
+}> = ({shape}) => {
+ const shapeComponent = shapeComponents.find(
+ (c) => c.shape.toLowerCase() === shape.toLowerCase(),
+ );
- return (
- <ul>
- <li>
- <a
- href={`/docs/shapes/make-${shapeComponent.shape.toLowerCase()}`}
- >{`<${shapeComponent.shape} />`}</a>
- </li>
- <li>
- <a href={`/docs/shapes`}>
- <code>@remotion/shapes</code>
- </a>
- </li>
- <li>
- <a
- href={`https://github.com/remotion-dev/remotion/blob/main/packages/shapes/src/utils/make-${shape.toLowerCase()}.ts`}
- >
- Source code for this function
- </a>
- </li>
- </ul>
- );
+ if (!shapeComponent) {
+ throw new Error('no');
+ }
+
+ return (
+ <ul>
+ <li>
+ <a
+ href={`/docs/shapes/make-${shapeComponent.shape.toLowerCase()}`}
+ >{`<${shapeComponent.shape} />`}</a>
+ </li>
+ <li>
+ <a href={`/docs/shapes`}>
+ <code>@remotion/shapes</code>
+ </a>
+ </li>
+ <li>
+ <a
+ href={`https://github.com/remotion-dev/remotion/blob/main/packages/shapes/src/utils/make-${shape.toLowerCase()}.ts`}
+ >
+ Source code for this function
+ </a>
+ </li>
+ </ul>
+ );
};
export const ShapeSeeAlso: React.FC<{
- shape: string;
-}> = ({ shape }) => {
- const shapeComponent = shapeComponents.find(
- (c) => c.shape.toLowerCase() === shape.toLowerCase(),
- );
+ shape: string;
+}> = ({shape}) => {
+ const shapeComponent = shapeComponents.find(
+ (c) => c.shape.toLowerCase() === shape.toLowerCase(),
+ );
+
+ if (!shapeComponent) {
+ throw new Error('no');
+ }
- return (
- <ul>
- <li>
- <a
- href={`/docs/shapes/${shapeComponent.shape.toLowerCase()}`}
- >{`make${shapeComponent.shape}()`}</a>
- </li>
- <li>
- <a href={`/docs/shapes`}>
- <code>@remotion/shapes</code>
- </a>
- </li>
- <li>
- <a
- href={`https://github.com/remotion-dev/remotion/blob/main/packages/shapes/src/components/${shape.toLowerCase()}.tsx`}
- >
- Source code for this function
- </a>
- </li>
- </ul>
- );
+ return (
+ <ul>
+ <li>
+ <a
+ href={`/docs/shapes/${shapeComponent.shape.toLowerCase()}`}
+ >{`make${shapeComponent.shape}()`}</a>
+ </li>
+ <li>
+ <a href={`/docs/shapes`}>
+ <code>@remotion/shapes</code>
+ </a>
+ </li>
+ <li>
+ <a
+ href={`https://github.com/remotion-dev/remotion/blob/main/packages/shapes/src/components/${shape.toLowerCase()}.tsx`}
+ >
+ Source code for this function
+ </a>
+ </li>
+ </ul>
+ );
};
diff --git a/packages/docs/components/transitions/previews.tsx b/packages/docs/components/transitions/previews.tsx
index f751e73c47..3704ae7466 100644
--- a/packages/docs/components/transitions/previews.tsx
+++ b/packages/docs/components/transitions/previews.tsx
@@ -1,266 +1,269 @@
-import type { CubeDirection } from "@remotion-dev/cube-presentation";
-import { cube } from "@remotion-dev/cube-presentation";
-import type { PlayerRef } from "@remotion/player";
-import { Player } from "@remotion/player";
+import type {CubeDirection} from '@remotion-dev/cube-presentation';
+import {cube} from '@remotion-dev/cube-presentation';
+import type {PlayerRef} from '@remotion/player';
+import {Player} from '@remotion/player';
import type {
- TransitionPresentation,
- TransitionTiming,
-} from "@remotion/transitions";
-import { TransitionSeries, springTiming } from "@remotion/transitions";
-import { clockWipe } from "@remotion/transitions/clock-wipe";
-import { fade } from "@remotion/transitions/fade";
-import type { FlipDirection } from "@remotion/transitions/flip";
-import { flip } from "@remotion/transitions/flip";
-import { none } from "@remotion/transitions/none";
-import type { SlideDirection } from "@remotion/transitions/slide";
-import { slide } from "@remotion/transitions/slide";
-import type { WipeDirection } from "@remotion/transitions/wipe";
-import { wipe } from "@remotion/transitions/wipe";
-import React, { useEffect, useRef } from "react";
-import type { SpringConfig } from "remotion";
-import { AbsoluteFill, measureSpring, spring, useVideoConfig } from "remotion";
+ TransitionPresentation,
+ TransitionTiming,
+} from '@remotion/transitions';
+import {TransitionSeries, springTiming} from '@remotion/transitions';
+import {clockWipe} from '@remotion/transitions/clock-wipe';
+import {fade} from '@remotion/transitions/fade';
+import type {FlipDirection} from '@remotion/transitions/flip';
+import {flip} from '@remotion/transitions/flip';
+import {none} from '@remotion/transitions/none';
+import type {SlideDirection} from '@remotion/transitions/slide';
+import {slide} from '@remotion/transitions/slide';
+import type {WipeDirection} from '@remotion/transitions/wipe';
+import {wipe} from '@remotion/transitions/wipe';
+import React, {useEffect, useRef} from 'react';
+import type {SpringConfig} from 'remotion';
+import {AbsoluteFill, measureSpring, spring, useVideoConfig} from 'remotion';
import {
- presentationCompositionHeight,
- presentationCompositionWidth,
-} from "../TableOfContents/transitions/presentations";
-import { customPresentation } from "./custom-transition";
+ presentationCompositionHeight,
+ presentationCompositionWidth,
+} from '../TableOfContents/transitions/presentations';
+import {customPresentation} from './custom-transition';
const SceneA: React.FC = () => {
- return (
- <AbsoluteFill
- style={{
- justifyContent: "center",
- alignItems: "center",
- backgroundColor: "#0b84f3",
- fontFamily: "sans-serif",
- fontWeight: 900,
- color: "white",
- fontSize: 100,
- }}
- >
- A
- </AbsoluteFill>
- );
+ return (
+ <AbsoluteFill
+ style={{
+ justifyContent: 'center',
+ alignItems: 'center',
+ backgroundColor: '#0b84f3',
+ fontFamily: 'sans-serif',
+ fontWeight: 900,
+ color: 'white',
+ fontSize: 100,
+ }}
+ >
+ A
+ </AbsoluteFill>
+ );
};
const SceneB: React.FC = () => {
- return (
- <AbsoluteFill
- style={{
- justifyContent: "center",
- alignItems: "center",
- backgroundColor: "pink",
- fontFamily: "sans-serif",
- fontWeight: 900,
- color: "white",
- fontSize: 100,
- }}
- >
- B
- </AbsoluteFill>
- );
+ return (
+ <AbsoluteFill
+ style={{
+ justifyContent: 'center',
+ alignItems: 'center',
+ backgroundColor: 'pink',
+ fontFamily: 'sans-serif',
+ fontWeight: 900,
+ color: 'white',
+ fontSize: 100,
+ }}
+ >
+ B
+ </AbsoluteFill>
+ );
};
export const SampleTransition: React.FC<{
- readonly effect: TransitionPresentation<Record<string, unknown>>;
- readonly durationRestThreshold: number;
- readonly transition?: TransitionTiming;
-}> = ({ durationRestThreshold, effect, transition }) => {
- return (
- <TransitionSeries>
- <TransitionSeries.Sequence durationInFrames={60}>
- <SceneA />
- </TransitionSeries.Sequence>
- <TransitionSeries.Transition
- presentation={effect}
- timing={
- transition ??
- springTiming({
- config: {
- damping: 200,
- },
- durationInFrames: 60,
- durationRestThreshold,
- })
- }
- />
- <TransitionSeries.Sequence durationInFrames={90}>
- <SceneB />
- </TransitionSeries.Sequence>
- </TransitionSeries>
- );
+ readonly effect: TransitionPresentation<Record<string, unknown>>;
+ readonly durationRestThreshold: number;
+ readonly transition?: TransitionTiming;
+}> = ({durationRestThreshold, effect, transition}) => {
+ return (
+ <TransitionSeries>
+ <TransitionSeries.Sequence durationInFrames={60}>
+ <SceneA />
+ </TransitionSeries.Sequence>
+ <TransitionSeries.Transition
+ presentation={effect}
+ timing={
+ transition ??
+ springTiming({
+ config: {
+ damping: 200,
+ },
+ durationInFrames: 60,
+ durationRestThreshold,
+ })
+ }
+ />
+ <TransitionSeries.Sequence durationInFrames={90}>
+ <SceneB />
+ </TransitionSeries.Sequence>
+ </TransitionSeries>
+ );
};
export const FadeDemo: React.FC = () => {
- return <SampleTransition effect={fade()} durationRestThreshold={0.001} />;
+ return <SampleTransition effect={fade()} durationRestThreshold={0.001} />;
};
export const SlideDemo: React.FC<{
- readonly direction: SlideDirection;
-}> = ({ direction }) => {
- return (
- <SampleTransition
- effect={slide({ direction })}
- durationRestThreshold={0.001}
- />
- );
+ readonly direction: SlideDirection;
+}> = ({direction}) => {
+ return (
+ <SampleTransition
+ effect={slide({direction})}
+ durationRestThreshold={0.001}
+ />
+ );
};
export const FlipDemo: React.FC<{
- readonly direction: FlipDirection;
-}> = ({ direction }) => {
- return (
- <SampleTransition
- effect={flip({ direction })}
- durationRestThreshold={0.001}
- />
- );
+ readonly direction: FlipDirection;
+}> = ({direction}) => {
+ return (
+ <SampleTransition
+ effect={flip({direction})}
+ durationRestThreshold={0.001}
+ />
+ );
};
export const NoneDemo: React.FC<{}> = () => {
- return <SampleTransition effect={none({})} durationRestThreshold={0.001} />;
+ return <SampleTransition effect={none({})} durationRestThreshold={0.001} />;
};
export const SlideDemoLongDurationRest: React.FC<{
- readonly direction: SlideDirection;
-}> = ({ direction }) => {
- return (
- <SampleTransition
- effect={slide({ direction })}
- durationRestThreshold={0.005}
- />
- );
+ readonly direction: SlideDirection;
+}> = ({direction}) => {
+ return (
+ <SampleTransition
+ effect={slide({direction})}
+ durationRestThreshold={0.005}
+ />
+ );
};
export const WipeDemo: React.FC<{
- readonly direction: WipeDirection;
-}> = ({ direction }) => {
- return (
- <SampleTransition
- effect={wipe({ direction })}
- durationRestThreshold={0.001}
- />
- );
+ readonly direction: WipeDirection;
+}> = ({direction}) => {
+ return (
+ <SampleTransition
+ effect={wipe({direction})}
+ durationRestThreshold={0.001}
+ />
+ );
};
export const ClockWipeDemo: React.FC<{}> = () => {
- const { width, height } = useVideoConfig();
+ const {width, height} = useVideoConfig();
- return (
- <SampleTransition
- effect={clockWipe({ width, height })}
- durationRestThreshold={0.001}
- />
- );
+ return (
+ <SampleTransition
+ // @ts-expect-error
+ effect={clockWipe({width, height})}
+ durationRestThreshold={0.001}
+ />
+ );
};
-export const CubeDemo: React.FC<{ readonly direction: CubeDirection }> = ({
- direction,
+export const CubeDemo: React.FC<{readonly direction: CubeDirection}> = ({
+ direction,
}) => {
- return (
- <SampleTransition
- effect={cube({ direction })}
- durationRestThreshold={0.001}
- />
- );
+ return (
+ <SampleTransition
+ // @ts-expect-error
+ effect={cube({direction})}
+ durationRestThreshold={0.001}
+ />
+ );
};
export const CustomTransitionDemo: React.FC<{}> = () => {
- const { width, height } = useVideoConfig();
+ const {width, height} = useVideoConfig();
- return (
- <SampleTransition
- effect={customPresentation({ height, width })}
- durationRestThreshold={0.001}
- />
- );
+ return (
+ <SampleTransition
+ // @ts-expect-error
+ effect={customPresentation({height, width})}
+ durationRestThreshold={0.001}
+ />
+ );
};
const customTiming = ({
- pauseDuration,
+ pauseDuration,
}: {
- pauseDuration: number;
+ pauseDuration: number;
}): TransitionTiming => {
- const firstHalf: Partial<SpringConfig> = {};
- const secondPush: Partial<SpringConfig> = {
- damping: 200,
- };
+ const firstHalf: Partial<SpringConfig> = {};
+ const secondPush: Partial<SpringConfig> = {
+ damping: 200,
+ };
- return {
- getDurationInFrames: ({ fps }) => {
- return (
- measureSpring({ fps, config: firstHalf }) +
- measureSpring({ fps, config: secondPush }) +
- pauseDuration
- );
- },
- getProgress({ fps, frame }) {
- const first = spring({ fps, frame, config: firstHalf });
- const second = spring({
- fps,
- frame,
- config: secondPush,
- delay: pauseDuration + measureSpring({ fps, config: firstHalf }),
- });
+ return {
+ getDurationInFrames: ({fps}) => {
+ return (
+ measureSpring({fps, config: firstHalf}) +
+ measureSpring({fps, config: secondPush}) +
+ pauseDuration
+ );
+ },
+ getProgress({fps, frame}) {
+ const first = spring({fps, frame, config: firstHalf});
+ const second = spring({
+ fps,
+ frame,
+ config: secondPush,
+ delay: pauseDuration + measureSpring({fps, config: firstHalf}),
+ });
- return first / 2 + second / 2;
- },
- };
+ return first / 2 + second / 2;
+ },
+ };
};
export const CustomTimingDemo: React.FC<{}> = () => {
- return (
- <SampleTransition
- effect={slide({ direction: "from-left" })}
- transition={customTiming({ pauseDuration: 5 })}
- durationRestThreshold={0.001}
- />
- );
+ return (
+ <SampleTransition
+ effect={slide({direction: 'from-left'})}
+ transition={customTiming({pauseDuration: 5})}
+ durationRestThreshold={0.001}
+ />
+ );
};
export const PresentationPreview: React.FC<{
- readonly effect: TransitionPresentation<Record<string, unknown>>;
- readonly durationRestThreshold: number;
-}> = ({ effect, durationRestThreshold }) => {
- const ref = useRef<PlayerRef>(null);
+ readonly effect: TransitionPresentation<Record<string, unknown>>;
+ readonly durationRestThreshold: number;
+}> = ({effect, durationRestThreshold}) => {
+ const ref = useRef<PlayerRef>(null);
- useEffect(() => {
- const { current } = ref;
- if (!current) {
- return;
- }
+ useEffect(() => {
+ const {current} = ref;
+ if (!current) {
+ return;
+ }
- const callback = () => {
- current?.seekTo(0);
- current?.play();
- };
+ const callback = () => {
+ current?.seekTo(0);
+ current?.play();
+ };
- current?.getContainerNode()?.addEventListener("pointerenter", callback);
+ current?.getContainerNode()?.addEventListener('pointerenter', callback);
- return () => {
- current
- ?.getContainerNode()
- ?.removeEventListener("pointerenter", callback);
- };
- }, []);
+ return () => {
+ current
+ ?.getContainerNode()
+ ?.removeEventListener('pointerenter', callback);
+ };
+ }, []);
- return (
- <Player
- ref={ref}
- component={SampleTransition}
- compositionHeight={presentationCompositionHeight}
- compositionWidth={presentationCompositionWidth}
- durationInFrames={60}
- fps={30}
- numberOfSharedAudioTags={0}
- style={{
- height: 60,
- borderRadius: 6,
- }}
- inputProps={{
- effect,
- durationRestThreshold,
- }}
- />
- );
+ return (
+ <Player
+ ref={ref}
+ component={SampleTransition}
+ compositionHeight={presentationCompositionHeight}
+ compositionWidth={presentationCompositionWidth}
+ durationInFrames={60}
+ fps={30}
+ numberOfSharedAudioTags={0}
+ style={{
+ height: 60,
+ borderRadius: 6,
+ }}
+ inputProps={{
+ effect,
+ durationRestThreshold,
+ }}
+ />
+ );
};
diff --git a/packages/docs/src/components/ChooseTemplate.tsx b/packages/docs/src/components/ChooseTemplate.tsx
index 41022396ad..211a2aaf2a 100644
--- a/packages/docs/src/components/ChooseTemplate.tsx
+++ b/packages/docs/src/components/ChooseTemplate.tsx
@@ -44,7 +44,7 @@ export const ChooseTemplate: React.FC = () => {
style={{textDecoration: 'none'}}
to={`/templates/${template.cliId}`}
>
- <TemplateIcon label={template.featuredOnHomePage}>
+ <TemplateIcon label={template.featuredOnHomePage!}>
<IconForTemplate scale={0.7} template={template} />
</TemplateIcon>
</Link>
diff --git a/packages/docs/src/components/Demo/Demo.tsx b/packages/docs/src/components/Demo/Demo.tsx
index 0dfa8f278f..ca2dd405b3 100644
--- a/packages/docs/src/components/Demo/Demo.tsx
+++ b/packages/docs/src/components/Demo/Demo.tsx
@@ -23,7 +23,6 @@ import {
import type {EmojiPosition} from '../../remotion/HomepageVideo/emoji/EmojiCard';
import {ActionRow} from './ActionRow';
import {PlayerControls} from './PlayerControls';
-import styles from './player.module.css';
preloadAudio(staticFile('Utope-nature-5s.mp3'));
@@ -97,7 +96,7 @@ export const Demo: React.FC = () => {
current: c.prev,
next: c.current,
translation: 0,
- translationStyle: undefined,
+ translationStyle: '',
};
});
}, 200);
@@ -135,7 +134,10 @@ export const Demo: React.FC = () => {
emojiPositions,
onClickLeft,
onClickRight,
- ...data,
+ playerData: {
+ location: data?.location ?? null,
+ trending: data?.trending ?? null,
+ },
};
}, [cardOrder, colorMode, data, emojiPositions, onClickLeft, onClickRight]);
@@ -144,47 +146,29 @@ export const Demo: React.FC = () => {
<br />
<h1>Try out this interactive demo!</h1>
<ActionRow />
-
- {data ? (
- <div style={playerWrapper}>
- <Player
- ref={ref}
- component={HomepageVideoComp}
- compositionWidth={640}
- compositionHeight={360}
- durationInFrames={120}
- fps={30}
- autoPlay
- controls={isFullscreen}
- clickToPlay={false}
- style={{
- width: '100%',
- aspectRatio: '640 / 360',
- borderBottom: `2px solid ${BOX_STROKE}`,
- touchAction: 'none', // prevent page from scrolling when dragging children on mobile
- }}
- initiallyMuted
- inputProps={props}
- loop
- />
- <PlayerControls playerRef={ref} durationInFrames={120} fps={30} />
- </div>
- ) : (
- <>
- <div
- style={{
- aspectRatio: '640 / 360',
- ...playerWrapper,
- }}
- />
- <div
- className={styles['controls-wrapper']}
- style={{justifyContent: 'center'}}
- >
- <p>Loading Player</p>
- </div>
- </>
- )}
+ <div style={playerWrapper}>
+ <Player
+ ref={ref}
+ component={HomepageVideoComp}
+ compositionWidth={640}
+ compositionHeight={360}
+ durationInFrames={120}
+ fps={30}
+ autoPlay
+ controls={isFullscreen}
+ clickToPlay={false}
+ style={{
+ width: '100%',
+ aspectRatio: '640 / 360',
+ borderBottom: `2px solid ${BOX_STROKE}`,
+ touchAction: 'none', // prevent page from scrolling when dragging children on mobile
+ }}
+ initiallyMuted
+ inputProps={props}
+ loop
+ />
+ <PlayerControls playerRef={ref} durationInFrames={120} fps={30} />
+ </div>
</div>
);
};
diff --git a/packages/docs/src/components/Demo/PlayerSeekBar.tsx b/packages/docs/src/components/Demo/PlayerSeekBar.tsx
index 2bf13fe29d..9fdf965a0a 100644
--- a/packages/docs/src/components/Demo/PlayerSeekBar.tsx
+++ b/packages/docs/src/components/Demo/PlayerSeekBar.tsx
@@ -139,7 +139,7 @@ export const PlayerSeekBar: React.FC<{
}
const onFrameUpdate = () => {
- setFrame(playerRef.current.getCurrentFrame());
+ setFrame(playerRef.current!.getCurrentFrame());
};
current.addEventListener('frameupdate', onFrameUpdate);
@@ -200,8 +200,8 @@ export const PlayerSeekBar: React.FC<{
durationInFrames,
width,
);
- playerRef.current.pause();
- playerRef.current.seekTo(_frame);
+ playerRef.current!.pause();
+ playerRef.current!.seekTo(_frame);
setDragging({
dragging: true,
wasPlaying: playing,
@@ -229,7 +229,7 @@ export const PlayerSeekBar: React.FC<{
durationInFrames,
size.width,
);
- playerRef.current.seekTo(_frame);
+ playerRef.current!.seekTo(_frame);
},
[dragging.dragging, durationInFrames, playerRef, size],
);
@@ -243,9 +243,9 @@ export const PlayerSeekBar: React.FC<{
}
if (dragging.wasPlaying) {
- playerRef.current.play();
+ playerRef.current!.play();
} else {
- playerRef.current.pause();
+ playerRef.current!.pause();
}
onSeekEnd();
diff --git a/packages/docs/src/components/Demo/PlayerVolume.tsx b/packages/docs/src/components/Demo/PlayerVolume.tsx
index 2d572b762e..544b7713de 100644
--- a/packages/docs/src/components/Demo/PlayerVolume.tsx
+++ b/packages/docs/src/components/Demo/PlayerVolume.tsx
@@ -45,10 +45,10 @@ export const PlayerVolume: React.FC<{
timerRef.current = null;
}
- if (playerRef.current.isMuted()) {
- playerRef.current.unmute();
+ if (playerRef.current!.isMuted()) {
+ playerRef.current!.unmute();
} else {
- playerRef.current.mute();
+ playerRef.current!.mute();
}
}, [playerRef]);
diff --git a/packages/docs/src/components/ExpertPage.tsx b/packages/docs/src/components/ExpertPage.tsx
index be7f36bd2a..4b39f87443 100644
--- a/packages/docs/src/components/ExpertPage.tsx
+++ b/packages/docs/src/components/ExpertPage.tsx
@@ -107,12 +107,12 @@ export default () => {
}
const expert = experts.find((e) => e.slug === expertSlug[1]);
- const imgSrc = `/generated/experts-${expert.slug}.png`;
-
if (!expert) {
throw new Error('no expert found');
}
+ const imgSrc = `/generated/experts-${expert.slug}.png`;
+
return (
<Layout>
<Head>
diff --git a/packages/docs/src/components/MuxVideo.tsx b/packages/docs/src/components/MuxVideo.tsx
index 8370c0ebf9..d7f8f7b8f5 100644
--- a/packages/docs/src/components/MuxVideo.tsx
+++ b/packages/docs/src/components/MuxVideo.tsx
@@ -19,7 +19,7 @@ const MuxVideoForward: React.ForwardRefRenderFunction<
const videoRef = useRef<HTMLVideoElement>(null);
const vidUrl = getVideoToPlayUrl(muxId);
- useImperativeHandle(ref, () => videoRef.current, []);
+ useImperativeHandle(ref, () => videoRef.current!, []);
useEffect(() => {
let hls: Hls;
diff --git a/packages/docs/src/components/TemplateModalContent.tsx b/packages/docs/src/components/TemplateModalContent.tsx
index f912e06914..7289624cd0 100644
--- a/packages/docs/src/components/TemplateModalContent.tsx
+++ b/packages/docs/src/components/TemplateModalContent.tsx
@@ -144,7 +144,7 @@ export const TemplateModalContent: React.FC<{
}, []);
const copyCommand = useCallback(async (command: string) => {
- clearTimeout(copyTimeout);
+ clearTimeout(copyTimeout!);
const permissionName = 'clipboard-write' as PermissionName;
try {
const result = await navigator.permissions.query({
diff --git a/packages/docs/src/components/VideoPlayerContent.tsx b/packages/docs/src/components/VideoPlayerContent.tsx
index 8157085257..1cdcd5c0e0 100644
--- a/packages/docs/src/components/VideoPlayerContent.tsx
+++ b/packages/docs/src/components/VideoPlayerContent.tsx
@@ -114,11 +114,11 @@ export const VideoPlayerContent: React.FC<{
}
const onClick = () => {
- if (videoRef.current.paused) {
- videoRef.current.play();
+ if (videoRef.current?.paused) {
+ videoRef.current?.play();
setPaused(false);
} else {
- videoRef.current.pause();
+ videoRef.current?.pause();
setPaused(true);
}
};
diff --git a/packages/docs/src/helpers/chunk.ts b/packages/docs/src/helpers/chunk.ts
index 165ce6bfef..e3a48e7f12 100644
--- a/packages/docs/src/helpers/chunk.ts
+++ b/packages/docs/src/helpers/chunk.ts
@@ -1,6 +1,7 @@
export function chunk<T>(array: T[], chunkSize: number): T[][] {
const R = [];
for (let i = 0, len = array.length; i < len; i += chunkSize)
+ // @ts-expect-error
R.push(array.slice(i, i + chunkSize));
return R;
}
diff --git a/packages/docs/src/pages/4/index.tsx b/packages/docs/src/pages/4/index.tsx
index 1e13b9a959..b5079fa680 100644
--- a/packages/docs/src/pages/4/index.tsx
+++ b/packages/docs/src/pages/4/index.tsx
@@ -80,7 +80,7 @@ export const EventComp: React.FC<{
const V4: React.FC = () => {
const context = useDocusaurusContext();
- const [email, setEmail] = useState<string>(null);
+ const [email, setEmail] = useState<string | null>(null);
const [loading, setLoading] = useState<boolean>(false);
const [subscribed, setSubscribed] = useState<boolean>(false);
const [error, setError] = useState<string | null>(null);
@@ -108,7 +108,7 @@ const V4: React.FC = () => {
setSubscribed(false);
setError(null);
- if (isValidEmail(email)) {
+ if (email && isValidEmail(email)) {
setLoading(true);
const res = await fetch('https://www.remotion.pro/api/newsletter', {
method: 'POST',
diff --git a/packages/docs/src/remotion/Article.tsx b/packages/docs/src/remotion/Article.tsx
index bbb74b11df..0aecc5392d 100644
--- a/packages/docs/src/remotion/Article.tsx
+++ b/packages/docs/src/remotion/Article.tsx
@@ -7,6 +7,10 @@ export const Article: React.FC<{
articleRelativePath: string;
}> = ({articleRelativePath}) => {
const article = articles.find((e) => e.relativePath === articleRelativePath);
+ if (!article) {
+ return null;
+ }
+
const longestTitle = Math.max(
...article.title.split(' ').map((p) => p.length),
);
diff --git a/packages/docs/src/remotion/Expert.tsx b/packages/docs/src/remotion/Expert.tsx
index 00ae8a993e..1dd9014f81 100644
--- a/packages/docs/src/remotion/Expert.tsx
+++ b/packages/docs/src/remotion/Expert.tsx
@@ -69,7 +69,7 @@ export const Expert: React.FC<{
flexDirection: 'row',
}}
>
- <Img height="350" src={staticFile(expert.image)} />
+ <Img height="350" src={staticFile(expert!.image)} />
<div
style={{
width: 700,
@@ -87,7 +87,7 @@ export const Expert: React.FC<{
fontSize: 60,
}}
>
- {expert.name}
+ {expert!.name}
</div>
</div>
</div>
diff --git a/packages/docs/src/remotion/HomepageVideo/Comp.tsx b/packages/docs/src/remotion/HomepageVideo/Comp.tsx
index dd7c7a3a45..1078af5824 100644
--- a/packages/docs/src/remotion/HomepageVideo/Comp.tsx
+++ b/packages/docs/src/remotion/HomepageVideo/Comp.tsx
@@ -11,7 +11,7 @@ import {Cards} from './cards/Cards';
import type {EmojiPosition} from './emoji/EmojiCard';
import type {Location} from './types';
-export type Trending = {
+export type RemoteData = {
repos: string[];
date: string;
temperatureInCelsius: number;
@@ -23,8 +23,8 @@ export type Trending = {
};
export type LocationAndTrending = {
- location: Location;
- trending: Trending;
+ location: Location | null;
+ trending: RemoteData | null;
};
export const getDataAndProps = async () => {
@@ -61,7 +61,7 @@ export const calculateMetadata: CalculateMetadataFunction<
width: 640,
props: {
...props,
- trending,
+ data: trending,
location,
temperatureInCelsius: trending?.temperatureInCelsius ?? 10,
onToggle() {},
@@ -71,8 +71,7 @@ export const calculateMetadata: CalculateMetadataFunction<
};
export type DemoPlayerProps = {
- readonly location: Location;
- readonly trending: null | Trending;
+ readonly playerData: LocationAndTrending;
readonly onToggle: () => void;
readonly cardOrder: number[];
readonly updateCardOrder: (newCardOrder: number[]) => void;
@@ -84,14 +83,13 @@ export type DemoPlayerProps = {
export const HomepageVideoComp: React.FC<DemoPlayerProps> = ({
theme,
- location,
- trending,
onToggle,
cardOrder,
updateCardOrder,
emojiPositions,
onClickLeft,
onClickRight,
+ playerData,
}) => {
const [rerenders, setRerenders] = useState(0);
const {durationInFrames} = useVideoConfig();
@@ -104,14 +102,6 @@ export const HomepageVideoComp: React.FC<DemoPlayerProps> = ({
[rerenders, updateCardOrder],
);
- if (!location) {
- return null;
- }
-
- if (!trending) {
- return null;
- }
-
const loweredVolume = 0.5; // this track is too loud by default
const audioFadeFrame = durationInFrames - 30;
@@ -126,10 +116,8 @@ export const HomepageVideoComp: React.FC<DemoPlayerProps> = ({
onUpdate={onUpdate}
indices={cardOrder}
theme={theme}
- location={location}
- trending={trending}
+ data={playerData}
onToggle={onToggle}
- temperatureInCelsius={trending.temperatureInCelsius}
onClickLeft={onClickLeft}
onClickRight={onClickRight}
emojiPositions={emojiPositions}
diff --git a/packages/docs/src/remotion/HomepageVideo/CurrentCountry.tsx b/packages/docs/src/remotion/HomepageVideo/CurrentCountry.tsx
index 6c6d84b356..16bd619cd8 100644
--- a/packages/docs/src/remotion/HomepageVideo/CurrentCountry.tsx
+++ b/packages/docs/src/remotion/HomepageVideo/CurrentCountry.tsx
@@ -10,19 +10,25 @@ import {
export const CurrentCountry: React.FC<{
readonly theme: 'dark' | 'light';
- readonly countryPaths: {
- d: string;
- class: string;
- }[];
- readonly countryLabel: string;
+ readonly countryPaths:
+ | {
+ d: string;
+ class: string;
+ }[]
+ | null;
+ readonly countryLabel: string | null;
}> = ({theme, countryPaths, countryLabel}) => {
+ const {fps} = useVideoConfig();
+ const frame = useCurrentFrame();
+
+ if (!countryPaths) {
+ return null;
+ }
+
const joined = countryPaths.map((p) => p.d).join(' ');
const reset = resetPath(joined);
const boundingBox = getBoundingBox(reset);
- const {fps} = useVideoConfig();
- const frame = useCurrentFrame();
-
const progress = spring({
fps,
frame,
diff --git a/packages/docs/src/remotion/HomepageVideo/Temperature.tsx b/packages/docs/src/remotion/HomepageVideo/Temperature.tsx
index 24b382b422..e5dc83d699 100644
--- a/packages/docs/src/remotion/HomepageVideo/Temperature.tsx
+++ b/packages/docs/src/remotion/HomepageVideo/Temperature.tsx
@@ -4,9 +4,13 @@ import {TemperatureNumber} from './TemperatureNumber';
export const Temperature: React.FC<{
readonly theme: 'dark' | 'light';
- readonly city: string;
- temperatureInCelsius: number;
+ readonly city: string | null;
+ temperatureInCelsius: number | null;
}> = ({theme, city, temperatureInCelsius}) => {
+ if (temperatureInCelsius === null) {
+ return null;
+ }
+
return (
<AbsoluteFill>
<AbsoluteFill
diff --git a/packages/docs/src/remotion/HomepageVideo/TrendingRepos.tsx b/packages/docs/src/remotion/HomepageVideo/TrendingRepos.tsx
index 9581912a11..d6981a8d8c 100644
--- a/packages/docs/src/remotion/HomepageVideo/TrendingRepos.tsx
+++ b/packages/docs/src/remotion/HomepageVideo/TrendingRepos.tsx
@@ -1,6 +1,6 @@
import React, {useMemo} from 'react';
import {AbsoluteFill, spring, useCurrentFrame, useVideoConfig} from 'remotion';
-import type {Trending} from './Comp';
+import type {RemoteData} from './Comp';
const TrendingRepoItem: React.FC<{
repo: string;
@@ -39,7 +39,7 @@ const TrendingRepoItem: React.FC<{
export const TrendingRepos: React.FC<{
readonly theme: 'dark' | 'light';
- readonly trending: Trending;
+ readonly trending: RemoteData | null;
}> = ({theme, trending}) => {
const fill = theme === 'light' ? '#666' : '#999';
const frame = useCurrentFrame();
@@ -54,6 +54,10 @@ export const TrendingRepos: React.FC<{
delay: 0,
});
+ if (trending === null) {
+ return null;
+ }
+
return (
<AbsoluteFill>
<AbsoluteFill
diff --git a/packages/docs/src/remotion/HomepageVideo/cards/Card.tsx b/packages/docs/src/remotion/HomepageVideo/cards/Card.tsx
index 99b18ed1a2..c71b4ebe6d 100644
--- a/packages/docs/src/remotion/HomepageVideo/cards/Card.tsx
+++ b/packages/docs/src/remotion/HomepageVideo/cards/Card.tsx
@@ -176,6 +176,9 @@ export const Card: React.FC<{
cardLeft + translateX,
cardTop + translateY,
);
+ if (position === undefined) {
+ throw new Error('pos');
+ }
if (position === index) {
if (
diff --git a/packages/docs/src/remotion/HomepageVideo/cards/Cards.tsx b/packages/docs/src/remotion/HomepageVideo/cards/Cards.tsx
index 1959904655..d4fe5cc4e3 100644
--- a/packages/docs/src/remotion/HomepageVideo/cards/Cards.tsx
+++ b/packages/docs/src/remotion/HomepageVideo/cards/Cards.tsx
@@ -1,11 +1,10 @@
import React, {createRef, useEffect, useRef, useState} from 'react';
import {AbsoluteFill, getRemotionEnvironment} from 'remotion';
-import type {Trending} from '../Comp';
+import type {LocationAndTrending} from '../Comp';
import {CurrentCountry} from '../CurrentCountry';
import {Temperature} from '../Temperature';
import {TrendingRepos} from '../TrendingRepos';
import {EmojiCard, type EmojiPosition} from '../emoji/EmojiCard';
-import type {Location} from '../types';
import {Card} from './Card';
import {getInitialPositions} from './math';
@@ -13,9 +12,7 @@ export const Cards: React.FC<{
readonly onUpdate: (newIndices: number[]) => void;
readonly indices: number[];
readonly theme: 'dark' | 'light';
- readonly location: Location;
- readonly trending: Trending;
- readonly temperatureInCelsius: number;
+ readonly data: LocationAndTrending;
onToggle: () => void;
onClickLeft: () => void;
onClickRight: () => void;
@@ -24,13 +21,11 @@ export const Cards: React.FC<{
onUpdate,
indices,
theme,
- location,
- trending,
onToggle,
- temperatureInCelsius,
onClickLeft,
onClickRight,
emojiPositions,
+ data,
}) => {
const container = useRef<HTMLDivElement>(null);
@@ -71,17 +66,17 @@ export const Cards: React.FC<{
const index = indices[i];
const content =
index === 0 ? (
- <TrendingRepos trending={trending} theme={theme} />
+ <TrendingRepos trending={data.trending} theme={theme} />
) : index === 1 ? (
<Temperature
- city={location.city}
+ city={data.location?.city ?? null}
theme={theme}
- temperatureInCelsius={temperatureInCelsius}
+ temperatureInCelsius={data.trending?.temperatureInCelsius ?? null}
/>
) : index === 2 ? (
<CurrentCountry
- countryPaths={trending.countryPaths}
- countryLabel={trending.countryLabel}
+ countryPaths={data.trending?.countryPaths ?? null}
+ countryLabel={data.trending?.countryLabel ?? null}
theme={theme}
/>
) : (
@@ -93,6 +88,7 @@ export const Cards: React.FC<{
// eslint-disable-next-line react/no-array-index-key
key={i}
onUpdate={onUpdate}
+ // @ts-expect-error
refsToUse={refs}
index={i}
content={content}
diff --git a/packages/docs/src/remotion/HomepageVideo/emoji/DisplayedEmoji.tsx b/packages/docs/src/remotion/HomepageVideo/emoji/DisplayedEmoji.tsx
index 8e587c8230..440b07b691 100644
--- a/packages/docs/src/remotion/HomepageVideo/emoji/DisplayedEmoji.tsx
+++ b/packages/docs/src/remotion/HomepageVideo/emoji/DisplayedEmoji.tsx
@@ -8,7 +8,7 @@ export const DisplayedEmoji: React.FC<{
}> = ({emoji}) => {
const partyDuration = getAvailableEmojis().find(
(e) => e.name === emoji,
- ).durationInSeconds;
+ )!.durationInSeconds;
const {durationInFrames, fps} = useVideoConfig();
const ratio = durationInFrames / fps / partyDuration;
diff --git a/packages/docs/src/remotion/Root.tsx b/packages/docs/src/remotion/Root.tsx
index ac68fd187a..b4f296200b 100644
--- a/packages/docs/src/remotion/Root.tsx
+++ b/packages/docs/src/remotion/Root.tsx
@@ -75,13 +75,6 @@ export const RemotionRoot: React.FC = () => {
fps={30}
defaultProps={{
theme: 'light',
- location: {
- country: 'US',
- city: 'New York',
- latitude: 40.7128,
- longitude: -74.006,
- },
- trending: null,
onToggle: () => undefined,
cardOrder: [0, 1, 2, 3],
updateCardOrder: () => undefined,
@@ -94,6 +87,21 @@ export const RemotionRoot: React.FC = () => {
},
onClickLeft: () => undefined,
onClickRight: () => undefined,
+ playerData: {
+ trending: {
+ temperatureInCelsius: 14,
+ countryLabel: 'Switzerland',
+ countryPaths: [],
+ date: '2024-12-31',
+ repos: [],
+ },
+ location: {
+ city: 'New York',
+ country: 'US',
+ latitude: 40.7128,
+ longitude: -74.006,
+ },
+ },
}}
calculateMetadata={calculateMetadata}
/>
diff --git a/packages/docs/src/remotion/Template.tsx b/packages/docs/src/remotion/Template.tsx
index 5145a77718..dabd729751 100644
--- a/packages/docs/src/remotion/Template.tsx
+++ b/packages/docs/src/remotion/Template.tsx
@@ -67,11 +67,11 @@ export const TemplateComp: React.FC<{
alignItems: 'center',
}}
>
- {template.cliId === 'next' ||
- template.cliId === 'next-tailwind' ||
- template.cliId === 'next-pages-dir' ? null : (
+ {template!.cliId === 'next' ||
+ template!.cliId === 'next-tailwind' ||
+ template!.cliId === 'next-pages-dir' ? null : (
<>
- <IconForTemplate scale={1.6} template={template} />{' '}
+ <IconForTemplate scale={1.6} template={template!} />{' '}
<div
style={{
width: 25,
@@ -81,7 +81,7 @@ export const TemplateComp: React.FC<{
</>
)}
- {template.shortName}
+ {template!.shortName}
</div>
</div>
@@ -111,7 +111,7 @@ export const TemplateComp: React.FC<{
>
<div>
<div style={{opacity: 0.7}}>Install this template</div>
- <div>npx create-video@latest --template {template.cliId}</div>
+ <div>npx create-video@latest --template {template!.cliId}</div>
</div>
</div>
<div
diff --git a/packages/docs/src/theme/Footer/index.tsx b/packages/docs/src/theme/Footer/index.tsx
index a2771db4fa..12bf26dbe3 100644
--- a/packages/docs/src/theme/Footer/index.tsx
+++ b/packages/docs/src/theme/Footer/index.tsx
@@ -9,7 +9,7 @@ const Footer = () => {
useEffect(() => {
if (typeof document !== 'undefined') {
document
- .querySelector('.navbar__logo')
+ .querySelector('.navbar__logo')!
.addEventListener('contextmenu', (e) => {
e.preventDefault();
window.open('https://remotion.dev/brand', '_blank');
diff --git a/packages/docs/tsconfig.json b/packages/docs/tsconfig.json
index 5e59692dad..58fca08a46 100644
--- a/packages/docs/tsconfig.json
+++ b/packages/docs/tsconfig.json
@@ -9,7 +9,7 @@
"target": "ES2019",
"moduleResolution": "node",
"noImplicitAny": false,
- "strictNullChecks": false,
+ "strictNullChecks": true,
"strict": false,
"noEmit": true,
"incremental": true