@wordpress/interface
Version:
Interface module for WordPress. The package contains shared functionality across the modern JavaScript-based WordPress screens.
68 lines (64 loc) • 1.44 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.activeModal = activeModal;
exports.complementaryAreas = complementaryAreas;
exports.default = void 0;
var _data = require("@wordpress/data");
/**
* WordPress dependencies
*/
function complementaryAreas(state = {}, action) {
switch (action.type) {
case 'SET_DEFAULT_COMPLEMENTARY_AREA':
{
const {
scope,
area
} = action;
// If there's already an area, don't overwrite it.
if (state[scope]) {
return state;
}
return {
...state,
[scope]: area
};
}
case 'ENABLE_COMPLEMENTARY_AREA':
{
const {
scope,
area
} = action;
return {
...state,
[scope]: area
};
}
}
return state;
}
/**
* Reducer for storing the name of the open modal, or null if no modal is open.
*
* @param {Object} state Previous state.
* @param {Object} action Action object containing the `name` of the modal
*
* @return {Object} Updated state
*/
function activeModal(state = null, action) {
switch (action.type) {
case 'OPEN_MODAL':
return action.name;
case 'CLOSE_MODAL':
return null;
}
return state;
}
var _default = exports.default = (0, _data.combineReducers)({
complementaryAreas,
activeModal
});
//# sourceMappingURL=reducer.js.map