-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add loading state everywhere is wallet triggering
- Loading branch information
Showing
8 changed files
with
92 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,37 @@ | ||
import { Button, CircularProgress } from '@mui/material'; | ||
import type { ButtonProps } from '@mui/material'; | ||
import { Button, CircularProgress } from "@mui/material"; | ||
import type { ButtonProps, SxProps } from "@mui/material"; | ||
|
||
export type ButtonIntent = 'primary' | 'secondary'; | ||
export interface ExtendedButtonProps extends Omit<ButtonProps, 'size'> { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- conflicting event types for form and button event handlers | ||
onClick?: (e?: any) => void; | ||
interface Props extends Omit<ButtonProps, "size" | "sx"> { | ||
isLoading?: boolean; | ||
size?: "small" | "medium" | "large" | "extraLarge"; | ||
sx?: SxProps; | ||
} | ||
|
||
interface Props extends ExtendedButtonProps { | ||
isLoading: boolean; | ||
} | ||
export const LoadingButton = ({ | ||
isLoading, | ||
disabled, | ||
children, | ||
size = "large", | ||
sx, | ||
...rest | ||
}: Props) => { | ||
const buttonHeight = { | ||
extraLarge: 48, | ||
large: 40, | ||
medium: 36, | ||
small: 32, | ||
}[size]; | ||
|
||
export const LoadingButton = ({ isLoading, disabled, children, ...rest }: Props) => { | ||
return ( | ||
<Button disabled={disabled || isLoading} {...rest}> | ||
{isLoading ? ( | ||
<CircularProgress /> | ||
) : ( | ||
children | ||
<Button | ||
disabled={disabled || isLoading} | ||
sx={{ height: buttonHeight, ...sx }} | ||
{...rest} | ||
> | ||
{isLoading && ( | ||
<CircularProgress size={26} sx={{ position: "absolute" }} /> | ||
)} | ||
{children} | ||
</Button> | ||
); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters