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,
  level: PropTypes.number,
  name: PropTypes.string,
};

const defaultProps = {
  tag: 'div',
  defaultClassName: 'sui-o-secondary-nav__panel',
  className: '',
  level: 1,
  name: '',
};

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

  const classes = classnames(
    defaultClassName,
    className,
    level === 2 ? 'as--level-two' : '',
    level === 3 ? 'as--level-three' : '',
  );

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

SecondaryNavPanel.propTypes = propTypes;
SecondaryNavPanel.defaultProps = defaultProps;
