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

const propTypes = {
  className: PropTypes.string,
  defaultClassName: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
  color: PropTypes.oneOf(['', 'primary']),
  position: PropTypes.oneOf(['', 'start', 'between', 'end']),
  size: PropTypes.oneOf(['', 'sm', 'lg', 'xl']),
};

const defaultProps = {
  className: '',
  defaultClassName: 'sui-a-loader',
  color: '',
  position: '',
  size: '',
};

export const Loader = ({
  defaultClassName,
  className,
  color,
  size,
  position,
  ...attributes
}) => {
  const classes = classnames(
    defaultClassName,
    modifierCSS(color),
    modifierCSS(position),
    modifierCSS(size),
    className
  );

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

Loader.propTypes = propTypes;
Loader.defaultProps = defaultProps;
