Skip to content

Commit

Permalink
feat[devtools-fusebox]: support theme option (#28832)
Browse files Browse the repository at this point in the history
Support propagating theme from Chrome DevTools frontend, the field is
optional.

Next step, which is out of scope of this project and general improvement
for React DevTools: teach RDT to listen to theme changes and if the
theme preference is set to `auto` in settings, update the theme
accordingly with the browser devtools.
  • Loading branch information
hoxyq authored Apr 12, 2024
1 parent 96c5846 commit 7625f0d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/react-devtools-fusebox/src/frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import Bridge from 'react-devtools-shared/src/bridge';
import Store from 'react-devtools-shared/src/devtools/store';
import DevTools from 'react-devtools-shared/src/devtools/views/DevTools';

import type {Wall} from 'react-devtools-shared/src/frontend/types';
import type {
BrowserTheme,
Wall,
} from 'react-devtools-shared/src/frontend/types';
import type {FrontendBridge} from 'react-devtools-shared/src/bridge';

type Config = {
Expand Down Expand Up @@ -42,18 +45,20 @@ export function createStore(bridge: FrontendBridge, config?: Config): Store {
type InitializationOptions = {
bridge: FrontendBridge,
store: Store,
theme?: BrowserTheme,
};

export function initialize(
contentWindow: Element | Document,
options: InitializationOptions,
): void {
const {bridge, store} = options;
const {bridge, store, theme = 'light'} = options;
const root = createRoot(contentWindow);

root.render(
<DevTools
bridge={bridge}
browserTheme={theme}
store={store}
showTabBar={true}
warnIfLegacyBackendDetected={true}
Expand Down

0 comments on commit 7625f0d

Please sign in to comment.