Skip to content

Commit 688e55a

Browse files
Copilothotlong
andcommitted
Fix dashboard story schema structure and SchemaRenderer prop spreading
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 61d3835 commit 688e55a

2 files changed

Lines changed: 40 additions & 29 deletions

File tree

packages/components/src/stories-json/dashboard.stories.tsx

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,30 @@ export const Default: Story = {
2525
type: 'dashboard',
2626
columns: 3,
2727
gap: 4,
28-
children: [
28+
widgets: [
2929
{
30-
type: 'metric',
31-
label: 'Total Revenue',
32-
value: '$45,231.89',
33-
className: 'col-span-1'
30+
id: 'metric-1',
31+
component: {
32+
type: 'metric',
33+
label: 'Total Revenue',
34+
value: '$45,231.89',
35+
}
3436
},
3537
{
36-
type: 'metric',
37-
label: 'Active Users',
38-
value: '2,350',
39-
className: 'col-span-1'
38+
id: 'metric-2',
39+
component: {
40+
type: 'metric',
41+
label: 'Active Users',
42+
value: '2,350',
43+
}
4044
},
4145
{
42-
type: 'metric',
43-
label: 'Conversion Rate',
44-
value: '12.5%',
45-
className: 'col-span-1'
46+
id: 'metric-3',
47+
component: {
48+
type: 'metric',
49+
label: 'Conversion Rate',
50+
value: '12.5%',
51+
}
4652
}
4753
]
4854
} as any,
@@ -54,24 +60,28 @@ export const WithCards: Story = {
5460
type: 'dashboard',
5561
columns: 2,
5662
gap: 6,
57-
children: [
63+
widgets: [
5864
{
59-
type: 'card',
60-
title: 'Schema/Plugins/Sales Overview',
61-
children: [
62-
{ type: 'metric', label: 'Today', value: '$1,234' },
63-
{ type: 'metric', label: 'This Week', value: '$8,456' },
64-
],
65-
className: 'col-span-1'
65+
id: 'card-1',
66+
title: 'Sales Overview',
67+
component: {
68+
type: 'card',
69+
children: [
70+
{ type: 'metric', label: 'Today', value: '$1,234' },
71+
{ type: 'metric', label: 'This Week', value: '$8,456' },
72+
],
73+
}
6674
},
6775
{
68-
type: 'card',
69-
title: 'Schema/Plugins/User Metrics',
70-
children: [
71-
{ type: 'metric', label: 'Online', value: '456' },
72-
{ type: 'metric', label: 'New Today', value: '89' },
73-
],
74-
className: 'col-span-1'
76+
id: 'card-2',
77+
title: 'User Metrics',
78+
component: {
79+
type: 'card',
80+
children: [
81+
{ type: 'metric', label: 'Online', value: '456' },
82+
{ type: 'metric', label: 'New Today', value: '89' },
83+
],
84+
}
7585
}
7686
]
7787
} as any,

packages/react/src/SchemaRenderer.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ export const SchemaRenderer = forwardRef<any, { schema: SchemaNode } & Record<st
5757
// may not support refs. The SchemaRenderer itself can still receive refs for its own use.
5858
return React.createElement(Component, {
5959
schema: evaluatedSchema,
60-
...(evaluatedSchema.props || {}),
60+
...evaluatedSchema, // Spread all schema properties as props
61+
...(evaluatedSchema.props || {}), // Override with explicit props if provided
6162
className: evaluatedSchema.className,
6263
'data-obj-id': evaluatedSchema.id,
6364
'data-obj-type': evaluatedSchema.type,

0 commit comments

Comments
 (0)