mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
c597444179
GitOrigin-RevId: d45d155277a7fc4fbd137f8c640e4a22b1b82399
47 lines
871 B
TypeScript
47 lines
871 B
TypeScript
import { useTranslation } from 'react-i18next'
|
|
import Icon from './icon'
|
|
import { useEffect, useState } from 'react'
|
|
|
|
function LoadingSpinner({ delay = 0 }) {
|
|
const { t } = useTranslation()
|
|
|
|
const [show, setShow] = useState(false)
|
|
|
|
useEffect(() => {
|
|
const timer = window.setTimeout(() => {
|
|
setShow(true)
|
|
}, delay)
|
|
|
|
return () => {
|
|
window.clearTimeout(timer)
|
|
}
|
|
}, [delay])
|
|
|
|
if (!show) {
|
|
return null
|
|
}
|
|
|
|
return (
|
|
<div className="loading">
|
|
<Icon type="refresh" fw spin />
|
|
|
|
{t('loading')}…
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default LoadingSpinner
|
|
|
|
export function FullSizeLoadingSpinner({
|
|
delay = 0,
|
|
minHeight,
|
|
}: {
|
|
delay?: number
|
|
minHeight?: string
|
|
}) {
|
|
return (
|
|
<div className="full-size-loading-spinner-container" style={{ minHeight }}>
|
|
<LoadingSpinner delay={delay} />
|
|
</div>
|
|
)
|
|
}
|