11import { PropsWithChildren , useState } from 'react' ;
2- import { useTranslation } from 'react-i18next' ;
32import { css } from 'styled-components' ;
43
54import { Box } from '@/components' ;
6- import { useCunninghamTheme } from '@/cunningham ' ;
5+ import { MainLayoutContent } from '@/components/main-layout/MainLayoutContent ' ;
76import { Header } from '@/features/header' ;
87import { HEADER_HEIGHT } from '@/features/header/conf' ;
9- import { LeftPanel } from '@/features/left-panel' ;
10- import { MAIN_LAYOUT_ID } from '@/layouts/conf' ;
11- import { useResponsiveStore } from '@/stores' ;
12-
13- import { ResizableLeftPanel } from '../features/left-panel/components/ResizableLeftPanel' ;
148
159type MainLayoutProps = {
1610 backgroundColor ?: 'white' | 'grey' ;
@@ -22,82 +16,8 @@ export function MainLayout({
2216 backgroundColor = 'white' ,
2317 enableResizablePanel = false ,
2418} : PropsWithChildren < MainLayoutProps > ) {
25- const { isDesktop } = useResponsiveStore ( ) ;
26- const { colorsTokens } = useCunninghamTheme ( ) ;
27- const currentBackgroundColor = ! isDesktop ? 'white' : backgroundColor ;
28- const { t } = useTranslation ( ) ;
29-
3019 const [ isResizing , setIsResizing ] = useState ( false ) ;
3120
32- // Main content area (same for all layouts)
33- const mainContent = (
34- < Box
35- as = "main"
36- role = "main"
37- aria-label = { t ( 'Main content' ) }
38- id = { MAIN_LAYOUT_ID }
39- $align = "center"
40- $flex = { 1 }
41- $width = "100%"
42- $height = { `calc(100dvh - ${ HEADER_HEIGHT } px)` }
43- $padding = { {
44- all : isDesktop ? 'base' : '0' ,
45- } }
46- $background = {
47- currentBackgroundColor === 'white'
48- ? colorsTokens [ 'greyscale-000' ]
49- : colorsTokens [ 'greyscale-050' ]
50- }
51- $css = { css `
52- overflow-y : auto;
53- overflow-x : clip;
54- ` }
55- >
56- { children }
57- </ Box >
58- ) ;
59-
60- // Render layout based on device and resizable panel setting
61- const renderContent = ( ) => {
62- // Mobile: simple layout
63- if ( ! isDesktop ) {
64- return (
65- < >
66- < LeftPanel />
67- { mainContent }
68- </ >
69- ) ;
70- }
71-
72- // Desktop with resizable panel
73- if ( enableResizablePanel ) {
74- return (
75- < ResizableLeftPanel
76- leftPanel = { < LeftPanel /> }
77- onResizingChange = { setIsResizing }
78- >
79- { mainContent }
80- </ ResizableLeftPanel >
81- ) ;
82- }
83-
84- // Desktop with fixed panel
85- return (
86- < >
87- < Box
88- $css = { css `
89- width : 300px ;
90- min-width : 300px ;
91- border-right : 1px solid ${ colorsTokens [ 'greyscale-200' ] } ;
92- ` }
93- >
94- < LeftPanel />
95- </ Box >
96- { mainContent }
97- </ >
98- ) ;
99- } ;
100-
10121 return (
10222 < Box
10323 className = { `--docs--main-layout ${ isResizing ? 'resizing' : '' } ` }
@@ -114,7 +34,13 @@ export function MainLayout({
11434 $width = "100%"
11535 $height = { `calc(100dvh - ${ HEADER_HEIGHT } px)` }
11636 >
117- { renderContent ( ) }
37+ < MainLayoutContent
38+ backgroundColor = { backgroundColor }
39+ enableResizablePanel = { enableResizablePanel }
40+ onResizingChange = { setIsResizing }
41+ >
42+ { children }
43+ </ MainLayoutContent >
11844 </ Box >
11945 </ Box >
12046 ) ;
0 commit comments