ente/web/packages/shared/components/EnteButton.tsx
Manav Rathi c8205b8475
tsc
The only place I can currently find where this code would run is on the delete
account dialog, where props.color is being passed.
2024-05-25 10:02:09 +05:30

44 lines
1.2 KiB
TypeScript

import { ensure } from "@/utils/ensure";
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) => ({
// TODO: Refactor to not need this ensure.
backgroundColor:
theme.palette[ensure(props.color)].main,
color: theme.palette[ensure(props.color)].contrastText,
}),
}),
}}
{...props}
>
{loading ? (
<CircularProgress size={20} sx={{ color: "inherit" }} />
) : success ? (
<Done sx={{ fontSize: 20 }} />
) : (
children
)}
</Button>
);
}