'use strict';

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

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 _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 _classnames = require('classnames');

var _classnames2 = _interopRequireDefault(_classnames);

var _card = require('kitten/hoc/card');

var _marger = require('kitten/components/layout/marger');

var _clockIcon = require('kitten/components/icons/clock-icon');

var _paragraph = require('kitten/components/typography/paragraph');

var _buttonIcon = require('kitten/components/buttons/button-icon');

var _separator = require('kitten/components/layout/separator');

var _arrowIcon = require('kitten/components/icons/arrow-icon');

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 ProjectCreatorCardComponent = function (_React$Component) {
  _inherits(ProjectCreatorCardComponent, _React$Component);

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

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

  _createClass(ProjectCreatorCardComponent, [{
    key: 'renderDate',
    value: function renderDate() {
      if (!this.props.date) return;

      return _react2.default.createElement(
        'div',
        { className: 'k-ProjectCreatorCard__content' },
        _react2.default.createElement(_clockIcon.ClockIcon, { width: '10px', height: '10px' }),
        _react2.default.createElement(
          'span',
          { className: 'k-ProjectCreatorCard__date' },
          this.props.date
        )
      );
    }
  }, {
    key: 'renderStatus',
    value: function renderStatus() {
      if (!this.props.statusText) return;

      var _props = this.props,
          statusBackgroundColor = _props.statusBackgroundColor,
          statusBorderColor = _props.statusBorderColor,
          statusText = _props.statusText;


      var statusStyles = {
        backgroundColor: statusBackgroundColor,
        borderColor: statusBorderColor ? statusBorderColor : statusBackgroundColor
      };

      return _react2.default.createElement(
        'div',
        { className: 'k-ProjectCreatorCard__status' },
        _react2.default.createElement('span', {
          className: 'k-ProjectCreatorCard__status--icon',
          style: statusStyles
        }),
        _react2.default.createElement(
          'div',
          { className: 'k-ProjectCreatorCard__status--text' },
          statusText
        )
      );
    }
  }, {
    key: 'renderDescription',
    value: function renderDescription() {
      return _react2.default.createElement(
        'div',
        { className: 'k-ProjectCreatorCard__grid' },
        _react2.default.createElement(
          _marger.Marger,
          { top: '2', bottom: '1' },
          _react2.default.createElement(
            'div',
            { className: 'k-ProjectCreatorCard__grid--flexEnd' },
            this.renderDate(),
            this.renderStatus()
          )
        ),
        _react2.default.createElement(
          _marger.Marger,
          { top: '1', bottom: '2' },
          _react2.default.createElement(
            _paragraph.Paragraph,
            { margin: false },
            this.props.children
          )
        )
      );
    }
  }, {
    key: 'renderLink',
    value: function renderLink() {
      if (!this.props.href) return;

      var target = this.props.isExternal ? { target: '_blank' } : {};

      return _react2.default.createElement(
        'a',
        _extends({
          className: 'k-ProjectCreatorCard__link',
          href: this.props.href
        }, target),
        _react2.default.createElement(_separator.Separator, { darker: true }),
        _react2.default.createElement(
          'div',
          { className: 'k-ProjectCreatorCard__grid' },
          _react2.default.createElement(
            _marger.Marger,
            {
              top: '1.2',
              bottom: '1.2',
              className: 'k-ProjectCreatorCard__grid--flex'
            },
            this.props.linkText,
            _react2.default.createElement(
              _buttonIcon.ButtonIcon,
              { size: 'tiny', withoutHover: true, verticalArrow: true },
              _react2.default.createElement(_arrowIcon.ArrowIcon, { className: 'k-ButtonIcon__svg' })
            )
          )
        )
      );
    }
  }, {
    key: 'render',
    value: function render() {
      var ProjectCreatorCardClassName = (0, _classnames2.default)('k-ProjectCreatorCard', this.props.className);

      return _react2.default.createElement(
        'div',
        { className: ProjectCreatorCardClassName },
        this.renderDescription(),
        this.renderLink()
      );
    }
  }]);

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

var ProjectCreatorCard = exports.ProjectCreatorCard = function ProjectCreatorCard(props) {
  var ProjectCreatorCardContent = (0, _card.card)(ProjectCreatorCardComponent);
  return _react2.default.createElement(ProjectCreatorCardContent, _extends({
    withDarkBorder: !!props.href,
    light: true,
    withBorder: true,
    withShadow: false,
    translateOnHover: true,
    rounded: 'tiny'
  }, props));
};

ProjectCreatorCard.defaultProps = {
  date: null,
  children: null,
  href: null,
  isExternal: false,
  linkText: null,
  statusBackgroundColor: null,
  statusBorderColor: null,
  statusText: 'Status'
};