-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathloading.tsx
More file actions
69 lines (65 loc) · 1.81 KB
/
loading.tsx
File metadata and controls
69 lines (65 loc) · 1.81 KB
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
63
64
65
66
67
68
69
import { ComponentRegistry } from '@object-ui/core';
import type { LoadingSchema } from '@object-ui/types';
import { Spinner } from '@/ui';
import { cn } from '@/lib/utils';
ComponentRegistry.register('loading',
({ schema, className, ...props }: { schema: LoadingSchema; className?: string; [key: string]: any }) => {
const size = schema.size || 'md';
const fullscreen = schema.fullscreen || false;
const loadingContent = (
<div className={cn('flex flex-col items-center justify-center gap-2', className)}>
<Spinner
className={cn(
size === 'sm' && 'h-4 w-4',
size === 'md' && 'h-8 w-8',
size === 'lg' && 'h-12 w-12',
size === ('xl' as any) && 'h-16 w-16'
)}
/>
{schema.text && (
<p className="text-sm text-muted-foreground">{schema.text}</p>
)}
</div>
);
if (fullscreen) {
return (
<div
className="fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm"
{...props}
>
{loadingContent}
</div>
);
}
return (
<div className="flex items-center justify-center p-8" {...props}>
{loadingContent}
</div>
);
},
{
label: 'Loading',
inputs: [
{ name: 'text', type: 'string', label: 'Loading Text' },
{
name: 'size',
type: 'enum',
enum: ['sm', 'md', 'lg', 'xl'],
label: 'Size',
defaultValue: 'md'
},
{
name: 'fullscreen',
type: 'boolean',
label: 'Fullscreen Overlay',
defaultValue: false
},
{ name: 'className', type: 'string', label: 'CSS Class' }
],
defaultProps: {
text: 'Loading...',
size: 'md',
fullscreen: false
}
}
);