diff --git a/client/index.jsx b/client/index.jsx index a1a880bb..09ab654b 100644 --- a/client/index.jsx +++ b/client/index.jsx @@ -3,11 +3,10 @@ import { render } from 'react-dom'; import { hot } from 'react-hot-loader/root'; import { Provider } from 'react-redux'; import { Router, browserHistory } from 'react-router'; -import { ThemeProvider } from 'styled-components'; import configureStore from './store'; import routes from './routes'; -import theme, { Theme } from './theme'; +import ThemeProvider from './modules/App/components/ThemeProvider'; require('./styles/main.scss'); @@ -19,14 +18,12 @@ const initialState = window.__INITIAL_STATE__; const store = configureStore(initialState); -const currentTheme = Theme.light; - const App = () => ( - - + + - - + + ); const HotApp = hot(App); diff --git a/client/modules/App/components/ThemeProvider.jsx b/client/modules/App/components/ThemeProvider.jsx new file mode 100644 index 00000000..eb6dcc9b --- /dev/null +++ b/client/modules/App/components/ThemeProvider.jsx @@ -0,0 +1,26 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { connect } from 'react-redux'; +import { ThemeProvider } from 'styled-components'; + +import theme, { Theme } from '../../../theme'; + +const Provider = ({ children, currentTheme }) => ( + + {children} + +); + +Provider.propTypes = { + children: PropTypes.node.isRequired, + currentTheme: PropTypes.oneOf(Object.keys(Theme)).isRequired, +}; + +function mapStateToProps(state) { + return { + currentTheme: state.preferences.theme, + }; +} + + +export default connect(mapStateToProps)(Provider);