import React from "react";
import StyledLoader from "./StyledLoader";

export type StyledLoaderProps = {
  background?: string;
  color?: string;
  size?:number;
};

type LoaderProps = StyledLoaderProps & {
  loading: boolean;
  props?: any;
};

const Loader: React.FC<LoaderProps> = ({
  background,
  color,
  loading,
  size,
  ...props
}) => {
  if (!loading) return null;

  return <StyledLoader background={background} color={color} size={size} {...props} />;
};

export default Loader;
