Spaces:
Build error
Build error
File size: 1,655 Bytes
0bfe2e3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
import { cva } from 'class-variance-authority';
import * as React from 'react';
import { cn, defineStyleAnatomy } from '../core/styling';
import { LoadingSpinner } from './loading-spinner';
/* -------------------------------------------------------------------------------------------------
* Anatomy
* -----------------------------------------------------------------------------------------------*/
export const LoadingOverlayAnatomy = defineStyleAnatomy({
overlay: cva([
'UI-LoadingOverlay__overlay',
'absolute bg-[--background]/50 w-full h-full z-10 inset-0 pt-4 flex flex-col items-center justify-center backdrop-blur-sm',
'!mt-0',
]),
});
/* -------------------------------------------------------------------------------------------------
* LoadingOverlay
* -----------------------------------------------------------------------------------------------*/
export type LoadingOverlayProps = {
children?: React.ReactNode;
/**
* Whether to show the loading spinner
*/
showSpinner?: boolean;
/**
* If true, the loading overlay will be unmounted
*/
hide?: boolean;
className?: string;
};
export const LoadingOverlay = React.forwardRef<
HTMLDivElement,
LoadingOverlayProps
>((props, ref) => {
const {
children,
hide = false,
showSpinner = true,
className,
...rest
} = props;
if (hide) return null;
return (
<div
ref={ref}
className={cn(LoadingOverlayAnatomy.overlay(), className)}
{...rest}
>
{showSpinner && <LoadingSpinner className="justify-auto" />}
{children}
</div>
);
});
LoadingOverlay.displayName = 'LoadingOverlay';
|