ente/web/packages/shared/components/EnteButton.tsx
Manav Rathi b26b0759d6
tsc
2024-05-25 07:10:47 +05:30

41 lines
1.0 KiB
TypeScript

import Done from "@mui/icons-material/Done";
import { Button, CircularProgress, type ButtonProps } from "@mui/material";
interface Iprops extends ButtonProps {
loading?: boolean;
success?: boolean;
}
export default function EnteButton({
children,
loading,
success,
disabled,
sx,
...props
}: Iprops) {
return (
<Button
disabled={disabled}
sx={{
...sx,
...((loading || success) && {
"&.Mui-disabled": (theme) => ({
backgroundColor: theme.palette[props.color].main,
color: theme.palette[props.color].contrastText,
}),
}),
}}
{...props}
>
{loading ? (
<CircularProgress size={20} sx={{ color: "inherit" }} />
) : success ? (
<Done sx={{ fontSize: 20 }} />
) : (
children
)}
</Button>
);
}