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'
|
2024-09-25 09:46:02 -04:00
|
|
|
import BootstrapVersionSwitcher from '@/features/ui/components/bootstrap-5/bootstrap-version-switcher'
|
|
|
|
import { Spinner } from 'react-bootstrap-5'
|
2021-10-06 04:33:24 -04:00
|
|
|
|
2024-02-06 10:19:37 -05:00
|
|
|
function LoadingSpinner({
|
|
|
|
delay = 0,
|
|
|
|
loadingText,
|
|
|
|
}: {
|
|
|
|
delay?: 0 | 500 // 500 is our standard delay
|
|
|
|
loadingText?: string
|
|
|
|
}) {
|
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 (
|
2024-09-25 09:46:02 -04:00
|
|
|
<BootstrapVersionSwitcher
|
|
|
|
bs3={
|
|
|
|
<div className="loading">
|
|
|
|
<Icon type="refresh" fw spin />
|
|
|
|
|
|
|
|
{loadingText || t('loading')}…
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
bs5={
|
|
|
|
<div className="text-center mt-4">
|
|
|
|
<Spinner
|
|
|
|
animation="border"
|
|
|
|
aria-hidden="true"
|
|
|
|
role="status"
|
|
|
|
className="align-bottom"
|
|
|
|
/>
|
|
|
|
|
|
|
|
{loadingText || t('loading')}…
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
/>
|
2021-10-06 04:33:24 -04:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default LoadingSpinner
|
2023-10-17 04:41:40 -04:00
|
|
|
|
|
|
|
export function FullSizeLoadingSpinner({
|
|
|
|
delay = 0,
|
|
|
|
minHeight,
|
2024-02-06 10:19:37 -05:00
|
|
|
loadingText,
|
2023-10-17 04:41:40 -04:00
|
|
|
}: {
|
2024-02-06 10:19:37 -05:00
|
|
|
delay?: 0 | 500
|
2023-10-17 04:41:40 -04:00
|
|
|
minHeight?: string
|
2024-02-06 10:19:37 -05:00
|
|
|
loadingText?: string
|
2023-10-17 04:41:40 -04:00
|
|
|
}) {
|
|
|
|
return (
|
|
|
|
<div className="full-size-loading-spinner-container" style={{ minHeight }}>
|
2024-02-06 10:19:37 -05:00
|
|
|
<LoadingSpinner loadingText={loadingText} delay={delay} />
|
2023-10-17 04:41:40 -04:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|