Skip to content

Commit

Permalink
[docs] Force light theme mode when activePage is null (#35575)
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasTy authored Dec 23, 2022
1 parent 68ef353 commit 648e121
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion docs/src/modules/components/ThemeContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
getThemedComponents,
getMetaThemeColor,
} from 'docs/src/modules/brandingTheme';
import PageContext from './PageContext';

const languageMap = {
en: enUS,
Expand Down Expand Up @@ -115,7 +116,10 @@ if (process.env.NODE_ENV !== 'production') {
export function ThemeProvider(props) {
const { children } = props;
const prefersDarkMode = useMediaQuery('(prefers-color-scheme: dark)');
const preferredMode = prefersDarkMode ? 'dark' : 'light';
const pageContextValue = React.useContext(PageContext);
// `activePage` does not exist for playground pages
// forcing light mode in playground avoids the need for a wrapping theme in playground pages
const preferredMode = pageContextValue.activePage && prefersDarkMode ? 'dark' : 'light';

const [themeOptions, dispatch] = React.useReducer(
(state, action) => {
Expand Down

0 comments on commit 648e121

Please sign in to comment.