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

var _icons2 = _interopRequireDefault(_icons);

var _themeGet = require('../../extensions/themeGet');

var _themeGet2 = _interopRequireDefault(_themeGet);

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

var Icon = _styledComponents2.default.i.withConfig({ displayName: 'Icon' }).withConfig({
  displayName: 'Icon'
})(['font-family:', ';font-size:inherit;color:', ';font-style:normal;display:inline-block;cursor:', ';&::before{content:"', '";display:block;color:inherit;}'], (0, _themeGet2.default)('fonts.icon'), function (_ref) {
  var color = _ref.color;
  return color || 'inherit';
}, function (_ref2) {
  var onClick = _ref2.onClick;
  return onClick ? 'pointer' : 'inherit';
}, function (_ref3) {
  var name = _ref3.name,
      iconsHelper = _ref3.iconsHelper;
  return iconsHelper(name) || iconsHelper('help_2');
});

Icon.propTypes = {
  /**
   * The name of the glyph to use (see src/Icon/icons.js)
   */
  name: _propTypes2.default.string.isRequired,
  /**
   * Adds a class name to the element.
   */
  className: _propTypes2.default.string,
  /**
   * Adds an id to the element.
   */
  id: _propTypes2.default.string,
  /**
   * Replace the icon helper function (advanced).
   */
  iconsHelper: _propTypes2.default.func,
  /**
   * Color of the icon
   */
  color: _propTypes2.default.string
};

Icon.defaultProps = {
  className: null,
  id: null,
  iconsHelper: _icons2.default,
  color: null
};

/**
 * @component
 */
exports.default = Icon;