Skip to content

Commit 02d94c0

Browse files
committed
maximize bottom panel
1 parent 2aa66f5 commit 02d94c0

File tree

4 files changed

+93
-5
lines changed

4 files changed

+93
-5
lines changed

apps/remix-ide/src/app/panels/terminal.tsx

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function register(api) { KONSOLES.push(api) }
1919
const profile = {
2020
displayName: 'Terminal',
2121
name: 'terminal',
22-
methods: ['log', 'logHtml', 'togglePanel', 'isPanelHidden'],
22+
methods: ['log', 'logHtml', 'togglePanel', 'isPanelHidden', 'maximizePanel'],
2323
events: [],
2424
description: 'Remix IDE terminal',
2525
version: packageJson.version
@@ -55,8 +55,10 @@ export default class Terminal extends Plugin {
5555
dispatch: any
5656
terminalApi: any
5757
isHidden: boolean
58+
isMaximized: boolean
5859
constructor(opts, api) {
5960
super(profile)
61+
this.isMaximized = false
6062
this.fileImport = new CompilerImports()
6163
this.event = new EventManager()
6264
this.globalRegistry = Registry.getInstance()
@@ -116,6 +118,21 @@ export default class Terminal extends Plugin {
116118

117119
onActivation() {
118120
this.renderComponent()
121+
122+
// Listen for file changes - auto-restore terminal panel if maximized when main panel is used
123+
this.on('fileManager', 'currentFileChanged', () => {
124+
if (this.isMaximized) {
125+
this.maximizePanel() // This will toggle and restore the panel
126+
}
127+
})
128+
129+
// Listen for tab/app switches - auto-restore terminal panel if maximized
130+
this.on('tabs', 'switchApp', () => {
131+
if (this.isMaximized) {
132+
this.maximizePanel() // This will toggle and restore the panel
133+
}
134+
})
135+
119136
// Initialize isHidden state from panelStates in localStorage
120137
const panelStatesStr = window.localStorage.getItem('panelStates')
121138
const panelStates = panelStatesStr ? JSON.parse(panelStatesStr) : {}
@@ -204,6 +221,41 @@ export default class Terminal extends Plugin {
204221
return this.isHidden
205222
}
206223

224+
async maximizePanel() {
225+
if (!this.isMaximized) {
226+
// Hide all main panel content except terminal
227+
const mainView = document.querySelector('.mainview')
228+
if (mainView) {
229+
// Find all child elements with -wrap class except terminal-wrap
230+
const wraps = mainView.querySelectorAll('[class*="-wrap"]')
231+
wraps.forEach((wrap: HTMLElement) => {
232+
if (!wrap.classList.contains('terminal-wrap')) {
233+
wrap.classList.add('d-none')
234+
}
235+
})
236+
}
237+
238+
this.isMaximized = true
239+
trackMatomoEvent(this, { category: 'topbar', action: 'terminalPanel', name: 'maximized', isClick: false })
240+
this.emit('terminalPanelMaximized')
241+
} else {
242+
// Show all main panel content
243+
const mainView = document.querySelector('.mainview')
244+
if (mainView) {
245+
// Find all child elements with -wrap class and show them
246+
const wraps = mainView.querySelectorAll('[class*="-wrap"]')
247+
wraps.forEach((wrap: HTMLElement) => {
248+
wrap.classList.remove('d-none')
249+
})
250+
}
251+
252+
this.isMaximized = false
253+
trackMatomoEvent(this, { category: 'topbar', action: 'terminalPanel', name: 'restored', isClick: false })
254+
this.emit('terminalPanelRestored')
255+
}
256+
this.renderComponent()
257+
}
258+
207259
setDispatch(dispatch) {
208260
this.dispatch = dispatch
209261
}
@@ -219,6 +271,8 @@ export default class Terminal extends Plugin {
219271
plugin={state.plugin}
220272
onReady={state.onReady}
221273
visible={true}
274+
isMaximized={this.isMaximized}
275+
maximizePanel={this.maximizePanel.bind(this)}
222276
/>
223277
</>)
224278
}

libs/remix-ui/terminal/src/lib/components/remix-ui-terminal-bar.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
import { appPlatformTypes, platformContext } from '@remix-ui/app'
2-
import { CustomTooltip } from '@remix-ui/helper'
32
import React, { useState, useEffect, useRef, useContext } from 'react' // eslint-disable-line
4-
import { FormattedMessage, useIntl } from 'react-intl'
5-
import { listenOnNetworkAction } from '../actions/terminalAction'
63
import { TerminalContext } from '../context'
74
import { RemixUiTerminalProps } from '../types/terminalTypes'
85
import { RemixUITerminalMenu } from './remix-ui-terminal-menu'
96
import { RemixUITerminalMenuToggle } from './remix-ui-terminal-menu-toggle'
7+
import { RemixUITerminalMenuMaximize } from './remix-ui-terminal-menu-maximize'
108
import { RemixUIXtermMenu } from '../../../../xterm/src/lib/components/remix-ui-terminal-menu-xterm'
119
import { RemixUITerminalMenuButtons } from './remix-ui-terminal-menu-buttons'
1210

1311
export const RemixUITerminalBar = (props: RemixUiTerminalProps) => {
1412
const { terminalState, xtermState } = useContext(TerminalContext)
1513
const platform = useContext(platformContext)
16-
const intl = useIntl()
1714
const terminalMenu = useRef(null)
1815

1916
useEffect(() => {
@@ -31,10 +28,12 @@ export const RemixUITerminalBar = (props: RemixUiTerminalProps) => {
3128
<div className='d-flex flex-row w-100 justify-content-end align-items-center'>
3229
<RemixUITerminalMenuButtons {...props} />
3330
{xtermState.showOutput? <RemixUITerminalMenu {...props} />: <RemixUIXtermMenu {...props} />}
31+
<RemixUITerminalMenuMaximize {...props} />
3432
<RemixUITerminalMenuToggle {...props} />
3533
</div> :
3634
<div className='d-flex flex-row w-100 justify-content-end align-items-center'>
3735
<RemixUITerminalMenu {...props} />
36+
<RemixUITerminalMenuMaximize {...props} />
3837
<RemixUITerminalMenuToggle {...props} />
3938
</div>
4039
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { CustomTooltip } from '@remix-ui/helper'
2+
import React from 'react' // eslint-disable-line
3+
import { FormattedMessage } from 'react-intl'
4+
import { RemixUiTerminalProps } from '../types/terminalTypes'
5+
6+
export const RemixUITerminalMenuMaximize = (props: RemixUiTerminalProps) => {
7+
8+
async function handleMaximizeTerminal(): Promise<void> {
9+
if (props.maximizePanel) {
10+
await props.maximizePanel()
11+
}
12+
}
13+
14+
return (
15+
<>
16+
<CustomTooltip
17+
placement="top"
18+
tooltipId="terminalMaximize"
19+
tooltipClasses="text-nowrap"
20+
tooltipText={props.isMaximized ? "Minimize Panel" : "Maximize Panel"}
21+
>
22+
<div
23+
className="codicon-screen-icon mx-2"
24+
data-id="maximizeBottomPanel"
25+
onClick={handleMaximizeTerminal}
26+
style={{ cursor: 'pointer' }}
27+
>
28+
{props.isMaximized ? '\ueb4d' : '\ueb4c' /* Actual icons were not being rendered, so used unicode for codicon-screen-full & codicon-screen-normal icons*/ }
29+
</div>
30+
</CustomTooltip>
31+
</>
32+
)
33+
}

libs/remix-ui/terminal/src/lib/types/terminalTypes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,6 @@ export interface RemixUiTerminalProps {
3535
plugin: any,
3636
onReady: (api: any) => void,
3737
visible: boolean,
38+
isMaximized?: boolean,
39+
maximizePanel?: () => void,
3840
}

0 commit comments

Comments
 (0)