🎥 Make videos programmatically with React
docs: Revert useColorMode workaround changes as requested
copilot-swe-agent[bot]726622a6dd17
diff --git a/packages/docs/src/css/custom.css b/packages/docs/src/css/custom.cssindex 119efdb365..50f25a8b87 100644--- a/packages/docs/src/css/custom.css+++ b/packages/docs/src/css/custom.css@@ -239,29 +239,3 @@ code {.header-x-link:hover::before {background-color: var(--ifm-navbar-link-hover-color);}--/* Video Player Header theme-specific styles */-[data-theme='light'] .video-player-header {- border-bottom: 1px solid rgba(0, 0, 0, 0.1);-}--[data-theme='dark'] .video-player-header {- border-bottom: 1px solid rgba(255, 255, 255, 0.1);-}--[data-theme='light'] .video-player-icon {- color: #222;-}--[data-theme='dark'] .video-player-icon {- color: #ddd;-}--/* Footer logo theme-specific styles */-[data-theme='light'] .footer-logo-dark {- display: none;-}--[data-theme='dark'] .footer-logo-light {- display: none;-}diff --git a/packages/docs/src/pages/index.tsx b/packages/docs/src/pages/index.tsxindex 476731d78b..1c2b198d25 100644--- a/packages/docs/src/pages/index.tsx+++ b/packages/docs/src/pages/index.tsx@@ -1,8 +1,9 @@+import {useColorMode} from '@docusaurus/theme-common';import '@remotion/promo-pages/dist/Homepage.css';import {NewLanding} from '@remotion/promo-pages/dist/Homepage.js';import '@remotion/promo-pages/dist/tailwind.css';import Layout from '@theme/Layout';-import React, {useEffect, useState} from 'react';+import React from 'react';if (typeof window !== 'undefined' &&@@ -12,62 +13,19 @@ if (}const Inner: React.FC = () => {- // Initialize with default values to avoid hydration mismatch- const [colorMode, setColorModeState] = useState<'light' | 'dark'>('light');-- useEffect(() => {- // After hydration, determine the actual color mode from DOM attributes- const htmlElement = document.documentElement;- const currentTheme = htmlElement.getAttribute('data-theme') as- | 'light'- | 'dark'- | null;- if (currentTheme) {- setColorModeState(currentTheme);- }-- // Set up a MutationObserver to watch for theme changes- const observer = new MutationObserver((mutations) => {- mutations.forEach((mutation) => {- if (- mutation.type === 'attributes' &&- mutation.attributeName === 'data-theme'- ) {- const newTheme = (mutation.target as HTMLElement).getAttribute(- 'data-theme',- ) as 'light' | 'dark' | null;- if (newTheme) {- setColorModeState(newTheme);- }- }- });- });-- observer.observe(htmlElement, {- attributes: true,- attributeFilter: ['data-theme'],- });-- return () => observer.disconnect();- }, []);-- const handleSetColorMode = (newColorMode: 'light' | 'dark') => {- // Dispatch a custom event to trigger Docusaurus theme change- const event = new CustomEvent('docusaurus-theme-change', {- detail: {theme: newColorMode},- });- window.dispatchEvent(event);-- // Also try to find and click the actual theme toggle button- const themeToggle = document.querySelector(- '[title="Switch between dark and light mode"]',- ) as HTMLButtonElement;- if (themeToggle && colorMode !== newColorMode) {- themeToggle.click();- }- };-- return <NewLanding colorMode={colorMode} setColorMode={handleSetColorMode} />;+ let colorMode = 'light';+ let setColorMode = () => {};++ try {+ const colorModeHook = useColorMode();+ colorMode = colorModeHook.colorMode;+ setColorMode = colorModeHook.setColorMode;+ } catch (error) {+ // Fallback to light mode if context is not available+ console.warn('useColorMode context not available, falling back to light mode');+ }++ return <NewLanding colorMode={colorMode} setColorMode={setColorMode} />;};const Homepage: React.FC = () => {diff --git a/packages/docs/src/theme/Footer/Links/MultiColumn/index.tsx b/packages/docs/src/theme/Footer/Links/MultiColumn/index.tsxindex 45047cb7c8..d836d09c8e 100644--- a/packages/docs/src/theme/Footer/Links/MultiColumn/index.tsx+++ b/packages/docs/src/theme/Footer/Links/MultiColumn/index.tsx@@ -1,6 +1,7 @@-import React from 'react';+import {useColorMode} from '@docusaurus/theme-common';// @ts-expect-errorimport LinkItem from '@theme/Footer/LinkItem';+import React, {useEffect, useState} from 'react';const footerTitle: React.CSSProperties = {fontFamily: 'GTPlanar',@@ -46,6 +47,25 @@ const copyright: React.CSSProperties = {};export default ({columns}) => {+ let colorMode = 'light';+ try {+ const colorModeHook = useColorMode();+ colorMode = colorModeHook.colorMode;+ } catch (error) {+ // Fallback to light mode if context is not available+ console.warn('useColorMode context not available, falling back to light mode');+ }++ const [src, setSrc] = useState('/img/new-logo.png');++ useEffect(() => {+ if (colorMode === 'dark') {+ setSrc('/img/remotion-white.png');+ } else {+ setSrc('/img/new-logo.png');+ }+ }, [colorMode]);+return (<div className="row footer__links"><div@@ -54,26 +74,14 @@ export default ({columns}) => {marginBottom: 20,}}>- <div className="footer-logo-container">- <img- src="/img/new-logo.png"- className="footer-logo footer-logo-light"- style={{- height: 32,- marginRight: 80,- }}- alt="Remotion Logo"- />- <img- src="/img/remotion-white.png"- className="footer-logo footer-logo-dark"- style={{- height: 32,- marginRight: 80,- }}- alt="Remotion Logo"- />- </div>+ <img+ key={colorMode}+ src={src}+ style={{+ height: 32,+ marginRight: 80,+ }}+ /><p style={copyright}>© Copyright {new Date().getFullYear()} Remotion AG. <br /> Websitecreated with Docusaurus.