'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = undefined;

var _defineProperty2 = require('babel-runtime/helpers/defineProperty');

var _defineProperty3 = _interopRequireDefault(_defineProperty2);

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

var _dec, _class, _class2, _temp;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _classnames2 = require('classnames');

var _classnames3 = _interopRequireDefault(_classnames2);

var _lib = require('@instructure/ui-themeable/lib');

var _lib2 = _interopRequireDefault(_lib);

var _theme = require('./theme');

var _theme2 = _interopRequireDefault(_theme);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var styles = {
  template: function template(theme) {
    return '/*  imported from styles.css  */\n\n.Page__styles__wrapper {\n  display: flex;\n  font-family: ' + theme.fontFamily + ';\n  height: 100%;\n  margin: 0;\n}\n\n@media screen and (--phoneBreakPoint) {\n  .Page__styles__content {\n    -webkit-overflow-scrolling: touch;\n  }\n}\n\n.Page__styles__content {\n  transition: transform 0.3s;\n  width: 100%;\n}\n\n.Page__styles__scrollable {\n  overflow-x: hidden;\n  overflow-y: auto;\n}\n';
  },
  'wrapper': 'Page__styles__wrapper',
  'content': 'Page__styles__content',
  'scrollable': 'Page__styles__scrollable'
};
var Page = (_dec = (0, _lib2.default)(_theme2.default, styles), _dec(_class = (_temp = _class2 = function (_Component) {
  (0, _inherits3.default)(Page, _Component);

  function Page() {
    (0, _classCallCheck3.default)(this, Page);
    return (0, _possibleConstructorReturn3.default)(this, (Page.__proto__ || Object.getPrototypeOf(Page)).apply(this, arguments));
  }

  (0, _createClass3.default)(Page, [{
    key: 'shouldRenderSidebar',
    value: function shouldRenderSidebar() {
      return this.props.sidebarComponent != null && this.props.sidebarOpen != null;
    }
  }, {
    key: 'renderSidebar',
    value: function renderSidebar() {
      return _react2.default.createElement(this.props.sidebarComponent, {
        role: this.props.sidebarRole,
        sidebarOpen: this.props.sidebarOpen,
        toggleSidebar: this.props.toggleSidebar
      });
    }
  }, {
    key: 'render',
    value: function render() {
      var childrenWrapperStyles = (0, _classnames3.default)(styles.content, (0, _defineProperty3.default)({}, styles.scrollable, this.shouldRenderSidebar()));

      return _react2.default.createElement(
        'div',
        { className: styles.wrapper },
        this.shouldRenderSidebar() ? this.renderSidebar() : null,
        _react2.default.createElement(
          'div',
          { role: this.props.contentRole, className: childrenWrapperStyles },
          this.props.children
        )
      );
    }
  }]);
  Page.displayName = 'Page'
  ;
  return Page;
}(_react.Component), _class2.propTypes = {
  children: _propTypes2.default.node.isRequired,
  contentRole: _propTypes2.default.string,
  sidebarComponent: _propTypes2.default.func,
  sidebarOpen: _propTypes2.default.bool,
  sidebarRole: _propTypes2.default.string,
  toggleSidebar: _propTypes2.default.func
}, _class2.defaultProps = {
  contentRole: 'main',
  sidebarComponent: null,
  sidebarOpen: null,
  sidebarRole: 'navigation',
  toggleSidebar: function toggleSidebar() {}
}, _temp)) || _class);
exports.default = Page;