webpackHotUpdate(4,{

/***/ "./module/index.js":
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* WEBPACK VAR INJECTION */(function(module) {/* unused harmony export emitter */
/* unused harmony export toggleLeft */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return showLeft; });
/* unused harmony export hideLeft */
/* unused harmony export toggleRight */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return showRight; });
/* unused harmony export hideRight */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__("./node_modules/react/cjs/react.development.js");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_tiny_emitter__ = __webpack_require__("./node_modules/tiny-emitter/index.js");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_tiny_emitter___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_tiny_emitter__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__styles__ = __webpack_require__("./module/styles.js");
var _jsxFileName = '/Users/hakonmartinholmsenkrogh/www/react-layout/module/index.js';

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

(function () {
  var enterModule = __webpack_require__("./node_modules/react-hot-loader/patch.js").enterModule;

  enterModule && enterModule(module);
})();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }






var defaultWidth = '500px';
var marginToTriggerWidthOverride = 40;

var emitter = new __WEBPACK_IMPORTED_MODULE_1_tiny_emitter___default.a();
var showStatus = {
  left: false,
  right: false
};
var speed = 300;
var toggleResolvers = [];

function toggleSide(side, show) {
  if (toggleResolvers.length > 0) {
    toggleResolvers.forEach(function (r) {
      if (!r.handeled) {
        r.resolve(false);
        r.handeled = true;
      }
    });
  }

  return new Promise(function (resolve) {
    if (side === 'both') {
      showStatus.left = false;
      showStatus.right = false;
    } else {
      showStatus[side] = show;
    }

    emitter.emit('toggle', showStatus);

    if (show && document.activeElement) {
      document.activeElement.blur();
    }

    var resolver = {
      type: (show ? 'Show' : 'Hide') + ' ' + side + ' side(s)',
      timeout: setTimeout(function () {
        if (!resolver.handeled) {
          resolver.resolve(true);
        }
        toggleResolvers.splice(toggleResolvers.indexOf(function (r) {
          return r === resolver;
        }), 1);
      }, speed),
      resolve: resolve
    };

    toggleResolvers.push(resolver);
  });
}

var toggleLeft = function toggleLeft() {
  var show = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !showStatus.left;
  return toggleSide('left', show);
};
var showLeft = function showLeft() {
  return toggleLeft(true);
};
var hideLeft = function hideLeft() {
  return toggleLeft(false);
};
var toggleRight = function toggleRight() {
  var show = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !showStatus.right;
  return toggleSide('right', show);
};
var showRight = function showRight() {
  return toggleRight(true);
};
var hideRight = function hideRight() {
  return toggleRight(false);
};

