'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 _themeGet = require('../../extensions/themeGet');

var _themeGet2 = _interopRequireDefault(_themeGet);

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

var processMethod = function processMethod(method) {
  var normalized = method.toLowerCase();
  if (normalized === 'delete') {
    return 'del';
  }
  return normalized;
};

var methodColors = {
  post: (0, _themeGet2.default)('colors.primary.default'),
  get: (0, _themeGet2.default)('colors.positive.default'),
  put: (0, _themeGet2.default)('colors.accents[0].default'),
  del: (0, _themeGet2.default)('colors.negative.default')
};

var MethodTag = _styledComponents2.default.pre.withConfig({
  displayName: 'MethodTag'
})(['color:', ';font-size:1em;line-height:1em;padding:0.5em 1em;border-radius:5px;text-transform:uppercase;margin:0;width:auto;display:inline-block;background:', ';'], (0, _themeGet2.default)('colors.text.inverted'), function (props) {
  var method = processMethod(props.children);
  return methodColors[method](props);
});

MethodTag.propTypes = {
  /**
   * Adds a class name to the element.
   */
  className: _propTypes2.default.string,
  /**
   * Adds an id to the element.
   */
  id: _propTypes2.default.string
};

MethodTag.defaultProps = {
  className: null,
  id: null
};

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