'use strict';

exports.__esModule = 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 _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _Icon = require('../../base/Icon');

var _Icon2 = _interopRequireDefault(_Icon);

require('./style.css');

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

var SocialLinks = function SocialLinks(socialLinks) {
  return _react2.default.createElement(
    'section',
    { className: 'ma__social-links' },
    socialLinks.label && _react2.default.createElement(
      'span',
      { className: 'ma__social-links__label' },
      socialLinks.label
    ),
    _react2.default.createElement(
      'ul',
      { className: 'ma__social-links__items' },
      socialLinks.items.map(function (socialLink, i) {
        return (
          /* eslint-disable-next-line react/no-array-index-key */
          _react2.default.createElement(SocialLink, _extends({}, socialLink, { key: 'socialLink_' + i, index: i }))
        );
      })
    )
  );
};

var SocialLink = function SocialLink(socialLink) {
  return _react2.default.createElement(
    'li',
    { className: 'ma__social-links__item' },
    _react2.default.createElement(
      'a',
      {
        href: socialLink.href,
        className: 'ma__social-links__link js-social-share',
        'data-social-share': socialLink.linkType,
        'aria-label': socialLink.altText
      },
      _react2.default.createElement(_Icon2.default, { name: socialLink.linkType })
    )
  );
};

SocialLink.propTypes = process.env.NODE_ENV !== "production" ? {
  /** The URL for the link */
  href: _propTypes2.default.string.isRequired,
  /** The type of social link and the icon name */
  linkType: _propTypes2.default.oneOf(['facebook', 'twitter', 'linkedin', 'youtube', 'instagram']).isRequired,
  /** Alt text for accessibility */
  altText: _propTypes2.default.string.isRequired
} : {};

SocialLinks.propTypes = process.env.NODE_ENV !== "production" ? {
  /** The optional label for the social links */
  label: _propTypes2.default.string,
  /** The social links to display */
  items: _propTypes2.default.arrayOf(_propTypes2.default.shape(SocialLink.propTypes)).isRequired
} : {};

SocialLinks.defaultProps = {
  label: ''
};

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