Skip to content

Commit 6662765

Browse files
BrunoScheuflertimsuchanek
authored andcommitted
Fix custom theme and settings (#759)
* Fix announcement link * fix: allow custom theme and settings from connect props * fix: update getTheme to use custom supplied settings * fix: removed unnecessary import
1 parent e2cf374 commit 6662765

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

packages/graphql-playground-react/src/components/PlaygroundWrapper.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import {
2020
import OldThemeProvider from './Theme/ThemeProvider'
2121
import { getActiveEndpoints } from './util'
2222
import { ISettings } from '../types'
23-
import { createStructuredSelector } from 'reselect'
2423
import { connect } from 'react-redux'
2524
import { getTheme, getSettings } from '../state/workspace/reducers'
2625
import { Session, Tab } from '../state/sessions/reducers'
@@ -511,10 +510,11 @@ class PlaygroundWrapper extends React.Component<
511510
}
512511
}
513512

514-
const mapStateToProps = createStructuredSelector({
515-
theme: getTheme,
516-
settings: getSettings,
517-
})
513+
const mapStateToProps = (state, ownProps) => {
514+
const theme = ownProps.theme || getTheme(state, ownProps.settings)
515+
const settings = ownProps.settings || getSettings(state)
516+
return { theme, settings }
517+
}
518518

519519
export default connect(
520520
mapStateToProps,

packages/graphql-playground-react/src/state/workspace/reducers.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ export function normalizeSettingsString(settingsString) {
205205
return JSON.stringify(parseSettingsString(settingsString), null, 2)
206206
}
207207

208-
export const getTheme = createSelector(
209-
[getSettings],
210-
s => s['editor.theme'] || 'dark',
211-
)
208+
export const getTheme = (state, customSettings) => {
209+
const settings = customSettings || getSettings(state)
210+
return settings['editor.theme'] || 'dark'
211+
}

0 commit comments

Comments
 (0)