'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 _reactRouter = require('react-router');

var _style = require('./style.scss');

var _style2 = _interopRequireDefault(_style);

var _bind = require('classnames/bind');

var _bind2 = _interopRequireDefault(_bind);

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

var ButtonAnchor = function ButtonAnchor(props) {
  var cx = _bind2.default.bind(_style2.default);
  var collapseClass = props.collapse ? 'collapse' : null;
  var btnAnchorClasses = cx(_style2.default.btn, props.optClass, props.size, collapseClass);

  var buttonAnchor = void 0;

  if (props.internal) {
    buttonAnchor = _react2.default.createElement(
      _reactRouter.Link,
      _extends({ to: props.path, className: btnAnchorClasses }, props),
      props.children
    );
  } else {
    buttonAnchor = _react2.default.createElement(
      'a',
      _extends({ href: props.path, className: btnAnchorClasses }, props),
      props.children
    );
  }
  return buttonAnchor;
};

ButtonAnchor.propTypes = {
  /**
   * Optional styles to add to the button.
   */
  optClass: _react2.default.PropTypes.string,
  /**
   * The size of button.
   */
  size: _react2.default.PropTypes.string,
  /**
   * Whether the button is disabled.
   */
  disabled: _react2.default.PropTypes.bool,
  /**
   * A path to pass to the anchor tag.
   */
  path: _react2.default.PropTypes.string,
  /**
   * Whether the link it to an internal page, or external (default)
   */
  internal: _react2.default.PropTypes.bool,
  /**
   * Whether to display only an icon on small screens
   */
  collapse: _react2.default.PropTypes.bool
};

exports.default = ButtonAnchor;