99import { ComponentRegistry } from '@object-ui/core' ;
1010import type { DashboardSchema } from '@object-ui/types' ;
1111import { SchemaRenderer } from '@object-ui/react' ;
12+ import { cn } from '@object-ui/components' ;
1213import { forwardRef } from 'react' ;
13- import { cn } from '../../lib/utils' ;
1414
15- const DashboardRenderer = forwardRef < HTMLDivElement , { schema : DashboardSchema ; className ?: string ; [ key : string ] : any } > (
15+ export const DashboardRenderer = forwardRef < HTMLDivElement , { schema : DashboardSchema ; className ?: string ; [ key : string ] : any } > (
1616 ( { schema, className, ...props } , ref ) => {
1717 const columns = schema . columns || 3 ;
1818 const gap = schema . gap || 4 ;
1919
20+ // Use style to convert gap number to pixels or use tailwind classes if possible
21+ // Here using inline style for grid gap which maps to 0.25rem * 4 * gap = gap rem
22+
2023 return (
2124 < div
2225 ref = { ref }
2326 className = { cn ( "grid" , className ) }
2427 style = { {
2528 gridTemplateColumns : `repeat(${ columns } , minmax(0, 1fr))` ,
26- gap : gap * 4 // Assuming tailwind scale
29+ gap : ` ${ gap * 0.25 } rem`
2730 } }
2831 { ...props }
2932 >
@@ -44,22 +47,3 @@ const DashboardRenderer = forwardRef<HTMLDivElement, { schema: DashboardSchema;
4447 ) ;
4548 }
4649) ;
47-
48- ComponentRegistry . register (
49- 'dashboard' ,
50- DashboardRenderer ,
51- {
52- label : 'Dashboard' ,
53- category : 'Complex' ,
54- icon : 'layout-dashboard' ,
55- inputs : [
56- { name : 'columns' , type : 'number' , label : 'Columns' , defaultValue : 3 } ,
57- { name : 'gap' , type : 'number' , label : 'Gap' , defaultValue : 4 } ,
58- { name : 'className' , type : 'string' , label : 'CSS Class' }
59- ] ,
60- defaultProps : {
61- columns : 3 ,
62- widgets : [ ]
63- }
64- }
65- ) ;
0 commit comments