Files
scratch-gui/src/reducers/editor-tab.js
T
chrisgarrity 44c76e5774 Combine GUI reducers
* Export initial states for each reducer
* combine all gui reducers (excludes scratchPaint and intl)
* combine all initial states to create default guiState for preloading in www
* expect all of the gui state to be accessible at `state.scratchGui`
2018-05-21 16:54:19 -04:00

39 lines
861 B
JavaScript

const ACTIVATE_TAB = 'scratch-gui/navigation/ACTIVATE_TAB';
// Constants use numbers to make it easier to work with react-tabs
const BLOCKS_TAB_INDEX = 0;
const COSTUMES_TAB_INDEX = 1;
const SOUNDS_TAB_INDEX = 2;
const initialState = {
activeTabIndex: BLOCKS_TAB_INDEX
};
const reducer = function (state, action) {
if (typeof state === 'undefined') state = initialState;
switch (action.type) {
case ACTIVATE_TAB:
return Object.assign({}, state, {
activeTabIndex: action.activeTabIndex
});
default:
return state;
}
};
const activateTab = function (tab) {
return {
type: ACTIVATE_TAB,
activeTabIndex: tab
};
};
export {
reducer as default,
initialState as editorTabInitialState,
activateTab,
BLOCKS_TAB_INDEX,
COSTUMES_TAB_INDEX,
SOUNDS_TAB_INDEX
};