2019-06-23 06:25:38 +00:00
|
|
|
import React from 'react';
|
2019-08-17 23:03:10 +00:00
|
|
|
import Spinner, { SpinnerSize } from '@/components/elements/Spinner';
|
2020-07-04 19:39:55 +00:00
|
|
|
import Fade from '@/components/elements/Fade';
|
|
|
|
import tw from 'twin.macro';
|
2019-06-23 06:25:38 +00:00
|
|
|
|
2019-08-17 23:03:10 +00:00
|
|
|
interface Props {
|
|
|
|
visible: boolean;
|
|
|
|
fixed?: boolean;
|
|
|
|
size?: SpinnerSize;
|
|
|
|
backgroundOpacity?: number;
|
|
|
|
}
|
|
|
|
|
2020-07-11 22:45:28 +00:00
|
|
|
const SpinnerOverlay: React.FC<Props> = ({ size, fixed, visible, backgroundOpacity, children }) => (
|
2020-07-04 19:39:55 +00:00
|
|
|
<Fade timeout={150} in={visible} unmountOnExit>
|
2019-06-23 06:25:38 +00:00
|
|
|
<div
|
2020-07-04 19:39:55 +00:00
|
|
|
css={[
|
2021-08-04 02:46:00 +00:00
|
|
|
tw`top-0 left-0 flex items-center justify-center w-full h-full rounded flex-col z-40`,
|
2020-07-04 19:39:55 +00:00
|
|
|
!fixed ? tw`absolute` : tw`fixed`,
|
|
|
|
]}
|
2021-08-04 02:46:00 +00:00
|
|
|
style={{ background: `rgba(0, 0, 0, ${backgroundOpacity || 0.45})` }}
|
2019-06-23 06:25:38 +00:00
|
|
|
>
|
2019-08-17 23:03:10 +00:00
|
|
|
<Spinner size={size}/>
|
2020-07-11 22:45:28 +00:00
|
|
|
{children && (typeof children === 'string' ? <p css={tw`mt-4 text-neutral-400`}>{children}</p> : children)}
|
2019-06-23 06:25:38 +00:00
|
|
|
</div>
|
2020-07-04 19:39:55 +00:00
|
|
|
</Fade>
|
2019-06-23 06:25:38 +00:00
|
|
|
);
|
2020-02-08 23:23:08 +00:00
|
|
|
|
|
|
|
export default SpinnerOverlay;
|