'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);

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

var _propTypes2 = _interopRequireDefault(_propTypes);

var _styledComponents = require('styled-components');

var _styledComponents2 = _interopRequireDefault(_styledComponents);

var _Icons = require('../Icons');

var _Text = require('../Text');

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

var Wrapper = _styledComponents2.default.div.withConfig({
  displayName: 'ModalHeader__Wrapper'
})(['position:relative;display:flex;justify-content:', ';align-items:center;width:100%;padding:', ';box-sizing:border-box;border-bottom:1px solid ', ';padding-left:', ' !important;padding-right:', ' !important;& >:first-child{margin-right:10px;}'], function (props) {
  return props.center ? 'center' : 'space-between';
}, function (props) {
  return props.tray ? '60px 10%' : '20px 30px';
}, function (props) {
  return props.theme['gray-1'];
}, function (props) {
  return props.paddingHorizontal;
}, function (props) {
  return props.paddingHorizontal;
});
var Header = _styledComponents2.default.div.withConfig({
  displayName: 'ModalHeader__Header'
})(['display:flex;flex-direction:row;justify-content:flex-start;align-items:center;']);
var HeaderIcon = (0, _styledComponents2.default)(_Icons.Icon).withConfig({
  displayName: 'ModalHeader__HeaderIcon'
})(['margin-right:10px;']);

var ModalHeader = function ModalHeader(props) {
  var closeButton = props.closeButton,
      onClose = props.onClose,
      icon = props.icon,
      children = props.children,
      paddingHorizontal = props.paddingHorizontal;


  return _react2.default.createElement(
    Wrapper,
    _extends({ paddingHorizontal: paddingHorizontal, closeButton: closeButton }, props),
    _react2.default.createElement(
      Header,
      null,
      icon && _react2.default.createElement(HeaderIcon, { name: icon, size: '28px', weight: 300, color: 'gray-5' }),
      _react2.default.createElement(
        _Text.Text,
        { size: '20px', weight: 300, color: 'gray-5', capitalize: true },
        children
      )
    ),
    closeButton && _react2.default.createElement(_Icons.Icon, { name: 'close', size: '20px', weight: 300, color: 'gray-5', cursor: true, onClick: onClose })
  );
};

ModalHeader.propTypes = {
  closeButton: _propTypes2.default.bool,
  onClose: _propTypes2.default.func,
  icon: _propTypes2.default.string
};

ModalHeader.defaultProps = {
  closeButton: true
};

exports.default = ModalHeader;