File tree 2 files changed +31
-8
lines changed
2 files changed +31
-8
lines changed Original file line number Diff line number Diff line change @@ -3,11 +3,10 @@ import { render } from 'react-dom';
3
3
import { hot } from 'react-hot-loader/root' ;
4
4
import { Provider } from 'react-redux' ;
5
5
import { Router , browserHistory } from 'react-router' ;
6
- import { ThemeProvider } from 'styled-components' ;
7
6
8
7
import configureStore from './store' ;
9
8
import routes from './routes' ;
10
- import theme , { Theme } from './theme ' ;
9
+ import ThemeProvider from './modules/App/components/ThemeProvider ' ;
11
10
12
11
require ( './styles/main.scss' ) ;
13
12
@@ -19,14 +18,12 @@ const initialState = window.__INITIAL_STATE__;
19
18
20
19
const store = configureStore ( initialState ) ;
21
20
22
- const currentTheme = Theme . light ;
23
-
24
21
const App = ( ) => (
25
- < ThemeProvider theme = { { ... theme [ currentTheme ] } } >
26
- < Provider store = { store } >
22
+ < Provider store = { store } >
23
+ < ThemeProvider >
27
24
< Router history = { history } routes = { routes ( store ) } />
28
- </ Provider >
29
- </ ThemeProvider >
25
+ </ ThemeProvider >
26
+ </ Provider >
30
27
) ;
31
28
32
29
const HotApp = hot ( App ) ;
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import PropTypes from 'prop-types' ;
3
+ import { connect } from 'react-redux' ;
4
+ import { ThemeProvider } from 'styled-components' ;
5
+
6
+ import theme , { Theme } from '../../../theme' ;
7
+
8
+ const Provider = ( { children, currentTheme } ) => (
9
+ < ThemeProvider theme = { { ...theme [ currentTheme ] } } >
10
+ { children }
11
+ </ ThemeProvider >
12
+ ) ;
13
+
14
+ Provider . propTypes = {
15
+ children : PropTypes . node . isRequired ,
16
+ currentTheme : PropTypes . oneOf ( Object . keys ( Theme ) ) . isRequired ,
17
+ } ;
18
+
19
+ function mapStateToProps ( state ) {
20
+ return {
21
+ currentTheme : state . preferences . theme ,
22
+ } ;
23
+ }
24
+
25
+
26
+ export default connect ( mapStateToProps ) ( Provider ) ;
You can’t perform that action at this time.
0 commit comments