2021-10-06 04:33:24 -04:00
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
import Icon from './icon'
|
2022-01-11 04:17:56 -05:00
|
|
|
import { useEffect, useState } from 'react'
|
2021-10-06 04:33:24 -04:00
|
|
|
|
2022-04-07 04:58:48 -04:00
|
|
|
function LoadingSpinner({ delay = 0 }) {
|
2021-10-06 04:33:24 -04:00
|
|
|
const { t } = useTranslation()
|
2022-01-11 04:17:56 -05:00
|
|
|
|
|
|
|
const [show, setShow] = useState(false)
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const timer = window.setTimeout(() => {
|
|
|
|
setShow(true)
|
|
|
|
}, delay)
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
window.clearTimeout(timer)
|
|
|
|
}
|
|
|
|
}, [delay])
|
|
|
|
|
|
|
|
if (!show) {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
2021-10-06 04:33:24 -04:00
|
|
|
return (
|
|
|
|
<div className="loading">
|
2022-01-19 06:56:57 -05:00
|
|
|
<Icon type="refresh" fw spin />
|
2022-01-11 04:17:56 -05:00
|
|
|
|
|
|
|
{t('loading')}…
|
2021-10-06 04:33:24 -04:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default LoadingSpinner
|
2023-10-17 04:41:40 -04:00
|
|
|
|
|
|
|
export function FullSizeLoadingSpinner({
|
|
|
|
delay = 0,
|
|
|
|
minHeight,
|
|
|
|
}: {
|
|
|
|
delay?: number
|
|
|
|
minHeight?: string
|
|
|
|
}) {
|
|
|
|
return (
|
|
|
|
<div className="full-size-loading-spinner-container" style={{ minHeight }}>
|
|
|
|
<LoadingSpinner delay={delay} />
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|