2024-09-11 11:27:50 +00:00
|
|
|
import { createPortal } from 'react-dom'
|
2024-02-28 16:49:44 +00:00
|
|
|
import styles from './style.module.scss'
|
|
|
|
|
|
|
|
interface Props {
|
2024-08-30 10:28:33 +00:00
|
|
|
desc?: string
|
|
|
|
variant?: 'small' | 'default'
|
2024-02-28 16:49:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const LoadingSpinner = (props: Props) => {
|
2024-08-30 10:28:33 +00:00
|
|
|
const { desc, variant = 'default' } = props
|
2024-02-28 16:49:44 +00:00
|
|
|
|
2024-08-30 10:28:33 +00:00
|
|
|
switch (variant) {
|
|
|
|
case 'small':
|
|
|
|
return (
|
|
|
|
<div
|
2024-09-02 10:49:51 +00:00
|
|
|
className={`${styles.loadingSpinnerContainer}`}
|
|
|
|
data-variant={variant}
|
2024-08-30 10:28:33 +00:00
|
|
|
>
|
|
|
|
<div className={styles.loadingSpinner}></div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
|
|
|
|
default:
|
2024-09-11 11:27:50 +00:00
|
|
|
return createPortal(
|
2024-08-30 10:28:33 +00:00
|
|
|
<div className={styles.loadingSpinnerOverlay}>
|
2024-09-02 10:49:51 +00:00
|
|
|
<div
|
|
|
|
className={styles.loadingSpinnerContainer}
|
|
|
|
data-variant={variant}
|
|
|
|
>
|
2024-08-30 10:28:33 +00:00
|
|
|
<div className={styles.loadingSpinner}></div>
|
2024-09-02 10:49:51 +00:00
|
|
|
{desc && <p className={styles.loadingSpinnerDesc}>{desc}</p>}
|
2024-08-30 10:28:33 +00:00
|
|
|
</div>
|
2024-09-11 11:27:50 +00:00
|
|
|
</div>,
|
|
|
|
document.getElementById('root')!
|
2024-08-30 10:28:33 +00:00
|
|
|
)
|
|
|
|
}
|
2024-02-28 16:49:44 +00:00
|
|
|
}
|