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; };

import React from 'react';
import PropTypes from 'prop-types';
import Icon from '../../base/Icon';

import './style.css';

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

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

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

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

SocialLinks.defaultProps = {
  label: ''
};

export default SocialLinks;