TechNote/app/reducers/contextMenu.jsx
Joey Payne d14eed9965 Add state for navigation
Currently selected navigation item is available under the navigation
variable so that the whole application has access to it.
2016-03-06 11:08:42 -07:00

30 lines
761 B
JavaScript

import { UPDATE_CONTEXT_MENU, OPEN_CONTEXT_MENU, CLOSE_CONTEXT_MENU } from '../constants/contextMenu'
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
}
}