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

const propTypes = {
  isLoading: PropTypes.bool,
  tag: PropTypes.elementType,
};

const defaultProps = {
  isLoading: false,
  tag: 'div',
};

export const PageLoader = ({ isLoading, tag: Tag }) => {
  if (!isLoading) {
    return '';
  }

  return (
    <Tag className="sui-l-page-loader" />
  );
};

PageLoader.propTypes = propTypes;
PageLoader.defaultProps = defaultProps;
