import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { modifierCSS } from '../../../helpers';

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

const defaultProps = {
  children: '',
  className: '',
  color: '',
  defaultClassName: 'sui-a-step-indicator__message',
  tag: 'div',
};

export const StepIndicatorMessage = ({
  children,
  className,
  color,
  defaultClassName,
  tag: Tag,
  ...attributes
}) => {
  const classes = classnames(
    className,
    modifierCSS(color),
    defaultClassName,
  );

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

StepIndicatorMessage.propTypes = propTypes;
StepIndicatorMessage.defaultProps = defaultProps;
