Add global state and right click menu using redux

This commit is contained in:
Joey Payne 2016-02-19 12:48:47 -07:00
commit 54d64cc124
10 changed files with 190 additions and 81 deletions

View file

@ -0,0 +1,31 @@
import { UPDATE_CONTEXT_MENU, OPEN_CONTEXT_MENU, CLOSE_CONTEXT_MENU } from '../constants'
const initialState =
{
opened: false,
x: 0,
y: 0,
items: []
}
export default function contextMenu(state = initialState, action){
switch (action.type) {
case UPDATE_CONTEXT_MENU:
return Object.assign({}, state,{
items: action.items
})
case OPEN_CONTEXT_MENU:
return Object.assign({}, state, {
opened: true,
x: action.x,
y: action.y
})
case CLOSE_CONTEXT_MENU:
return Object.assign({}, state, {
opened: false
})
default:
return state
}
}

8
app/reducers/index.jsx Normal file
View file

@ -0,0 +1,8 @@
import { combineReducers } from 'redux'
import contextMenu from './contextMenu'
const rootReducer = combineReducers({
contextMenu
})
export default rootReducer