'use strict';

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

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

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

var _NewBadge2 = _interopRequireDefault(_NewBadge);

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

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

var ListItemContainer = _styledComponents2.default.li.withConfig({
  displayName: 'ListItem__ListItemContainer'
})(['background: ', ';color: ', ';padding: ', ';border-bottom: 1px solid ', ';border-right: 1px solid ', ';position: relative;overflow-x: visible;'], function (_ref) {
  var active = _ref.active,
      theme = _ref.theme;
  return active ? theme.colors.gutter : theme.colors.white;
}, function (_ref2) {
  var active = _ref2.active,
      theme = _ref2.theme;
  return active ? theme.colors.primary : theme.colors.black;
}, function (_ref3) {
  var theme = _ref3.theme;
  return theme.padding.medium + ' ' + theme.padding.large;
}, function (_ref4) {
  var theme = _ref4.theme;
  return theme.colors.borderLight;
}, function (_ref5) {
  var theme = _ref5.theme,
      active = _ref5.active;
  return active ? theme.colors.gutter : theme.colors.borderLight;
});

var ListLabel = _styledComponents2.default.h3.withConfig({
  displayName: 'ListItem__ListLabel'
})(['text-transform: ', ';font-weight: ', ';margin: 0;'], function (_ref6) {
  var theme = _ref6.theme;
  return theme.listItem.textTransform;
}, function (_ref7) {
  var theme = _ref7.theme;
  return theme.listItem.fontWeight;
});

var ListDetails = _styledComponents2.default.div.withConfig({
  displayName: 'ListItem__ListDetails'
})(['']);

var ListItem = function (_React$Component) {
  _inherits(ListItem, _React$Component);

  function ListItem() {
    _classCallCheck(this, ListItem);

    return _possibleConstructorReturn(this, (ListItem.__proto__ || Object.getPrototypeOf(ListItem)).apply(this, arguments));
  }

  _createClass(ListItem, [{
    key: 'render',
    value: function render() {
      var _props = this.props,
          label = _props.label,
          details = _props.details,
          active = _props.active,
          isNew = _props.isNew;


      return _react2.default.createElement(
        ListItemContainer,
        { active: active },
        _react2.default.createElement(
          ListLabel,
          null,
          isNew ? _react2.default.createElement(_NewBadge2.default, null) : null,
          label
        ),
        _react2.default.createElement(
          ListDetails,
          null,
          details
        )
      );
    }
  }]);

  return ListItem;
}(_react2.default.Component);

ListItem.propTypes = {
  label: _propTypes2.default.string,
  details: _propTypes2.default.node,
  active: _propTypes2.default.bool,
  isNew: _propTypes2.default.bool
};
ListItem.defaultProps = {
  label: null,
  details: null,
  active: false,
  isNew: false
};


ListItem.usage = '\n# ListItem\n\nRenders a list item component. Use it inside a List for optimal effect.\n\nProps:\n\n* `label`: the main content\n* `details`: some extra info to render below the label\n* `active`: determines whether the item should render as active or not\n\nTODO: refactor this to use Card.\n\n```\n<ListItem label="hi" active={true} />\n```\n';

exports.default = ListItem;