Skip to content

Commit

Permalink
Fix custom theme and settings (graphql#759)
Browse files Browse the repository at this point in the history
* Fix announcement link

* fix: allow custom theme and settings from connect props

* fix: update getTheme to use custom supplied settings

* fix: removed unnecessary import
  • Loading branch information
BrunoScheufler authored and timsuchanek committed Jul 6, 2018
1 parent 9cd0bcf commit e0c4c77
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
import OldThemeProvider from './Theme/ThemeProvider'
import { getActiveEndpoints } from './util'
import { ISettings } from '../types'
import { createStructuredSelector } from 'reselect'
import { connect } from 'react-redux'
import { getTheme, getSettings } from '../state/workspace/reducers'
import { Session, Tab } from '../state/sessions/reducers'
Expand Down Expand Up @@ -511,10 +510,11 @@ class PlaygroundWrapper extends React.Component<
}
}

const mapStateToProps = createStructuredSelector({
theme: getTheme,
settings: getSettings,
})
const mapStateToProps = (state, ownProps) => {
const theme = ownProps.theme || getTheme(state, ownProps.settings)
const settings = ownProps.settings || getSettings(state)
return { theme, settings }
}

export default connect(
mapStateToProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export function normalizeSettingsString(settingsString) {
return JSON.stringify(parseSettingsString(settingsString), null, 2)
}

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

0 comments on commit e0c4c77

Please sign in to comment.