var CrystallizeLayout = function (_Component) {
  _inherits(CrystallizeLayout, _Component);

  function CrystallizeLayout() {
    var _ref;

    var _temp, _this, _ret;

    _classCallCheck(this, CrystallizeLayout);

    for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = CrystallizeLayout.__proto__ || Object.getPrototypeOf(CrystallizeLayout)).call.apply(_ref, [this].concat(args))), _this), _this.state = {
      showLeft: showStatus.left,
      showRight: showStatus.right,
      widthOverride: null
    }, _this.activeWidthOverrides = {
      left: false,
      right: false,
      get any() {
        return this.left || this.right;
      }
    }, _this.startWidthOverride = function (side) {
      if (!_this.activeWidthOverrides.any) {
        _this.handleWindowResize();
        window.addEventListener('resize', _this.handleWindowResize, false);
      }

      _this.activeWidthOverrides[side] = true;
    }, _this.handleWindowResize = function () {
      clearTimeout(_this.widthOverrideSetTimeout);
      _this.widthOverrideSetTimeout = setTimeout(function () {
        _this.setState({
          widthOverride: window.innerWidth - marginToTriggerWidthOverride + 'px'
        });
      }, 25);
    }, _this.stopWidthOverride = function (side) {
      _this.activeWidthOverrides[side] = false;

      if (!_this.activeWidthOverrides.any) {
        window.removeEventListener('resize', _this.handleWindowResize);
        clearTimeout(_this.widthOverrideSetTimeout);
      }
    }, _this.listenForMediaChange = function () {
      var _this$props = _this.props,
          _this$props$width = _this$props.width,
          width = _this$props$width === undefined ? defaultWidth : _this$props$width,
          leftWidth = _this$props.leftWidth,
          rightWidth = _this$props.rightWidth;


      var left = leftWidth || width;
      var right = rightWidth || width;

      _this.leftMql = window.matchMedia('(min-width: ' + (parseInt(left, 10) + marginToTriggerWidthOverride) + 'px)');
      _this.leftMql.addListener(_this.handleLeftMediaChange);
      _this.handleLeftMediaChange(_this.leftMql);

      _this.rightMql = window.matchMedia('(min-width: ' + (parseInt(right, 10) + marginToTriggerWidthOverride) + 'px)');
      _this.rightMql.addListener(_this.handleRightMediaChange);
      _this.handleRightMediaChange(_this.rightMql);
    }, _this.handleLeftMediaChange = function (mql) {
      var theScreenIsTooSmallForMenu = !mql.matches;
      if (theScreenIsTooSmallForMenu) {
        _this.startWidthOverride('left');
      } else {
        _this.stopWidthOverride('left');
      }
    }, _this.handleRightMediaChange = function (mql) {
      var theScreenIsTooSmallForMenu = !mql.matches;
      if (theScreenIsTooSmallForMenu) {
        _this.startWidthOverride('right');
      } else {
        _this.stopWidthOverride('right');
      }
    }, _this.stopListenForMediaChange = function () {
      _this.leftMql.removeListener(_this.handleLeftMediaChange);
      _this.rightMql.removeListener(_this.handleRightMediaChange);
      _this.stopWidthOverride('left');
      _this.stopWidthOverride('right');
    }, _this.onToggle = function (_ref2) {
      var left = _ref2.left,
          right = _ref2.right;

      _this.setState({
        showLeft: left,
        showRight: right
      });

      if (left || right) {
        _this.disableScroll(true);
      } else {
        _this.disableScroll(false);
      }
    }, _this.onOverlayClick = function (e) {
      e.preventDefault();
      toggleSide('both');
    }, _this.renderChildren = function (additionalProps) {
      return __WEBPACK_IMPORTED_MODULE_0_react___default.a.Children.map(_this.props.children, function (child) {
        return __WEBPACK_IMPORTED_MODULE_0_react___default.a.cloneElement(child, additionalProps);
      });
    }, _temp), _possibleConstructorReturn(_this, _ret);
  }

  _createClass(CrystallizeLayout, [{
    key: 'componentDidMount',
    value: function componentDidMount() {
      emitter.on('toggle', this.onToggle);
      speed = parseInt(this.props.speed || 300);
      this.listenForMediaChange();
    }
  }, {
    key: 'componentWillUnmount',
    value: function componentWillUnmount() {
      emitter.off('toggle', this.onToggle);
      this.stopListenForMediaChange();
    }
  }, {
    key: 'disableScroll',
    value: function disableScroll(stop) {
      if (!this.defaultBodyOverflow) {
        var style = getComputedStyle(document.body);
        this.defaultBodyOverflow = style.overflowY;
      }
      document.body.style.overflowY = stop ? 'hidden' : this.defaultBodyOverflow;
    }
  }, {
    key: 'render',
    value: function render() {
      var _props = this.props,
          left = _props.left,
          right = _props.right,
          _props$width = _props.width,
          width = _props$width === undefined ? defaultWidth : _props$width,
          leftWidth = _props.leftWidth,
          rightWidth = _props.rightWidth,
          blurContentOnShow = _props.blurContentOnShow;
      var widthOverride = this.state.widthOverride;


      var leftWidthToUse = this.activeWidthOverrides.left ? widthOverride : leftWidth || width;
      var rightWidthToUse = this.activeWidthOverrides.right ? widthOverride : rightWidth || width;

      var _state = this.state,
          showLeft = _state.showLeft,
          showRight = _state.showRight;


      var contentPushed = '0px';
      if (showLeft) {
        contentPushed = leftWidthToUse;
      } else if (showRight) {
        contentPushed = '-' + rightWidthToUse;
      }

      var LeftCmp = left || null;
      var RightCmp = right || null;

      // Enable the blur content on show prop setting
      var blurContentOnShowProp = blurContentOnShow;
      if (blurContentOnShow && typeof blurContentOnShow === 'boolean') {
        blurContentOnShowProp = '3px';
      }

      return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(
        __WEBPACK_IMPORTED_MODULE_2__styles__["d" /* Outer */],
        {
          showLeft: showLeft,
          showRight: showRight,
          leftWidth: leftWidthToUse,
          rightWidth: rightWidthToUse,
          speed: speed,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 230
          }
        },
        (showLeft || showRight) && __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_2__styles__["a" /* ClickOverlay */], {
          showLeft: showLeft,
          showRight: showRight,
          onClick: this.onOverlayClick,
          speed: speed,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 238
          }
        }),
        __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(
          __WEBPACK_IMPORTED_MODULE_2__styles__["b" /* Content */],
          {
            leftShown: showLeft,
            rightShown: showRight,
            blurContentOnShow: blurContentOnShowProp,
            speed: speed,
            __source: {
              fileName: _jsxFileName,
              lineNumber: 245
            }
          },
          this.renderChildren({
            leftShown: showLeft,
            rightShown: showRight,
            contentPushed: contentPushed
          })
        ),
        LeftCmp && __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(
          __WEBPACK_IMPORTED_MODULE_2__styles__["c" /* Left */],
          { width: leftWidthToUse, show: showLeft, speed: speed, __source: {
              fileName: _jsxFileName,
              lineNumber: 258
            }
          },
          __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(LeftCmp, { shown: showLeft, __source: {
              fileName: _jsxFileName,
              lineNumber: 259
            }
          })
        ),
        RightCmp && __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(
          __WEBPACK_IMPORTED_MODULE_2__styles__["e" /* Right */],
          { width: rightWidthToUse, show: showRight, speed: speed, __source: {
              fileName: _jsxFileName,
              lineNumber: 263
            }
          },
          __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(RightCmp, { shown: showRight, __source: {
              fileName: _jsxFileName,
              lineNumber: 264
            }
          })
        )
      );
    }
  }, {
    key: '__reactstandin__regenerateByEval',
    value: function __reactstandin__regenerateByEval(key, code) {
      this[key] = eval(code);
    }
  }]);

  return CrystallizeLayout;
}(__WEBPACK_IMPORTED_MODULE_0_react__["Component"]);

