UNPKG

@zohodesk/hooks

Version:

Unified Component Library - Hooks

27 lines (23 loc) 491 B
import * as CONST from "./constants"; export default function reducer() { let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; let action = arguments.length > 1 ? arguments[1] : undefined; switch (action.type) { case CONST.OPEN: { return true; } case CONST.CLOSE: { return false; } case CONST.TOGGLE: { return !state; } default: { return state; } } }