@@ -36,19 +36,31 @@ function getInitialWidth(): number {
36
36
return typeof window !== 'undefined' ? window . innerWidth : breakpoints . xs ;
37
37
}
38
38
39
+ /** Renders a `GridTemplate`, which is expecting the column size for each viewport breakpoint (xs, sm, md, lg, xl)
40
+ * coming in via the extra props provided by the caller.
41
+ * Uses a 12 column grid by default. This can be overridden by passing `layoutGrid` in `uiSchema`.
42
+ *
43
+ * @param props - The GridTemplateProps, including the extra props containing the grid sizing details
44
+ */
39
45
export default function GridTemplate ( props : GridTemplateProps ) {
40
46
return props . column ? GridTemplateColumn ( props ) : GridTemplateRow ( props ) ;
41
47
}
42
48
43
49
function GridTemplateRow ( props : GridTemplateProps ) {
44
- const { children, column, uiSchema, ...rest } = props ;
50
+ const { children, column, uiSchema, style , ...rest } = props ;
45
51
const layoutGrid = uiSchema ?. [ 'ui:layoutGrid' ] ?? { } ;
46
52
const totalColumns = layoutGrid . columns ?? 12 ;
47
53
const gap = layoutGrid . gap ?? '16px' ;
48
54
49
55
return (
50
56
< div
51
- style = { { display : 'grid' , gridTemplateColumns : `repeat(${ totalColumns } , 1fr)` , alignItems : 'start' , gap } }
57
+ style = { {
58
+ display : 'grid' ,
59
+ gridTemplateColumns : `repeat(${ totalColumns } , 1fr)` ,
60
+ alignItems : 'start' ,
61
+ gap,
62
+ ...( style ?? { } ) ,
63
+ } }
52
64
{ ...rest }
53
65
>
54
66
{ children }
@@ -57,7 +69,7 @@ function GridTemplateRow(props: GridTemplateProps) {
57
69
}
58
70
59
71
function GridTemplateColumn ( props : GridTemplateProps ) {
60
- const { children, column, uiSchema, xs, sm, md, lg, xl, ...rest } = props ;
72
+ const { children, column, uiSchema, xs, sm, md, lg, xl, style , ...rest } = props ;
61
73
62
74
const [ breakpoint , setBreakpoint ] = useState < Breakpoint > ( ( ) => getBreakpoint ( getInitialWidth ( ) ) ) ;
63
75
@@ -74,7 +86,7 @@ function GridTemplateColumn(props: GridTemplateProps) {
74
86
const span = getResponsiveSpan ( props as ResponsiveSpan , breakpoint ) ;
75
87
76
88
return (
77
- < div style = { { gridColumn : `span ${ span } / span ${ span } ` } } { ...rest } >
89
+ < div style = { { gridColumn : `span ${ span } / span ${ span } ` , ... ( style ?? { } ) } } { ...rest } >
78
90
{ children }
79
91
</ div >
80
92
) ;
0 commit comments