mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-24 21:12:38 -04:00
f8efc3e2ae
[web] Implement the editor's left menu in Offcanvas GitOrigin-RevId: 999e995d664b1dc958f56643f05e95b8aa2d6290
82 lines
1.8 KiB
TypeScript
82 lines
1.8 KiB
TypeScript
import { useTranslation } from 'react-i18next'
|
|
import Icon from './icon'
|
|
import { useEffect, useState } from 'react'
|
|
import BootstrapVersionSwitcher from '@/features/ui/components/bootstrap-5/bootstrap-version-switcher'
|
|
import { Spinner } from 'react-bootstrap-5'
|
|
import classNames from 'classnames'
|
|
|
|
function LoadingSpinner({
|
|
align,
|
|
delay = 0,
|
|
loadingText,
|
|
size,
|
|
}: {
|
|
align?: 'left' | 'center'
|
|
delay?: 0 | 500 // 500 is our standard delay
|
|
loadingText?: string
|
|
size?: 'sm'
|
|
}) {
|
|
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
|
|
}
|
|
|
|
const alignmentClass =
|
|
align === 'left' ? 'align-items-start' : 'align-items-center'
|
|
|
|
return (
|
|
<BootstrapVersionSwitcher
|
|
bs3={
|
|
<div className="loading">
|
|
<Icon type="refresh" fw spin />
|
|
|
|
{loadingText || t('loading')}…
|
|
</div>
|
|
}
|
|
bs5={
|
|
<div className={classNames(`d-flex ${alignmentClass}`)}>
|
|
<Spinner
|
|
animation="border"
|
|
aria-hidden="true"
|
|
role="status"
|
|
className="align-self-center"
|
|
size={size}
|
|
/>
|
|
|
|
{loadingText || t('loading')}…
|
|
</div>
|
|
}
|
|
/>
|
|
)
|
|
}
|
|
|
|
export default LoadingSpinner
|
|
|
|
export function FullSizeLoadingSpinner({
|
|
delay = 0,
|
|
minHeight,
|
|
loadingText,
|
|
}: {
|
|
delay?: 0 | 500
|
|
minHeight?: string
|
|
loadingText?: string
|
|
}) {
|
|
return (
|
|
<div className="full-size-loading-spinner-container" style={{ minHeight }}>
|
|
<LoadingSpinner loadingText={loadingText} delay={delay} />
|
|
</div>
|
|
)
|
|
}
|