TechNote/app/reducers/contextMenu.jsx
Joey Payne c1340ef758 Refactor context menu actions and constants
This is in order to accomodate more stateful objects by separating the
context menu specific actions and constants into their own files.
2016-03-05 17:24:23 -07:00

31 lines
765 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
}
}