11import classNames from 'classnames'
22import { ReactNode , useCallback , useEffect , useMemo , useRef , useState } from 'react'
3+ import { isMobile } from 'react-device-detect'
34
45interface Props {
56 className ?: string
@@ -8,7 +9,8 @@ interface Props {
89 bottomArea : ReactNode
910}
1011
11- export default function GridWithSplitters ( { className, chartArea, rightArea, bottomArea } : Props ) {
12+ // Desktop layout component with full grid and drag functionality
13+ function DesktopGridLayout ( { className, chartArea, rightArea, bottomArea } : Props ) {
1214 const [ chartWidthPercent , setChartWidthPercent ] = useState ( 75 ) // Chart takes 75% width
1315 const [ chartHeightPercent , setChartHeightPercent ] = useState ( 75 ) // Chart takes 75% height
1416 const [ isDragging , setIsDragging ] = useState < 'vertical' | 'horizontal' | null > ( null )
@@ -141,15 +143,8 @@ export default function GridWithSplitters({ className, chartArea, rightArea, bot
141143 />
142144 ) }
143145
144- { /* Mobile Layout - Stacked */ }
145- < div className = 'flex flex-col w-full gap-1 md:hidden' >
146- < div className = 'bg-surface w-full' > { chartArea } </ div >
147- < div className = 'bg-surface w-full' > { rightArea } </ div >
148- < div className = 'bg-surface w-full' > { bottomArea } </ div >
149- </ div >
150-
151146 { /* Desktop Layout - CSS Grid with Splitters */ }
152- < div className = 'hidden md: grid w-full h-full min-h-0' style = { gridStyles } >
147+ < div className = 'grid w-full h-full min-h-0' style = { gridStyles } >
153148 { /* Row 1, Col 1: Chart Area */ }
154149 < div className = 'min-w-0 min-h-0 overflow-hidden row-start-1 row-end-2 col-start-1 col-end-2' >
155150 { chartArea }
@@ -214,3 +209,20 @@ export default function GridWithSplitters({ className, chartArea, rightArea, bot
214209 </ div >
215210 )
216211}
212+
213+ // Mobile layout - stacked
214+ function MobileGridLayout ( { className, chartArea, rightArea, bottomArea } : Props ) {
215+ return (
216+ < div className = { classNames ( 'w-full' , className ) } >
217+ < div className = 'flex flex-col w-full gap-1' >
218+ < div className = 'bg-surface w-full' > { chartArea } </ div >
219+ < div className = 'bg-surface w-full' > { rightArea } </ div >
220+ < div className = 'bg-surface w-full' > { bottomArea } </ div >
221+ </ div >
222+ </ div >
223+ )
224+ }
225+
226+ export default function GridWithSplitters ( props : Props ) {
227+ return isMobile ? < MobileGridLayout { ...props } /> : < DesktopGridLayout { ...props } />
228+ }
0 commit comments