p5.js-web-editor/client/modules/IDE/reducers/ide.js

64 lines
2.4 KiB
JavaScript
Raw Normal View History

2016-06-22 21:58:23 +02:00
import * as ActionTypes from '../../../constants';
2016-05-11 22:13:17 +02:00
const initialState = {
2016-07-08 20:57:22 +02:00
isPlaying: false,
isTextOutputPlaying: false,
consoleEvent: {
method: undefined,
arguments: []
2016-07-18 01:15:13 +02:00
},
2016-07-14 18:47:54 +02:00
modalIsVisible: false,
2016-09-04 02:47:30 +02:00
sidebarIsExpanded: false,
consoleIsExpanded: false,
2016-08-30 05:23:10 +02:00
preferencesIsVisible: false,
projectOptionsVisible: false,
newFolderModalVisible: false
2016-06-24 00:29:55 +02:00
};
2016-05-11 22:13:17 +02:00
const ide = (state = initialState, action) => {
2016-06-24 00:29:55 +02:00
switch (action.type) {
case ActionTypes.TOGGLE_SKETCH:
2016-07-11 21:22:29 +02:00
return Object.assign({}, state, { isPlaying: !state.isPlaying });
2016-06-24 00:29:55 +02:00
case ActionTypes.START_SKETCH:
2016-07-11 21:22:29 +02:00
return Object.assign({}, state, { isPlaying: true });
2016-06-24 00:29:55 +02:00
case ActionTypes.STOP_SKETCH:
2016-07-11 21:22:29 +02:00
return Object.assign({}, state, { isPlaying: false });
case ActionTypes.START_TEXT_OUTPUT:
return Object.assign({}, state, { isTextOutputPlaying: true });
case ActionTypes.STOP_TEXT_OUTPUT:
return Object.assign({}, state, { isTextOutputPlaying: false });
case ActionTypes.CONSOLE_EVENT:
return Object.assign({}, state, { consoleEvent: action.event });
case ActionTypes.SHOW_MODAL:
return Object.assign({}, state, { modalIsVisible: true });
case ActionTypes.HIDE_MODAL:
return Object.assign({}, state, { modalIsVisible: false });
2016-07-14 18:47:54 +02:00
case ActionTypes.COLLAPSE_SIDEBAR:
return Object.assign({}, state, { sidebarIsExpanded: false });
case ActionTypes.EXPAND_SIDEBAR:
return Object.assign({}, state, { sidebarIsExpanded: true });
case ActionTypes.COLLAPSE_CONSOLE:
return Object.assign({}, state, { consoleIsExpanded: false });
case ActionTypes.EXPAND_CONSOLE:
return Object.assign({}, state, { consoleIsExpanded: true });
case ActionTypes.OPEN_PREFERENCES:
return Object.assign({}, state, { preferencesIsVisible: true });
case ActionTypes.CLOSE_PREFERENCES:
return Object.assign({}, state, { preferencesIsVisible: false });
case ActionTypes.RESET_PROJECT:
return initialState;
2016-08-30 05:23:10 +02:00
case ActionTypes.OPEN_PROJECT_OPTIONS:
return Object.assign({}, state, { projectOptionsVisible: true });
case ActionTypes.CLOSE_PROJECT_OPTIONS:
return Object.assign({}, state, { projectOptionsVisible: false });
case ActionTypes.SHOW_NEW_FOLDER_MODAL:
return Object.assign({}, state, { newFolderModalVisible: true });
case ActionTypes.CLOSE_NEW_FOLDER_MODAL:
return Object.assign({}, state, { newFolderModalVisible: false });
2016-06-24 00:29:55 +02:00
default:
return state;
}
};
2016-05-11 22:13:17 +02:00
2016-06-24 00:29:55 +02:00
export default ide;