misc_pterodactyl-panel/resources/scripts/components/elements/SpinnerOverlay.tsx

35 lines
942 B
TypeScript
Raw Normal View History

2022-11-25 20:25:03 +00:00
import type { ReactNode } from 'react';
2020-07-04 19:39:55 +00:00
import tw from 'twin.macro';
2022-11-25 20:25:03 +00:00
import Spinner, { SpinnerSize } from '@/components/elements/Spinner';
interface Props {
2022-11-25 20:25:03 +00:00
children?: ReactNode;
visible: boolean;
fixed?: boolean;
size?: SpinnerSize;
backgroundOpacity?: number;
}
2022-11-25 20:25:03 +00:00
function SpinnerOverlay({ size, fixed, visible, backgroundOpacity, children }: Props) {
if (!visible) {
return null;
}
return (
<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})` }}
>
<Spinner size={size} />
{children && (typeof children === 'string' ? <p css={tw`mt-4 text-neutral-400`}>{children}</p> : children)}
</div>
2022-11-25 20:25:03 +00:00
);
}
2020-02-08 23:23:08 +00:00
export default SpinnerOverlay;