@@ -104,14 +104,68 @@ const Root: React.FC<React.PropsWithChildren<PageLayoutProps>> = ({
104104Root . displayName = 'PageLayout'
105105
106106// ----------------------------------------------------------------------------
107- // Divider (internal)
107+ // ResizeHandle (internal)
108108
109- type DividerProps = {
110- variant ?: 'none' | 'line' | 'filled' | ResponsiveValue < 'none' | 'line' | 'filled' >
111- canResize ?: boolean
109+ type ResizeHandleProps = {
112110 isResizing ?: boolean
113111 onClick ?: ( e : React . MouseEvent ) => void
114112 onMouseDown ?: ( e : React . MouseEvent ) => void
113+ }
114+
115+ const ResizeHandle : React . FC < React . PropsWithChildren < ResizeHandleProps > > = ( { isResizing, onClick, onMouseDown} ) => {
116+ return (
117+ < Box
118+ sx = { {
119+ position : 'absolute' ,
120+ top : 0 ,
121+ bottom : 0
122+ } }
123+ >
124+ < Box
125+ onMouseDown = { onMouseDown }
126+ onClick = { onClick }
127+ sx = { {
128+ width : '16px' ,
129+ height : '100%' ,
130+ display : 'flex' ,
131+ justifyContent : 'center' ,
132+ position : 'absolute' ,
133+ transform : 'translateX(50%)' ,
134+ right : 0 ,
135+ opacity : isResizing ? 1 : 0 ,
136+ cursor : 'col-resize' ,
137+ '&:hover' : {
138+ animation : isResizing ? 'none' : 'resizer-appear 80ms 300ms both' ,
139+
140+ '@keyframes resizer-appear' : {
141+ from : {
142+ opacity : 0
143+ } ,
144+
145+ to : {
146+ opacity : 1
147+ }
148+ }
149+ }
150+ } }
151+ >
152+ < Box
153+ sx = { {
154+ backgroundColor : 'accent.fg' ,
155+ width : '1px' ,
156+ height : '100%'
157+ } }
158+ />
159+ </ Box >
160+ </ Box >
161+ )
162+ }
163+
164+ // ----------------------------------------------------------------------------
165+ // Divider (internal)
166+
167+ type DividerProps = {
168+ variant ?: 'none' | 'line' | 'filled' | ResponsiveValue < 'none' | 'line' | 'filled' >
115169} & SxProp
116170
117171const horizontalDividerVariants = {
@@ -184,65 +238,20 @@ const verticalDividerVariants = {
184238 }
185239}
186240
187- const VerticalDivider : React . FC < React . PropsWithChildren < DividerProps > > = ( {
188- variant = 'none' ,
189- canResize,
190- isResizing,
191- onClick,
192- onMouseDown,
193- sx = { }
194- } ) => {
241+ const VerticalDivider : React . FC < React . PropsWithChildren < DividerProps > > = ( { variant = 'none' , sx = { } } ) => {
195242 const responsiveVariant = useResponsiveValue ( variant , 'none' )
196243 return (
197244 < Box
198245 sx = { merge < BetterSystemStyleObject > (
199246 {
200- height : '100%' ,
201- position : 'relative' ,
247+ position : 'absolute' ,
248+ top : 0 ,
249+ bottom : 0 ,
202250 ...verticalDividerVariants [ responsiveVariant ]
203251 } ,
204252 sx
205253 ) }
206- >
207- { canResize && (
208- < Box
209- onMouseDown = { onMouseDown }
210- onClick = { onClick }
211- sx = { {
212- width : '16px' ,
213- height : '100%' ,
214- display : 'flex' ,
215- justifyContent : 'center' ,
216- position : 'absolute' ,
217- transform : 'translateX(50%)' ,
218- right : 0 ,
219- opacity : isResizing ? 1 : 0 ,
220- cursor : 'col-resize' ,
221- '&:hover' : {
222- animation : isResizing ? 'none' : 'resizer-appear 80ms 300ms both' ,
223-
224- '@keyframes resizer-appear' : {
225- from : {
226- opacity : 0
227- } ,
228-
229- to : {
230- opacity : 1
231- }
232- }
233- }
234- } }
235- >
236- < Box
237- sx = { {
238- backgroundColor : 'accent.fg' ,
239- width : '1px' ,
240- height : '100%'
241- } }
242- />
243- </ Box >
244- ) }
245- </ Box >
254+ />
246255 )
247256}
248257
@@ -506,18 +515,22 @@ const Pane = React.forwardRef<HTMLDivElement, React.PropsWithChildren<PageLayout
506515 }
507516 } , [ sticky , enableStickyPane , disableStickyPane , offsetHeader ] )
508517
518+ const containerRef = React . useRef < HTMLDivElement > ( null )
519+
509520 const paneRef = React . useRef < HTMLDivElement > ( null )
510521 useRefObjectAsForwardedRef ( forwardRef , paneRef )
511522
512523 const { onMouseDown, onClick, isResizing, paneWidth} = useHorizontalResize (
513524 canResizePane ,
514525 position ,
515526 paneRef ,
527+ containerRef ,
516528 paneWidthStorageKey
517529 )
518530
519531 return (
520532 < Box
533+ ref = { containerRef }
521534 // eslint-disable-next-line @typescript-eslint/no-explicit-any
522535 sx = { ( theme : any ) =>
523536 merge < BetterSystemStyleObject > (
@@ -559,14 +572,17 @@ const Pane = React.forwardRef<HTMLDivElement, React.PropsWithChildren<PageLayout
559572 variant = { { narrow : dividerVariant , regular : 'none' } }
560573 sx = { { [ position === 'end' ? 'marginBottom' : 'marginTop' ] : SPACING_MAP [ rowGap ] } }
561574 />
562- < VerticalDivider
563- variant = { { narrow : 'none' , regular : dividerVariant } }
564- canResize = { canResizePane }
565- isResizing = { isResizing }
566- onClick = { onClick }
567- onMouseDown = { onMouseDown }
568- sx = { { [ position === 'end' ? 'marginRight' : 'marginLeft' ] : SPACING_MAP [ columnGap ] } }
569- />
575+
576+ < Box
577+ sx = { {
578+ position : 'relative' ,
579+ height : '100%' ,
580+ [ position === 'end' ? 'marginRight' : 'marginLeft' ] : SPACING_MAP [ columnGap ]
581+ } }
582+ >
583+ < VerticalDivider variant = { { narrow : 'none' , regular : dividerVariant } } />
584+ { canResizePane && < ResizeHandle isResizing = { isResizing } onClick = { onClick } onMouseDown = { onMouseDown } /> }
585+ </ Box >
570586 < Box
571587 ref = { paneRef }
572588 sx = { ( theme : Theme ) => ( {
0 commit comments