@fremtind/jkl-react-hooks
Version:
Jøkul react button components
51 lines (50 loc) • 1.74 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var ActionType = /* @__PURE__ */ ((ActionType2) => {
ActionType2["orientation"] = "ORIENTATION_CHANGED";
ActionType2["deviceSize"] = "DEVICE_SIZE_CHANGED";
return ActionType2;
})(ActionType || {});
function setDeviceSize(deviceSize) {
return {
isSmallDevice: deviceSize === "isSmallDevice",
isMediumDevice: deviceSize === "isMediumDevice",
isLargeDevice: deviceSize === "isLargeDevice",
isXlDevice: deviceSize === "isXlDevice"
};
}
function setOrientation(orientation) {
return {
isLandscape: orientation === "isLandscape",
isPortrait: orientation === "isPortrait"
};
}
const reducer = (state, action) => {
switch (action.type) {
case "ORIENTATION_CHANGED" /* orientation */:
return __spreadValues(__spreadValues({}, state), setOrientation(action.property));
case "DEVICE_SIZE_CHANGED" /* deviceSize */:
return __spreadValues(__spreadValues({}, state), setDeviceSize(action.property));
default:
return state;
}
};
export {
ActionType,
reducer
};
//# sourceMappingURL=state.js.map