var _default = CrystallizeLayout;
/* harmony default export */ __webpack_exports__["a"] = (_default);
;

(function () {
  var reactHotLoader = __webpack_require__("./node_modules/react-hot-loader/patch.js").default;

  var leaveModule = __webpack_require__("./node_modules/react-hot-loader/patch.js").leaveModule;

  if (!reactHotLoader) {
    return;
  }

  reactHotLoader.register(defaultWidth, 'defaultWidth', '/Users/hakonmartinholmsenkrogh/www/react-layout/module/index.js');
  reactHotLoader.register(marginToTriggerWidthOverride, 'marginToTriggerWidthOverride', '/Users/hakonmartinholmsenkrogh/www/react-layout/module/index.js');
  reactHotLoader.register(emitter, 'emitter', '/Users/hakonmartinholmsenkrogh/www/react-layout/module/index.js');
  reactHotLoader.register(showStatus, 'showStatus', '/Users/hakonmartinholmsenkrogh/www/react-layout/module/index.js');
  reactHotLoader.register(speed, 'speed', '/Users/hakonmartinholmsenkrogh/www/react-layout/module/index.js');
  reactHotLoader.register(toggleResolvers, 'toggleResolvers', '/Users/hakonmartinholmsenkrogh/www/react-layout/module/index.js');
  reactHotLoader.register(toggleSide, 'toggleSide', '/Users/hakonmartinholmsenkrogh/www/react-layout/module/index.js');
  reactHotLoader.register(toggleLeft, 'toggleLeft', '/Users/hakonmartinholmsenkrogh/www/react-layout/module/index.js');
  reactHotLoader.register(showLeft, 'showLeft', '/Users/hakonmartinholmsenkrogh/www/react-layout/module/index.js');
  reactHotLoader.register(hideLeft, 'hideLeft', '/Users/hakonmartinholmsenkrogh/www/react-layout/module/index.js');
  reactHotLoader.register(toggleRight, 'toggleRight', '/Users/hakonmartinholmsenkrogh/www/react-layout/module/index.js');
  reactHotLoader.register(showRight, 'showRight', '/Users/hakonmartinholmsenkrogh/www/react-layout/module/index.js');
  reactHotLoader.register(hideRight, 'hideRight', '/Users/hakonmartinholmsenkrogh/www/react-layout/module/index.js');
  reactHotLoader.register(CrystallizeLayout, 'CrystallizeLayout', '/Users/hakonmartinholmsenkrogh/www/react-layout/module/index.js');
  reactHotLoader.register(_default, 'default', '/Users/hakonmartinholmsenkrogh/www/react-layout/module/index.js');
  leaveModule(module);
})();

;
/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__("./node_modules/next/node_modules/webpack/buildin/harmony-module.js")(module)))

/***/ })

})
//# sourceMappingURL=4.37ec15f7c763f9e5654e.hot-update.js.map