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

var _Icomoon = require('./Icomoon');

var _Icomoon2 = _interopRequireDefault(_Icomoon);

var _ramda = require('ramda');

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 BaseIcon = _styledComponents2.default.span.withConfig({
  displayName: 'Icon__BaseIcon'
})(['font-weight:', ';font-size:', ';color:', ';-webkit-font-smoothing:antialiased;cursor:', ';display:flex;&:before{font-family:\'icomoon\';content:\'', '\';}'], function (props) {
  return props.weight;
}, function (props) {
  return props.size;
}, function (props) {
  return props.theme[props.color];
}, function (props) {
  return props.cursorEnabled ? 'pointer' : 'inherit';
}, function (props) {
  return props.code;
});

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

  var code = _Icomoon2.default[name];

  return _react2.default.createElement(BaseIcon, _extends({}, rest, { code: code, cursorEnabled: cursor }));
};

Icon.propTypes = {
  name: _propTypes2.default.string.isRequired,
  weight: _propTypes2.default.oneOf([100, 200, 300, 400, 500, 600, 700, 800, 900]),
  size: _propTypes2.default.string,
  color: _propTypes2.default.oneOf((0, _ramda.keysIn)((0, _Colors.Palette)())),
  cursor: _propTypes2.default.bool
};

Icon.defaultProps = {
  weight: 400,
  size: '16px',
  color: 'gray-5',
  cursor: false
};

exports.default = Icon;