File tree Expand file tree Collapse file tree 7 files changed +28
-20
lines changed Expand file tree Collapse file tree 7 files changed +28
-20
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ const logoUrl = require('../images/p5js-logo-small.svg');
7
7
const editorUrl = require ( '../images/code.svg' ) ;
8
8
9
9
const PreviewNav = ( { owner, project } ) => (
10
- < nav className = "nav" >
10
+ < nav className = "nav preview-nav " >
11
11
< div className = "nav__items-left" >
12
12
< div className = "nav__item-logo" >
13
13
< InlineSVG src = { logoUrl } alt = "p5.js logo" />
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ class App extends React.Component {
14
14
15
15
componentDidMount ( ) {
16
16
this . setState ( { isMounted : true } ) ; // eslint-disable-line react/no-did-mount-set-state
17
- document . body . className = 'light' ;
17
+ document . body . className = this . props . theme ;
18
18
}
19
19
20
20
componentWillReceiveProps ( nextProps ) {
@@ -26,6 +26,12 @@ class App extends React.Component {
26
26
}
27
27
}
28
28
29
+ componentDidUpdate ( prevProps ) {
30
+ if ( this . props . theme !== prevProps . theme ) {
31
+ document . body . className = this . props . theme ;
32
+ }
33
+ }
34
+
29
35
render ( ) {
30
36
return (
31
37
< div className = "app" >
@@ -45,10 +51,18 @@ App.propTypes = {
45
51
} ) ,
46
52
} ) . isRequired ,
47
53
setPreviousPath : PropTypes . func . isRequired ,
54
+ theme : PropTypes . string ,
48
55
} ;
49
56
50
57
App . defaultProps = {
51
- children : null
58
+ children : null ,
59
+ theme : 'light'
52
60
} ;
53
61
54
- export default connect ( ( ) => ( { } ) , { setPreviousPath } ) ( App ) ;
62
+ const mapStateToProps = state => ( {
63
+ theme : state . preferences . theme ,
64
+ } ) ;
65
+
66
+ const mapDispatchToProps = { setPreviousPath } ;
67
+
68
+ export default connect ( mapStateToProps , mapDispatchToProps ) ( App ) ;
Original file line number Diff line number Diff line change @@ -11,13 +11,6 @@ import * as ProjectActions from '../actions/project';
11
11
class FullView extends React . Component {
12
12
componentDidMount ( ) {
13
13
this . props . getProject ( this . props . params . project_id ) ;
14
- document . body . className = this . props . theme ;
15
- }
16
-
17
- componentWillUpdate ( nextProps ) {
18
- if ( nextProps . theme !== this . props . theme ) {
19
- document . body . className = nextProps . theme ;
20
- }
21
14
}
22
15
23
16
ident = ( ) => { }
@@ -62,7 +55,6 @@ class FullView extends React.Component {
62
55
}
63
56
64
57
FullView . propTypes = {
65
- theme : PropTypes . string . isRequired ,
66
58
params : PropTypes . shape ( {
67
59
project_id : PropTypes . string
68
60
} ) . isRequired ,
@@ -98,7 +90,6 @@ FullView.propTypes = {
98
90
function mapStateToProps ( state ) {
99
91
return {
100
92
user : state . user ,
101
- theme : state . preferences . theme ,
102
93
htmlFile : getHTMLFile ( state . files ) ,
103
94
jsFiles : getJSFiles ( state . files ) ,
104
95
cssFiles : getCSSFiles ( state . files ) ,
Original file line number Diff line number Diff line change @@ -65,7 +65,6 @@ class IDEView extends React.Component {
65
65
66
66
window . onbeforeunload = ( ) => this . warnIfUnsavedChanges ( ) ;
67
67
68
- document . body . className = this . props . preferences . theme ;
69
68
this . autosaveInterval = null ;
70
69
}
71
70
@@ -89,10 +88,6 @@ class IDEView extends React.Component {
89
88
this . props . getProject ( nextProps . params . project_id ) ;
90
89
}
91
90
}
92
-
93
- if ( nextProps . preferences . theme !== this . props . preferences . theme ) {
94
- document . body . className = nextProps . preferences . theme ;
95
- }
96
91
}
97
92
98
93
componentDidUpdate ( prevProps ) {
Original file line number Diff line number Diff line change 12
12
}
13
13
}
14
14
}
15
+
16
+ .preview-nav {
17
+ .nav__item {
18
+ margin-left : #{5 / $base-font-size } rem;
19
+ }
20
+ }
Original file line number Diff line number Diff line change @@ -66,7 +66,8 @@ const headers = { 'User-Agent': 'p5js-web-editor/0.0.1' };
66
66
67
67
const mongoConnectionString = process . env . MONGO_URL ;
68
68
69
- mongoose . connect ( mongoConnectionString , { useMongoClient : true } ) ;
69
+ mongoose . connect ( mongoConnectionString , { useNewUrlParser : true , useUnifiedTopology : true } ) ;
70
+ mongoose . set ( 'useCreateIndex' , true ) ;
70
71
mongoose . connection . on ( 'error' , ( ) => {
71
72
console . error ( 'MongoDB Connection Error. Please make sure that MongoDB is running.' ) ;
72
73
process . exit ( 1 ) ;
Original file line number Diff line number Diff line change @@ -40,7 +40,8 @@ const headers = { 'User-Agent': 'p5js-web-editor/0.0.1' };
40
40
41
41
const mongoConnectionString = process . env . MONGO_URL ;
42
42
43
- mongoose . connect ( mongoConnectionString , { useMongoClient : true } ) ;
43
+ mongoose . connect ( mongoConnectionString , { useNewUrlParser : true , useUnifiedTopology : true } ) ;
44
+ mongoose . set ( 'useCreateIndex' , true ) ;
44
45
mongoose . connection . on ( 'error' , ( ) => {
45
46
console . error ( 'MongoDB Connection Error. Please make sure that MongoDB is running.' ) ;
46
47
process . exit ( 1 ) ;
You can’t perform that action at this time.
0 commit comments