@@ -18,6 +18,7 @@ const RemixUIMainPanel = (props: RemixUIMainPanelProps) => {
18
18
const mainPanelRef = useRef < HTMLDivElement > ( null )
19
19
const tabsRef = useRef < HTMLDivElement > ( null )
20
20
const terminalRef = useRef < HTMLDivElement > ( null )
21
+ const bottomBarRef = useRef < HTMLDivElement > ( null )
21
22
22
23
const refs = [ tabsRef , editorRef , mainPanelRef , terminalRef ]
23
24
@@ -56,18 +57,47 @@ const RemixUIMainPanel = (props: RemixUIMainPanelProps) => {
56
57
}
57
58
58
59
const resize = ( height : number ) => {
60
+ syncBottomBarPosition ( )
59
61
layout . emit ( 'resize' , height )
60
62
}
61
63
64
+ const syncBottomBarPosition = ( ) => {
65
+ if ( terminalRef . current && bottomBarRef . current && mainPanelRef . current && ! layout . panels . terminal . minimized ) {
66
+ const bottomBarElement = bottomBarRef . current
67
+ const terminalElement = terminalRef . current
68
+ const mainPanelElement = mainPanelRef . current
69
+
70
+ const bottomBarHeight = bottomBarElement . offsetHeight ;
71
+
72
+ if ( editorRef . current ) {
73
+ const dragBarHeight = 8
74
+ const newEditorHeight = mainPanelElement . offsetHeight - terminalElement . offsetHeight - bottomBarHeight - dragBarHeight
75
+ editorRef . current . style . height = `${ newEditorHeight } px`
76
+ }
77
+ } else if ( bottomBarRef . current ) {
78
+ bottomBarRef . current . style . visibility = 'hidden'
79
+ if ( editorRef . current && mainPanelRef . current && bottomBarRef . current ) {
80
+ editorRef . current . style . height = `${ mainPanelRef . current . offsetHeight - bottomBarRef . current . offsetHeight } px`
81
+ }
82
+ }
83
+ }
84
+
62
85
return (
63
- < div className = "mainview" >
86
+ < div className = "mainview" ref = { mainPanelRef } >
64
87
{ Object . values ( plugins ) . map ( ( pluginRecord , i ) => {
88
+ let panelRef = refs [ i ]
89
+ if ( pluginRecord . profile . name === 'terminal' ) {
90
+ panelRef = terminalRef
91
+ } else if ( pluginRecord . profile . name === 'bottomBar' ) {
92
+ panelRef = bottomBarRef
93
+ }
94
+
65
95
return (
66
96
< React . Fragment key = { `mainView${ i } ` } >
67
97
{ pluginRecord . profile . name === 'terminal' ? (
68
98
< DragBar key = "dragbar-terminal" onResize = { resize } hidden = { pluginRecord . minimized || false } setHideStatus = { showTerminal } refObject = { terminalRef } > </ DragBar >
69
99
) : null }
70
- < RemixUIPanelPlugin ref = { refs [ i ] } key = { pluginRecord . profile . name } pluginRecord = { pluginRecord } />
100
+ < RemixUIPanelPlugin ref = { panelRef } key = { pluginRecord . profile . name } pluginRecord = { pluginRecord } />
71
101
</ React . Fragment >
72
102
)
73
103
} ) }
0 commit comments