-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathalert.tsx
More file actions
37 lines (36 loc) · 1.12 KB
/
alert.tsx
File metadata and controls
37 lines (36 loc) · 1.12 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
import { ComponentRegistry } from '@object-ui/core';
import type { AlertSchema } from '@object-ui/types';
import { renderChildren } from '../../lib/utils';
import {
Alert,
AlertTitle,
AlertDescription
} from '@/ui';
ComponentRegistry.register('alert',
({ schema, className, ...props }: { schema: AlertSchema; className?: string; [key: string]: any }) => (
<Alert variant={schema.variant} className={className} {...props}>
<AlertTitle>{schema.title}</AlertTitle>
<AlertDescription>{schema.description || renderChildren(schema.body)}</AlertDescription>
</Alert>
),
{
label: 'Alert',
inputs: [
{ name: 'title', type: 'string', label: 'Title', required: true },
{ name: 'description', type: 'string', label: 'Description' },
{
name: 'variant',
type: 'enum',
enum: ['default', 'destructive'],
defaultValue: 'default',
label: 'Variant'
},
{ name: 'className', type: 'string', label: 'CSS Class' }
],
defaultProps: {
title: 'Alert Title',
description: 'This is an alert message.',
variant: 'default'
}
}
);