'use strict';

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

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

var Overlay = function Overlay(props) {
  var getStyles = function getStyles() {
    var style = {
      position: 'fixed',
      height: '100%',
      width: '100%',
      top: 0,
      left: '-100%',
      opacity: 0,
      backgroundColor: 'rgba(0, 0, 0, 0.6)',
      WebkitTapHighlightColor: 'rgba(0, 0, 0, 0)', // Remove mobile color flashing (deprecated)
      willChange: 'opacity',
      transform: 'translateZ(0)',
      zIndex: 1400,
      transition: 'left 0ms cubic-bezier(0.46, 0.03, 0.52, 0.96) 400ms, opacity 400ms cubic-bezier(0.46, 0.03, 0.52, 0.96) 0ms'
    };

    document.body.style.removeProperty('overflow');

    if (props.show) {
      document.body.style.overflow = 'hidden';
      style.left = 0;
      style.opacity = 0.6;
      style.transition = 'left 0ms cubic-bezier(0.46, 0.03, 0.52, 0.96) 0ms, opacity 400ms cubic-bezier(0.46, 0.03, 0.52, 0.96) 0ms';
    }

    return style;
  };

  var style = getStyles();

  var show = props.show;

  var other = _objectWithoutProperties(props, ['show']);

  return _react2.default.createElement('div', _extends({}, other, { style: style }));
};

Overlay.propTypes = {
  show: _react2.default.PropTypes.bool.isRequired
};

Overlay.defaultProps = {
  show: false
};

exports.default = Overlay;