Skip to content

Commit 656f584

Browse files
committed
Add storybook stories for Feedback, Form, and Layout components
1 parent 74ace7c commit 656f584

File tree

3 files changed

+188
-0
lines changed

3 files changed

+188
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import type { Meta, StoryObj } from '@storybook/react';
2+
import { SchemaRenderer } from '../SchemaRenderer';
3+
4+
const meta: Meta = {
5+
title: 'Feedback/Extras',
6+
component: SchemaRenderer,
7+
tags: ['autodocs'],
8+
};
9+
10+
export default meta;
11+
type Story = StoryObj<typeof meta>;
12+
13+
export const Spinner: Story = {
14+
args: {
15+
type: 'spinner',
16+
size: 'lg',
17+
className: 'text-primary'
18+
} as any,
19+
render: (args) => <SchemaRenderer schema={args} />
20+
};
21+
22+
export const Empty: Story = {
23+
args: {
24+
type: 'empty',
25+
description: 'No Data Found',
26+
children: [
27+
{ type: 'button', content: 'Create Item', variant: 'default', size: 'sm' }
28+
]
29+
} as any,
30+
render: (args) => <SchemaRenderer schema={args} />
31+
};
32+
33+
export const Loading: Story = {
34+
args: {
35+
type: 'loading',
36+
text: 'Loading your experience...',
37+
className: 'h-[200px]'
38+
} as any,
39+
render: (args) => <SchemaRenderer schema={args} />
40+
};
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import type { Meta, StoryObj } from '@storybook/react';
2+
import { SchemaRenderer } from '../SchemaRenderer';
3+
import type { BaseSchema } from '@object-ui/types';
4+
5+
const meta: Meta = {
6+
title: 'Form/Inputs',
7+
component: SchemaRenderer,
8+
tags: ['autodocs'],
9+
};
10+
11+
export default meta;
12+
type Story = StoryObj<typeof meta>;
13+
14+
export const Slider: Story = {
15+
args: {
16+
type: 'slider',
17+
defaultValue: [50],
18+
max: 100,
19+
min: 0,
20+
step: 1,
21+
className: 'w-[300px]'
22+
},
23+
render: (args) => <SchemaRenderer schema={args} />
24+
};
25+
26+
export const InputOTP: Story = {
27+
args: {
28+
type: 'input-otp',
29+
maxLength: 6,
30+
className: 'gap-2'
31+
} as any,
32+
render: (args) => <SchemaRenderer schema={args} />
33+
};
34+
35+
export const Command: Story = {
36+
args: {
37+
type: 'command',
38+
placeholder: 'Search documentation...',
39+
className: 'rounded-lg border shadow-md w-[450px]',
40+
groups: [
41+
{
42+
heading: 'Suggestions',
43+
items: [
44+
{ value: 'cal', label: 'Calendar' },
45+
{ value: 'em', label: 'Search Emoji' },
46+
{ value: 'calc', label: 'Calculator' }
47+
]
48+
},
49+
{
50+
heading: 'Settings',
51+
items: [
52+
{ value: 'prof', label: 'Profile' },
53+
{ value: 'bill', label: 'Billing' },
54+
{ value: 'set', label: 'Settings' }
55+
]
56+
}
57+
]
58+
} as any,
59+
render: (args) => <SchemaRenderer schema={args} />
60+
};
61+
62+
export const FilterBuilder: Story = {
63+
args: {
64+
type: 'filter-builder',
65+
name: 'user_filters',
66+
label: 'User Filters',
67+
fields: [
68+
{ value: 'name', label: 'Name', type: 'text' },
69+
{ value: 'email', label: 'Email', type: 'text' },
70+
{ value: 'age', label: 'Age', type: 'number' },
71+
{ value: 'status', label: 'Status', type: 'select', options: ['active', 'inactive'] }
72+
],
73+
value: {
74+
id: 'root',
75+
logic: 'and',
76+
conditions: [
77+
{ field: 'age', operator: 'gt', value: 18 }
78+
]
79+
}
80+
} as any,
81+
render: (args) => <SchemaRenderer schema={args} />
82+
};
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import type { Meta, StoryObj } from '@storybook/react';
2+
import { SchemaRenderer } from '../SchemaRenderer';
3+
4+
const meta: Meta = {
5+
title: 'Layout/Extended',
6+
component: SchemaRenderer,
7+
tags: ['autodocs'],
8+
};
9+
10+
export default meta;
11+
type Story = StoryObj<typeof meta>;
12+
13+
export const ScrollArea: Story = {
14+
args: {
15+
type: 'scroll-area',
16+
height: '200px',
17+
width: '350px',
18+
className: 'rounded-md border p-4',
19+
content: [
20+
{ type: 'div', className: 'mb-4 text-sm font-bold', children: [{ type: 'text', content: 'Tags' }] },
21+
{
22+
type: 'div',
23+
children: Array.from({ length: 50 }).map((_, i) => ({
24+
type: 'div',
25+
className: 'text-sm border-b py-2',
26+
children: [{ type: 'text', content: `Tag ${i + 1}` }]
27+
}))
28+
}
29+
]
30+
} as any,
31+
render: (args) => <SchemaRenderer schema={args} />
32+
};
33+
34+
export const HeaderBar: Story = {
35+
args: {
36+
type: 'header-bar',
37+
crumbs: [
38+
{ label: 'Application' },
39+
{ label: 'Dashboard', href: '/dashboard' },
40+
{ label: 'Analytics' }
41+
]
42+
} as any,
43+
render: (args) => <SchemaRenderer schema={args} />
44+
};
45+
46+
export const Pagination: Story = {
47+
args: {
48+
type: 'pagination',
49+
currentPage: 2,
50+
totalPages: 10,
51+
className: 'mt-4'
52+
} as any,
53+
render: (args) => <SchemaRenderer schema={args} />
54+
};
55+
56+
export const Image: Story = {
57+
args: {
58+
type: 'image',
59+
src: 'https://images.unsplash.com/photo-1576075796615-2c1185331f36?w=800&dpr=2&q=80',
60+
alt: 'Photo by Unsplash',
61+
className: 'rounded-xl object-cover',
62+
width: 300,
63+
height: 200
64+
} as any,
65+
render: (args) => <SchemaRenderer schema={args} />
66+
};

0 commit comments

Comments
 (0)