mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-21 08:59:22 +01:00
Integrated update experience (#259)
This commit is contained in:
25
src-web/components/core/ButtonInfiniteLoading.tsx
Normal file
25
src-web/components/core/ButtonInfiniteLoading.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import { useState } from 'react';
|
||||
import type { ButtonProps } from './Button';
|
||||
import { Button } from './Button';
|
||||
|
||||
export function ButtonInfiniteLoading({
|
||||
onClick,
|
||||
isLoading,
|
||||
loadingChildren,
|
||||
children,
|
||||
...props
|
||||
}: ButtonProps & { loadingChildren?: string }) {
|
||||
const [localIsLoading, setLocalIsLoading] = useState<boolean>(false);
|
||||
return (
|
||||
<Button
|
||||
isLoading={localIsLoading || isLoading}
|
||||
onClick={(e) => {
|
||||
setLocalIsLoading(true);
|
||||
onClick?.(e);
|
||||
}}
|
||||
{...props}
|
||||
>
|
||||
{localIsLoading ? (loadingChildren ?? children) : children}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user