import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';

const propTypes = {
  children: PropTypes.node.isRequired,
  /**
   * The component used for the root node.
   * Either a string to use a DOM element or a component.
   */
  tag: PropTypes.elementType,
  defaultClassName: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
  className: PropTypes.string,
};

const defaultProps = {
  tag: 'a',
  defaultClassName: 'sui-o-secondary-nav__parentlink',
  className: '',
};

export const SecondaryNavParentLink = (props) => {
  const {
    tag: Tag,
    defaultClassName,
    className,
    ...attributes
  } = props;

  const classes = classnames(
    className,
    defaultClassName,
  );

  return (
    <Tag
      className={classes}
      {...attributes}
    />
  );
};

SecondaryNavParentLink.propTypes = propTypes;
SecondaryNavParentLink.defaultProps = defaultProps;
