fedisearch/application/src/components/Loader.tsx

32 wiersze
711 B
TypeScript
Czysty Zwykły widok Historia

import React, { ReactElement, ReactNode } from 'react'
import Spinner from './Spinner'
2022-01-01 19:37:33 +00:00
export default function Loader ({
showTop,
showBottom,
hideContent,
children,
loading,
placeholder
}: {
children: ReactNode
loading: boolean
hideContent?: boolean
showTop?: boolean
showBottom?: boolean
placeholder?: ReactNode
}): ReactElement {
const spinner = placeholder ?? (
<div className={'d-flex justify-content-center'}>
<Spinner/>
</div>
2022-01-15 19:44:37 +00:00
)
return (
<>
2022-11-03 18:38:01 +00:00
{(showTop ?? false) && loading ? spinner : ''}
{(hideContent ?? false) && loading ? '' : children}
{(showBottom ?? false) && loading ? spinner : ''}
</>
2022-01-01 19:37:33 +00:00
)
}