You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
portainer/app/react/components/buttons/LoadingButton.tsx

40 lines
796 B

import { PropsWithChildren } from 'react';
import { type Props as ButtonProps, Button } from './Button';
interface Props extends ButtonProps {
loadingText: string;
isLoading: boolean;
}
export function LoadingButton({
loadingText,
isLoading,
disabled,
type = 'submit',
children,
...buttonProps
}: PropsWithChildren<Props>) {
return (
<Button
// eslint-disable-next-line react/jsx-props-no-spreading
{...buttonProps}
type={type}
disabled={disabled || isLoading}
>
{isLoading ? (
<>
<i
className="fa fa-circle-notch fa-spin space-right"
aria-label="loading"
aria-hidden="true"
/>
{loadingText}
</>
) : (
children
)}
</Button>
);
}