@@ -26,6 +26,7 @@ import {
2626import { createPanelMotion , guardClosingFocus , panelOpacity , setPanelResizing } from "@/shell/panel-motion"
2727import { createSidebarPeek } from "@/shell/sidebar-peek"
2828import { windowDragEnabled } from "@/session/header/drag-area"
29+ import { useLayout } from "@/shell/state/layout"
2930
3031type SidebarPose = { closed : number ; peek : number | undefined }
3132
@@ -135,19 +136,18 @@ function MainShell(props: ParentProps) {
135136 const command = useCommand ( )
136137 const language = useLanguage ( )
137138 const dialog = useDialog ( )
139+ const layout = useLayout ( )
138140 const mobile = createMediaQuery ( "(max-width: 767px)" )
139141
140142 createTipToasts ( )
141143
142144 useDeepLinks ( )
143145
144146 const [ state , setState ] = createStore < {
145- tabsWidth : number
146147 tabsMount : HTMLElement | undefined
147148 tabsAside : HTMLElement | undefined
148149 tabsPanel : HTMLElement | undefined
149150 } > ( {
150- tabsWidth : 240 ,
151151 tabsMount : undefined ,
152152 tabsAside : undefined ,
153153 tabsPanel : undefined ,
@@ -213,17 +213,18 @@ function MainShell(props: ParentProps) {
213213 sidebar . closed = closed
214214 const aside = state . tabsAside
215215
216- if ( aside ) aside . style . width = `${ state . tabsWidth * ( 1 - closed ) } px`
216+ if ( aside ) aside . style . width = `${ layout . tabsSidebar . width ( ) * ( 1 - closed ) } px`
217217
218218 // Dims the contents, background included, as they leave and brightens them as they arrive.
219219 paintSidebarContents ( )
220220 paintCollapsedSlots ( closed )
221221 } ,
222222 // The contents slide by their own width, which a peek widens past the docked sidebar's.
223- measure : ( ) => measureSidebarToggles ( ( state . tabsMount ?. offsetWidth ?? state . tabsWidth ) * sidebarHidden ( ) ) ,
223+ measure : ( ) =>
224+ measureSidebarToggles ( ( state . tabsMount ?. offsetWidth ?? layout . tabsSidebar . width ( ) ) * sidebarHidden ( ) ) ,
224225 // A dock from a peek already shows the sidebar, so reduced motion has nothing to fade in.
225226 element : ( ) => ( peek . handedOff ( ) ? undefined : state . tabsPanel ) ,
226- distance : ( ) => state . tabsWidth ,
227+ distance : ( ) => layout . tabsSidebar . width ( ) ,
227228 } )
228229
229230 const peek = createSidebarPeek ( {
@@ -330,8 +331,8 @@ function MainShell(props: ParentProps) {
330331 data-peek = { peek . shown ( ) ? "" : undefined }
331332 style = { {
332333 "--sidebar-peek-width" : peek . shown ( )
333- ? `calc(${ state . tabsWidth } px + var(--shell-inline-inset, 8px))`
334- : `${ state . tabsWidth } px` ,
334+ ? `calc(${ layout . tabsSidebar . width ( ) } px + var(--shell-inline-inset, 8px))`
335+ : `${ layout . tabsSidebar . width ( ) } px` ,
335336 } }
336337 ref = { ( element ) => setState ( "tabsAside" , element ) }
337338 class = "relative z-10 h-full min-h-0 shrink-0"
@@ -375,10 +376,10 @@ function MainShell(props: ParentProps) {
375376 < Show when = { preferences . appearance . sidebarOpen ( ) } >
376377 < ResizeHandle
377378 direction = "horizontal"
378- size = { state . tabsWidth }
379+ size = { layout . tabsSidebar . width ( ) }
379380 min = { 136 }
380381 max = { 640 }
381- onResize = { ( width ) => setState ( "tabsWidth" , width ) }
382+ onResize = { layout . tabsSidebar . resize }
382383 onDraggingChange = { setPanelResizing }
383384 />
384385 </ Show >
0 commit comments