-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscroll-area.tsx
More file actions
32 lines (31 loc) · 1.36 KB
/
scroll-area.tsx
File metadata and controls
32 lines (31 loc) · 1.36 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
import { ComponentRegistry } from '@object-ui/core';
import type { ScrollAreaSchema } from '@object-ui/types';
import { ScrollArea, ScrollBar } from '@/ui';
import { renderChildren } from '../../lib/utils';
ComponentRegistry.register('scroll-area',
({ schema, className, ...props }: { schema: ScrollAreaSchema; className?: string; [key: string]: any }) => (
<ScrollArea className={className} style={{ height: schema.height, width: schema.width }} {...props}>
{renderChildren(schema.content || schema.children)}
{schema.orientation === 'horizontal' && <ScrollBar orientation="horizontal" />}
</ScrollArea>
),
{
label: 'Scroll Area',
inputs: [
{ name: 'height', type: 'string', label: 'Height (e.g. 200px)' },
{ name: 'width', type: 'string', label: 'Width' },
{ name: 'orientation', type: 'enum', enum: ['vertical', 'horizontal', 'both'], defaultValue: 'vertical', label: 'Orientation' },
{ name: 'content', type: 'slot', label: 'Content' },
{ name: 'className', type: 'string', label: 'CSS Class' }
],
defaultProps: {
height: '200px',
width: '100%',
orientation: 'vertical',
content: [
{ type: 'div', className: 'p-4', body: [{ type: 'text', content: 'Scrollable content goes here. Add more content to see scrolling behavior.' }] }
],
className: 'rounded-md border'
}
}
);