-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcarousel.tsx
More file actions
60 lines (59 loc) · 1.97 KB
/
carousel.tsx
File metadata and controls
60 lines (59 loc) · 1.97 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
import { ComponentRegistry } from '@object-ui/core';
import type { CarouselSchema } from '@object-ui/types';
import {
Carousel,
CarouselContent,
CarouselItem,
CarouselPrevious,
CarouselNext
} from '@/ui';
import { renderChildren } from '../../lib/utils';
ComponentRegistry.register('carousel',
({ schema, className, ...props }: { schema: CarouselSchema; className?: string; [key: string]: any }) => (
<Carousel
opts={schema.opts}
orientation={schema.orientation || 'horizontal'}
className={className}
{...props}
>
<CarouselContent>
{schema.items?.map((item: any, index: number) => (
<CarouselItem key={index} className={schema.itemClassName}>
{renderChildren(item)}
</CarouselItem>
))}
</CarouselContent>
{schema.showArrows && (
<>
<CarouselPrevious />
<CarouselNext />
</>
)}
</Carousel>
),
{
label: 'Carousel',
inputs: [
{ name: 'orientation', type: 'enum', enum: ['horizontal', 'vertical'], defaultValue: 'horizontal', label: 'Orientation' },
{ name: 'showArrows', type: 'boolean', label: 'Show Arrows', defaultValue: true },
{
name: 'items',
type: 'array',
label: 'Items',
description: 'Array of content schemas'
},
{ name: 'itemClassName', type: 'string', label: 'Item CSS Class' },
{ name: 'className', type: 'string', label: 'Container CSS Class' }
],
defaultProps: {
orientation: 'horizontal',
showArrows: true,
items: [
[{ type: 'div', className: 'p-8 border rounded bg-slate-50', body: [{ type: 'text', content: 'Slide 1' }] }],
[{ type: 'div', className: 'p-8 border rounded bg-slate-50', body: [{ type: 'text', content: 'Slide 2' }] }],
[{ type: 'div', className: 'p-8 border rounded bg-slate-50', body: [{ type: 'text', content: 'Slide 3' }] }]
],
className: 'w-full max-w-xs'
}
}
);