2024-06-22 22:06:16 +01:00
|
|
|
import Typography from '@mui/material/Typography';
|
|
|
|
|
import { useState } from 'react';
|
|
|
|
|
import Box from '@mui/material/Box';
|
|
|
|
|
import { useTimeout } from '../hooks';
|
2024-06-19 21:18:35 +01:00
|
|
|
|
|
|
|
|
export type FuseLoadingProps = {
|
|
|
|
|
delay?: number;
|
|
|
|
|
className?: string;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* FuseLoading displays a loading state with an optional delay
|
|
|
|
|
*/
|
|
|
|
|
function FuseLoading(props: FuseLoadingProps) {
|
2024-06-22 22:06:16 +01:00
|
|
|
const { delay = 0, className } = props;
|
|
|
|
|
const [showLoading, setShowLoading] = useState(!delay);
|
2024-06-19 21:18:35 +01:00
|
|
|
|
|
|
|
|
useTimeout(() => {
|
2024-06-22 22:06:16 +01:00
|
|
|
setShowLoading(true);
|
|
|
|
|
}, delay);
|
2024-06-19 21:18:35 +01:00
|
|
|
|
|
|
|
|
return (
|
2024-06-22 22:06:16 +01:00
|
|
|
<div>
|
2024-06-19 21:18:35 +01:00
|
|
|
<Typography
|
2024-06-25 22:09:17 +01:00
|
|
|
className="text-13 sm:text-20 -mb-16 font-medium"
|
2024-06-19 21:18:35 +01:00
|
|
|
color="text.secondary"
|
|
|
|
|
>
|
2024-06-21 20:06:07 +01:00
|
|
|
Loading
|
2024-06-19 21:18:35 +01:00
|
|
|
</Typography>
|
|
|
|
|
<Box
|
|
|
|
|
id="spinner"
|
|
|
|
|
sx={{
|
2024-06-21 20:06:07 +01:00
|
|
|
'& > div': {
|
|
|
|
|
backgroundColor: 'palette.secondary.main'
|
|
|
|
|
}
|
2024-06-19 21:18:35 +01:00
|
|
|
}}
|
|
|
|
|
>
|
2024-06-21 20:06:07 +01:00
|
|
|
<div className="bounce1" />
|
|
|
|
|
<div className="bounce2" />
|
|
|
|
|
<div className="bounce3" />
|
2024-06-19 21:18:35 +01:00
|
|
|
</Box>
|
|
|
|
|
</div>
|
2024-06-22 22:06:16 +01:00
|
|
|
);
|
2024-06-19 21:18:35 +01:00
|
|
|
}
|
|
|
|
|
|
2024-06-22 22:06:16 +01:00
|
|
|
export default FuseLoading;
|