'use strict';

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

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 _Button = require('./Button');

var _Button2 = _interopRequireDefault(_Button);

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

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 BaseIconButton = (0, _styledComponents2.default)(_Button2.default).withConfig({
  displayName: 'IconButton__BaseIconButton'
})(['width:auto;min-width:', ';max-width:', ';& >:first-child{margin-right:5px;}'], function (props) {
  return props.min;
}, function (props) {
  return props.max;
});

var selectColor = function selectColor(nature, disabled) {
  if (disabled) {
    return 'white';
  }

  switch (nature) {
    case 'empty':
      return 'gray-6';
    case 'primary':
      return 'white';
    case 'secondary':
      return 'white';
    case 'copy':
      return 'white';
    case 'received':
      return 'white';
    case 'sent':
      return 'white';
    case 'transferred':
      return 'white';
    case 'logout':
      return 'white';
    case 'dark':
      return 'white';
    default:
      return 'gray-6';
  }
};

var IconButton = function IconButton(props) {
  var name = props.name,
      children = props.children,
      rest = _objectWithoutProperties(props, ['name', 'children']);

  var color = selectColor(props.nature);

  return _react2.default.createElement(
    BaseIconButton,
    rest,
    _react2.default.createElement(_Icons.Icon, { name: name, color: color }),
    children
  );
};

_propTypes2.default.propTypes = {
  name: _propTypes2.default.string.isRequired,
  min: _propTypes2.default.string,
  max: _propTypes2.default.string
};

exports.default = IconButton;