'use strict';

exports.__esModule = true;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _classnames = require('classnames');

var _classnames2 = _interopRequireDefault(_classnames);

require('./style.css');

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

var ArrowButton = function ArrowButton(props) {
  var _classNames;

  var buttonClasses = (0, _classnames2.default)((_classNames = {
    'ma__arrow-button': true
  }, _classNames['ma__arrow-button--' + props.direction] = props.direction, _classNames['ma__arrow-button--left'] = !props.direction, _classNames));
  var Element = props.href ? 'a' : 'button';
  var onClickCallback = function onClickCallback(e) {
    if (typeof props.onClick === 'function') {
      e.preventDefault();
      props.onClick(e);
    }
  };

  return _react2.default.createElement(Element, {
    className: buttonClasses,
    onClick: function onClick(e) {
      return onClickCallback(e);
    },
    href: props.href,
    title: props.info,
    'aria-label': props.info
  });
};

ArrowButton.propTypes = process.env.NODE_ENV !== "production" ? {
  /** Custom click handler function. */
  onClick: _propTypes2.default.func,
  /** When populated with a url, this component renders a <a> vs a <button> */
  href: _propTypes2.default.string,
  /** The text which renders in the standard browser tooltip on hover */
  info: _propTypes2.default.string,
  /** Direction of the arrow. */
  direction: _propTypes2.default.oneOf(['left', 'right'])
} : {};

ArrowButton.defaultProps = {
  onClick: '',
  href: '',
  info: '',
  direction: 'left'
};

exports.default = ArrowButton;
module.exports = exports['default'];