Skip to content

Commit 7fb19d4

Browse files
committed
hide terminal panel
1 parent c010eb2 commit 7fb19d4

File tree

2 files changed

+30
-9
lines changed

2 files changed

+30
-9
lines changed

apps/remix-ide/src/app/tabs/locales/en/terminal.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"terminal.welcomeText9": "The following libraries are accessible",
1717
"terminal.welcomeText10": "Type the library name to see available commands",
1818
"terminal.text1": "This type of command has been deprecated and is not functioning anymore. Please run remix.help() to list available commands.",
19-
"terminal.hideTerminal": "Hide Terminal",
19+
"terminal.hideTerminal": "Hide Panel",
2020
"terminal.showTerminal": "Show Terminal",
2121
"terminal.clearConsole": "Clear console",
2222
"terminal.pendingTransactions": "Pending Transactions",

libs/remix-ui/terminal/src/lib/components/remix-ui-terminal-menu-toggle.tsx

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,35 @@
11
import { CustomTooltip } from '@remix-ui/helper'
2-
import React, { useContext, useEffect } from 'react' // eslint-disable-line
2+
import React, { useEffect, useState } from 'react' // eslint-disable-line
33
import { FormattedMessage } from 'react-intl'
4-
import { TerminalContext } from '../context'
5-
import { RemixUiTerminalProps, TOGGLE } from '../types/terminalTypes'
4+
import { RemixUiTerminalProps } from '../types/terminalTypes'
65
export const RemixUITerminalMenuToggle = (props: RemixUiTerminalProps) => {
76

8-
const { terminalState, dispatch } = useContext(TerminalContext)
7+
const [isPanelHidden, setIsPanelHidden] = useState(false)
98

10-
function handleToggleTerminal(event: any): void {
11-
dispatch({ type: TOGGLE })
9+
useEffect(() => {
10+
// Initialize panel hidden state
11+
const initPanelState = async () => {
12+
const hidden = await props.plugin.call('terminal', 'isPanelHidden')
13+
setIsPanelHidden(hidden)
14+
}
15+
initPanelState()
16+
17+
// Listen for panel visibility changes
18+
const handlePanelShown = () => setIsPanelHidden(false)
19+
const handlePanelHidden = () => setIsPanelHidden(true)
20+
21+
props.plugin.on('terminal', 'terminalPanelShown', handlePanelShown)
22+
props.plugin.on('terminal', 'terminalPanelHidden', handlePanelHidden)
23+
24+
return () => {
25+
props.plugin.off('terminal', 'terminalPanelShown')
26+
props.plugin.off('terminal', 'terminalPanelHidden')
27+
}
28+
}, [])
29+
30+
async function handleToggleTerminal(): Promise<void> {
31+
// Toggle the bottom terminal panel using terminal-wrap component
32+
await props.plugin.call('terminal', 'togglePanel')
1233
}
1334

1435
return (
@@ -17,10 +38,10 @@ export const RemixUITerminalMenuToggle = (props: RemixUiTerminalProps) => {
1738
placement="top"
1839
tooltipId="terminalToggle"
1940
tooltipClasses="text-nowrap"
20-
tooltipText={terminalState.isOpen ? <FormattedMessage id="terminal.hideTerminal" /> : <FormattedMessage id="terminal.showTerminal" />}
41+
tooltipText={<FormattedMessage id="terminal.hideTerminal" />}
2142
>
2243
<i
23-
className={`mx-2 remix_ui_terminal_toggleTerminal fas ${terminalState.isOpen ? 'fa-angle-double-down' : 'fa-angle-double-up'}`}
44+
className={`mx-2 codicon codicon-close fw-bold fs-5`}
2445
data-id="terminalToggleIcon"
2546
onClick={handleToggleTerminal}
2647
></i>

0 commit comments

Comments
 (0)