import * as React from 'react';
import { Spinner } from '../spinner';
import { SpinnerSizeEnum } from '../utils';

interface IConditionalSpinnerProps  extends React.HTMLProps<HTMLSpanElement> {
    spinnerSize?: SpinnerSizeEnum;
    color?: string;
    active: boolean;
    children: any,
}

export const ConditionalSpinner = ({ active, children, ...rest }: IConditionalSpinnerProps) => {
    if (active) {
        return <Spinner {...rest} />;
    }

    return <>{children}</>;
};
