Skip to content

Commit 387cec1

Browse files
committed
Merge branch 'feature/sketch-collections' of https://github.com/andrewn/p5.js-web-editor into feature/sketch-collections
2 parents 4f7c9f2 + 5319bbb commit 387cec1

File tree

7 files changed

+28
-20
lines changed

7 files changed

+28
-20
lines changed

client/components/PreviewNav.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const logoUrl = require('../images/p5js-logo-small.svg');
77
const editorUrl = require('../images/code.svg');
88

99
const PreviewNav = ({ owner, project }) => (
10-
<nav className="nav">
10+
<nav className="nav preview-nav">
1111
<div className="nav__items-left">
1212
<div className="nav__item-logo">
1313
<InlineSVG src={logoUrl} alt="p5.js logo" />

client/modules/App/App.jsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class App extends React.Component {
1414

1515
componentDidMount() {
1616
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;
1818
}
1919

2020
componentWillReceiveProps(nextProps) {
@@ -26,6 +26,12 @@ class App extends React.Component {
2626
}
2727
}
2828

29+
componentDidUpdate(prevProps) {
30+
if (this.props.theme !== prevProps.theme) {
31+
document.body.className = this.props.theme;
32+
}
33+
}
34+
2935
render() {
3036
return (
3137
<div className="app">
@@ -45,10 +51,18 @@ App.propTypes = {
4551
}),
4652
}).isRequired,
4753
setPreviousPath: PropTypes.func.isRequired,
54+
theme: PropTypes.string,
4855
};
4956

5057
App.defaultProps = {
51-
children: null
58+
children: null,
59+
theme: 'light'
5260
};
5361

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);

client/modules/IDE/pages/FullView.jsx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@ import * as ProjectActions from '../actions/project';
1111
class FullView extends React.Component {
1212
componentDidMount() {
1313
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-
}
2114
}
2215

2316
ident = () => {}
@@ -62,7 +55,6 @@ class FullView extends React.Component {
6255
}
6356

6457
FullView.propTypes = {
65-
theme: PropTypes.string.isRequired,
6658
params: PropTypes.shape({
6759
project_id: PropTypes.string
6860
}).isRequired,
@@ -98,7 +90,6 @@ FullView.propTypes = {
9890
function mapStateToProps(state) {
9991
return {
10092
user: state.user,
101-
theme: state.preferences.theme,
10293
htmlFile: getHTMLFile(state.files),
10394
jsFiles: getJSFiles(state.files),
10495
cssFiles: getCSSFiles(state.files),

client/modules/IDE/pages/IDEView.jsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ class IDEView extends React.Component {
6565

6666
window.onbeforeunload = () => this.warnIfUnsavedChanges();
6767

68-
document.body.className = this.props.preferences.theme;
6968
this.autosaveInterval = null;
7069
}
7170

@@ -89,10 +88,6 @@ class IDEView extends React.Component {
8988
this.props.getProject(nextProps.params.project_id);
9089
}
9190
}
92-
93-
if (nextProps.preferences.theme !== this.props.preferences.theme) {
94-
document.body.className = nextProps.preferences.theme;
95-
}
9691
}
9792

9893
componentDidUpdate(prevProps) {

client/styles/components/_preview-nav.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,9 @@
1212
}
1313
}
1414
}
15+
16+
.preview-nav {
17+
.nav__item {
18+
margin-left: #{5 / $base-font-size}rem;
19+
}
20+
}

server/scripts/examples-gg-latest.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ const headers = { 'User-Agent': 'p5js-web-editor/0.0.1' };
6666

6767
const mongoConnectionString = process.env.MONGO_URL;
6868

69-
mongoose.connect(mongoConnectionString, { useMongoClient: true });
69+
mongoose.connect(mongoConnectionString, { useNewUrlParser: true, useUnifiedTopology: true });
70+
mongoose.set('useCreateIndex', true);
7071
mongoose.connection.on('error', () => {
7172
console.error('MongoDB Connection Error. Please make sure that MongoDB is running.');
7273
process.exit(1);

server/scripts/examples.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ const headers = { 'User-Agent': 'p5js-web-editor/0.0.1' };
4040

4141
const mongoConnectionString = process.env.MONGO_URL;
4242

43-
mongoose.connect(mongoConnectionString, { useMongoClient: true });
43+
mongoose.connect(mongoConnectionString, { useNewUrlParser: true, useUnifiedTopology: true });
44+
mongoose.set('useCreateIndex', true);
4445
mongoose.connection.on('error', () => {
4546
console.error('MongoDB Connection Error. Please make sure that MongoDB is running.');
4647
process.exit(1);

0 commit comments

Comments
 (0)