11import { 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
33import { FormattedMessage } from 'react-intl'
4- import { TerminalContext } from '../context'
5- import { RemixUiTerminalProps , TOGGLE } from '../types/terminalTypes'
4+ import { RemixUiTerminalProps } from '../types/terminalTypes'
65export 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