From 842ba9f367b5a2f421d7503d98ccae0558e0123e Mon Sep 17 00:00:00 2001 From: catarak Date: Wed, 11 May 2016 16:13:17 -0400 Subject: [PATCH] add toggle sketch action --- shared/components/Toolbar/Toolbar.jsx | 2 +- shared/containers/App/App.jsx | 10 +++++++--- shared/redux/actions/index.js | 6 ++++++ shared/redux/reducers/ide.js | 19 ++++++++++++++++++- shared/redux/reducers/index.js | 4 +++- 5 files changed, 35 insertions(+), 6 deletions(-) diff --git a/shared/components/Toolbar/Toolbar.jsx b/shared/components/Toolbar/Toolbar.jsx index f4a4452f..c59d63c2 100644 --- a/shared/components/Toolbar/Toolbar.jsx +++ b/shared/components/Toolbar/Toolbar.jsx @@ -8,7 +8,7 @@ class Toolbar extends React.Component { return (
-
+
diff --git a/shared/containers/App/App.jsx b/shared/containers/App/App.jsx index e81de5f6..fab150de 100644 --- a/shared/containers/App/App.jsx +++ b/shared/containers/App/App.jsx @@ -12,7 +12,9 @@ class App extends React.Component { return (
+ className="toolbar" + isPlaying={this.props.ide.isPlaying} + toggleSketch={this.props.toggleSketch} /> @@ -20,7 +22,8 @@ class App extends React.Component { content={this.props.file.content} head={ - }/> + } + isPlaying={this.props.ide.isPlaying}/>
); } @@ -28,7 +31,8 @@ class App extends React.Component { function mapStateToProps(state) { return { - file: state.file + file: state.file, + ide: state.ide } } diff --git a/shared/redux/actions/index.js b/shared/redux/actions/index.js index 315a46ef..ff780292 100644 --- a/shared/redux/actions/index.js +++ b/shared/redux/actions/index.js @@ -6,4 +6,10 @@ export function updateFile(name, content) { name: name, content: content } +} + +export function toggleSketch() { + return { + type: ActionTypes.TOGGLE_SKETCH + } } \ No newline at end of file diff --git a/shared/redux/reducers/ide.js b/shared/redux/reducers/ide.js index e14ca741..6d95efc1 100644 --- a/shared/redux/reducers/ide.js +++ b/shared/redux/reducers/ide.js @@ -1 +1,18 @@ -import * as ActionTypes from '../constants/constants'; \ No newline at end of file +import * as ActionTypes from '../constants/constants'; + +const initialState = { + isPlaying: false +} + +const ide = (state = initialState, action) => { + switch (action.type) { + case ActionTypes.TOGGLE_SKETCH: + return { + isPlaying: !state.isPlaying + } + default: + return state + } +} + +export default ide; \ No newline at end of file diff --git a/shared/redux/reducers/index.js b/shared/redux/reducers/index.js index 2b1b8d38..b71c1c64 100644 --- a/shared/redux/reducers/index.js +++ b/shared/redux/reducers/index.js @@ -1,8 +1,10 @@ import { combineReducers } from 'redux' import file from './files' +import ide from './ide' const rootReducer = combineReducers({ - file + file, + ide }) export default rootReducer \ No newline at end of file