@@ -38,7 +38,7 @@ export const DashboardRenderer = forwardRef<HTMLDivElement, DashboardRendererPro
3838 const intervalRef = useRef < ReturnType < typeof setInterval > | null > ( null ) ;
3939
4040 useEffect ( ( ) => {
41- const checkMobile = ( ) => setIsMobile ( window . innerWidth < 640 ) ;
41+ const checkMobile = ( ) => setIsMobile ( window . innerWidth < 768 ) ;
4242 checkMobile ( ) ;
4343 window . addEventListener ( 'resize' , checkMobile ) ;
4444 return ( ) => window . removeEventListener ( 'resize' , checkMobile ) ;
@@ -61,7 +61,7 @@ export const DashboardRenderer = forwardRef<HTMLDivElement, DashboardRendererPro
6161 } ;
6262 } , [ schema . refreshInterval , onRefresh , handleRefresh ] ) ;
6363
64- const renderWidget = ( widget : DashboardWidgetSchema , index : number ) => {
64+ const renderWidget = ( widget : DashboardWidgetSchema , index : number , forceMobileFullWidth ?: boolean ) => {
6565 const getComponentSchema = ( ) => {
6666 if ( widget . component ) return widget . component ;
6767
@@ -113,7 +113,7 @@ export const DashboardRenderer = forwardRef<HTMLDivElement, DashboardRendererPro
113113 return (
114114 < div
115115 key = { widgetKey }
116- className = { cn ( "h-full w-full" , isMobile && "w-[85vw] shrink-0 snap-center" ) }
116+ className = { cn ( "h-full w-full" ) }
117117 style = { ! isMobile && widget . layout ? {
118118 gridColumn : `span ${ widget . layout . w } ` ,
119119 gridRow : `span ${ widget . layout . h } `
@@ -130,7 +130,7 @@ export const DashboardRenderer = forwardRef<HTMLDivElement, DashboardRendererPro
130130 className = { cn (
131131 "overflow-hidden border-border/50 shadow-sm transition-all hover:shadow-md" ,
132132 "bg-card/50 backdrop-blur-sm" ,
133- isMobile && "w-[85vw] shrink-0 snap-center "
133+ forceMobileFullWidth && "w-full "
134134 ) }
135135 style = { ! isMobile && widget . layout ? {
136136 gridColumn : `span ${ widget . layout . w } ` ,
@@ -169,15 +169,27 @@ export const DashboardRenderer = forwardRef<HTMLDivElement, DashboardRendererPro
169169 ) ;
170170
171171 if ( isMobile ) {
172+ // Separate metric widgets from other widgets for better mobile layout
173+ const metricWidgets = schema . widgets ?. filter ( w => w . type === 'metric' ) || [ ] ;
174+ const otherWidgets = schema . widgets ?. filter ( w => w . type !== 'metric' ) || [ ] ;
175+
172176 return (
173- < div ref = { ref } className = { cn ( "flex flex-col" , className ) } { ...props } >
177+ < div ref = { ref } className = { cn ( "flex flex-col gap-4 px-4 " , className ) } { ...props } >
174178 { refreshButton }
175- < div
176- className = "flex overflow-x-auto snap-x snap-mandatory gap-3 pb-4 [-webkit-overflow-scrolling:touch]"
177- style = { { scrollPaddingLeft : '0.75rem' } }
178- >
179- { schema . widgets ?. map ( ( widget : DashboardWidgetSchema , index : number ) => renderWidget ( widget , index ) ) }
180- </ div >
179+
180+ { /* Metric cards: 2-column grid */ }
181+ { metricWidgets . length > 0 && (
182+ < div className = "grid grid-cols-2 gap-3" >
183+ { metricWidgets . map ( ( widget : DashboardWidgetSchema , index : number ) => renderWidget ( widget , index ) ) }
184+ </ div >
185+ ) }
186+
187+ { /* Other widgets (charts, tables): full-width vertical stack */ }
188+ { otherWidgets . length > 0 && (
189+ < div className = "flex flex-col gap-4" >
190+ { otherWidgets . map ( ( widget : DashboardWidgetSchema , index : number ) => renderWidget ( widget , index , true ) ) }
191+ </ div >
192+ ) }
181193 </ div >
182194 ) ;
183195 }
0 commit comments