Skip to content

🎥 Make videos programmatically with React

also fix color mode warnings

Jonny Burger681c0e5d03a3
diff --git a/packages/docs/components/Bounties.tsx b/packages/docs/components/Bounties.tsx
index 334791e0fb..b3fd3e4407 100644
--- a/packages/docs/components/Bounties.tsx
+++ b/packages/docs/components/Bounties.tsx
@@ -43,7 +43,7 @@ const BountyCardSkeleton = () => (
);
export const Bounties = () => {
- const { isDarkTheme } = useColorMode();
+ const { colorMode } = useColorMode();
const [bounties, setBounties] = useState<RemoteData<Bounty[]>>({
_tag: "loading",
@@ -61,7 +61,7 @@ export const Bounties = () => {
}, []);
return (
- <div className={clsx("bounty-grid", isDarkTheme && "dark")}>
+ <div className={clsx("bounty-grid", colorMode === 'dark' && "dark")}>
{bounties._tag === "success" &&
bounties.data.map((bounty) => (
<div key={bounty.id}>
diff --git a/packages/docs/components/FFmpegVideo.tsx b/packages/docs/components/FFmpegVideo.tsx
index 0a240f7f40..8f975526b4 100644
--- a/packages/docs/components/FFmpegVideo.tsx
+++ b/packages/docs/components/FFmpegVideo.tsx
@@ -2,10 +2,14 @@ import { useColorMode } from "@docusaurus/theme-common";
import React from "react";
export const FfmpegVideo: React.FC = () => {
- const { isDarkTheme } = useColorMode();
+ const { colorMode } = useColorMode();
return (
<video
- src={isDarkTheme ? "/img/ffmpegauto-dark.mp4" : "/img/ffmpegauto.mp4"}
+ src={
+ colorMode === "dark"
+ ? "/img/ffmpegauto-dark.mp4"
+ : "/img/ffmpegauto.mp4"
+ }
autoPlay
muted
playsInline
diff --git a/packages/docs/components/LambdaSplash/VideoApps.tsx b/packages/docs/components/LambdaSplash/VideoApps.tsx
index 88cfc99c3a..f04eb71282 100644
--- a/packages/docs/components/LambdaSplash/VideoApps.tsx
+++ b/packages/docs/components/LambdaSplash/VideoApps.tsx
@@ -67,21 +67,23 @@ const docsButton: React.CSSProperties = {
export const VideoApps: React.FC<{
active: "remotion" | "player" | "lambda";
}> = ({ active }) => {
- const { isDarkTheme } = useColorMode();
+ const { colorMode } = useColorMode();
const [src, setSrc] = useState("/img/player-example.png");
const [src2, setSrc2] = useState("/img/player-example-dark.png");
useEffect(() => {
- if (isDarkTheme) {
+ if (colorMode === "dark") {
setSrc("/img/player-example-dark.png");
} else {
setSrc("/img/player-example.png");
}
- }, [isDarkTheme]);
+ }, [colorMode]);
useEffect(() => {
- setSrc2(isDarkTheme ? "/img/cluster-dark.png" : "/img/cluster.png");
- }, [isDarkTheme]);
+ setSrc2(
+ colorMode === "dark" ? "/img/cluster-dark.png" : "/img/cluster.png",
+ );
+ }, [colorMode]);
return (
<div className={videoapps.row}>
diff --git a/packages/docs/components/SplineVideo.tsx b/packages/docs/components/SplineVideo.tsx
index be24256af6..10b5239c60 100644
--- a/packages/docs/components/SplineVideo.tsx
+++ b/packages/docs/components/SplineVideo.tsx
@@ -2,11 +2,11 @@ import { useColorMode } from "@docusaurus/theme-common";
import React from "react";
export const SplineVideo: React.FC = () => {
- const { isDarkTheme } = useColorMode();
+ const { colorMode } = useColorMode();
return (
<video
src={
- isDarkTheme
+ colorMode === "dark"
? "/img/spline-guide/spline-dark.mp4"
: "/img/spline-guide/spline-light.mp4"
}
diff --git a/packages/docs/components/SpringsWithDurationDemo.tsx b/packages/docs/components/SpringsWithDurationDemo.tsx
index 9502f8e38e..0bd6270d06 100644
--- a/packages/docs/components/SpringsWithDurationDemo.tsx
+++ b/packages/docs/components/SpringsWithDurationDemo.tsx
@@ -2,10 +2,14 @@ import { useColorMode } from "@docusaurus/theme-common";
import React from "react";
export const SpringsWithDurationDemo: React.FC = () => {
- const { isDarkTheme } = useColorMode();
+ const { colorMode } = useColorMode();
return (
<video
- src={isDarkTheme ? "/img/springs-dark.mp4" : "/img/springs-light.mp4"}
+ src={
+ colorMode === "dark"
+ ? "/img/springs-dark.mp4"
+ : "/img/springs-light.mp4"
+ }
loop
muted
autoPlay
diff --git a/packages/docs/components/demos/index.tsx b/packages/docs/components/demos/index.tsx
index 34d1351ae7..992e4ead32 100644
--- a/packages/docs/components/demos/index.tsx
+++ b/packages/docs/components/demos/index.tsx
@@ -61,7 +61,7 @@ export const Demo: React.FC<{
type: string;
}> = ({ type }) => {
const demo = demos.find((d) => d.id === type);
- const { isDarkTheme } = useColorMode();
+ const { colorMode } = useColorMode();
const [key, setKey] = useState(() => 0);
@@ -133,7 +133,7 @@ export const Demo: React.FC<{
</AbsoluteFill>
);
}}
- inputProps={{ ...state, darkMode: isDarkTheme }}
+ inputProps={{ ...state, darkMode: colorMode === "dark" }}
autoPlay={demo.autoPlay}
loop
/>
diff --git a/packages/docs/src/components/DoMoreHero/DoMoreHero.tsx b/packages/docs/src/components/DoMoreHero/DoMoreHero.tsx
index 40544a1a97..70939bd19b 100644
--- a/packages/docs/src/components/DoMoreHero/DoMoreHero.tsx
+++ b/packages/docs/src/components/DoMoreHero/DoMoreHero.tsx
@@ -130,8 +130,8 @@ export const DoMoreHero: React.FC = () => {
};
const inputProps = useMemo(() => {
- return { dark: theme.isDarkTheme };
- }, [theme.isDarkTheme]);
+ return { dark: theme.colorMode === "dark" };
+ }, [theme.colorMode]);
return (
<div
diff --git a/packages/docs/src/theme/Footer/Links/MultiColumn/index.tsx b/packages/docs/src/theme/Footer/Links/MultiColumn/index.tsx
index c8e29b7f78..286c183a03 100644
--- a/packages/docs/src/theme/Footer/Links/MultiColumn/index.tsx
+++ b/packages/docs/src/theme/Footer/Links/MultiColumn/index.tsx
@@ -47,16 +47,16 @@ const copyright: React.CSSProperties = {
};
export default ({ columns }) => {
- const { isDarkTheme } = useColorMode();
+ const { colorMode } = useColorMode();
const [src, setSrc] = useState("/img/new-logo.png");
useEffect(() => {
- if (isDarkTheme) {
+ if (colorMode === "dark") {
setSrc("/img/remotion-white.png");
} else {
setSrc("/img/new-logo.png");
}
- }, [isDarkTheme]);
+ }, [colorMode]);
return (
<div className="row footer__links">
@@ -67,7 +67,7 @@ export default ({ columns }) => {
}}
>
<img
- key={String(isDarkTheme)}
+ key={colorMode}
src={src}
style={{
height: 32,