feat: add loading state to FilledButton (#7650)

This commit is contained in:
David Luzar
2024-02-03 14:53:31 +01:00
committed by GitHub
parent d67eaa8710
commit a289c42830
8 changed files with 119 additions and 31 deletions
@@ -6,6 +6,7 @@ import { useExcalidrawContainer } from "./App";
import { AbortError } from "../errors";
import Spinner from "./Spinner";
import { PointerType } from "../element/types";
import { isPromiseLike } from "../utils";
export type ToolButtonSize = "small" | "medium";
@@ -65,7 +66,7 @@ export const ToolButton = React.forwardRef((props: ToolButtonProps, ref) => {
const onClick = async (event: React.MouseEvent) => {
const ret = "onClick" in props && props.onClick?.(event);
if (ret && "then" in ret) {
if (isPromiseLike(ret)) {
try {
setIsLoading(true);
await ret;