Skip to content

Commit a28da89

Browse files
committed
maximize right side panel
1 parent 83e6610 commit a28da89

File tree

3 files changed

+85
-2
lines changed

3 files changed

+85
-2
lines changed

apps/remix-ide/src/app/components/right-side-panel.tsx

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,13 @@ export class RightSidePanel extends AbstractPanel {
2525
highlightStamp: number
2626
hiddenPlugin: any
2727
isHidden: boolean
28+
isMaximized: boolean
29+
maximizedState: { leftPanelHidden: boolean, terminalPanelHidden: boolean }
2830

2931
constructor() {
3032
super(rightSidePanel)
33+
this.isMaximized = false
34+
this.maximizedState = { leftPanelHidden: false, terminalPanelHidden: false }
3135
}
3236

3337
onActivation() {
@@ -225,6 +229,68 @@ export class RightSidePanel extends AbstractPanel {
225229
return this.isHidden
226230
}
227231

232+
async maximizePanel() {
233+
if (!this.isMaximized) {
234+
// Store the current state of panels before maximizing
235+
const leftPanelHidden = await this.call('sidePanel', 'isPanelHidden')
236+
const terminalPanelHidden = await this.call('terminal', 'isPanelHidden')
237+
238+
this.maximizedState = { leftPanelHidden, terminalPanelHidden }
239+
240+
// Hide left panel if it's visible
241+
if (!leftPanelHidden) {
242+
await this.call('sidePanel', 'togglePanel')
243+
}
244+
245+
// Hide terminal panel if it's visible
246+
if (!terminalPanelHidden) {
247+
await this.call('terminal', 'togglePanel')
248+
}
249+
250+
// Hide main panel (center panel with editor)
251+
const mainPanel = document.querySelector('#main-panel')
252+
mainPanel?.classList.add('d-none')
253+
254+
// Make right panel take full width
255+
const rightPanel = document.querySelector('#right-side-panel')
256+
rightPanel?.classList.add('right-panel-maximized')
257+
258+
this.isMaximized = true
259+
trackMatomoEvent(this, { category: 'topbar', action: 'rightSidePanel', name: 'maximized', isClick: false })
260+
this.emit('rightSidePanelMaximized')
261+
this.events.emit('rightSidePanelMaximized')
262+
} else {
263+
// Restore panels to their previous state
264+
const leftPanelHidden = await this.call('sidePanel', 'isPanelHidden')
265+
const terminalPanelHidden = await this.call('terminal', 'isPanelHidden')
266+
267+
// Restore left panel if it was visible before maximizing
268+
if (!this.maximizedState.leftPanelHidden && leftPanelHidden) {
269+
await this.call('sidePanel', 'togglePanel')
270+
}
271+
272+
// Restore terminal panel if it was visible before maximizing
273+
if (!this.maximizedState.terminalPanelHidden && terminalPanelHidden) {
274+
await this.call('terminal', 'togglePanel')
275+
}
276+
277+
// Show main panel
278+
const mainPanel = document.querySelector('#main-panel')
279+
mainPanel?.classList.remove('d-none')
280+
281+
// Remove full width from right panel
282+
const rightPanel = document.querySelector('#right-side-panel')
283+
rightPanel?.classList.remove('right-panel-maximized')
284+
285+
this.isMaximized = false
286+
trackMatomoEvent(this, { category: 'topbar', action: 'rightSidePanel', name: 'restored', isClick: false })
287+
this.emit('rightSidePanelRestored')
288+
this.events.emit('rightSidePanelRestored')
289+
}
290+
291+
this.renderComponent()
292+
}
293+
228294
highlight () {
229295
// If the right side panel is hidden, unhide it when a pinned icon is clicked
230296
if (this.isHidden) {
@@ -262,7 +328,7 @@ export class RightSidePanel extends AbstractPanel {
262328
}
263329

264330
updateComponent(state: any) {
265-
return <RemixPluginPanel header={<RemixUIPanelHeader plugins={state.plugins} pinView={this.pinView.bind(this)} unPinView={this.unPinView.bind(this)} togglePanel={this.togglePanel.bind(this)}></RemixUIPanelHeader>} { ...state } />
331+
return <RemixPluginPanel header={<RemixUIPanelHeader plugins={state.plugins} pinView={this.pinView.bind(this)} unPinView={this.unPinView.bind(this)} togglePanel={this.togglePanel.bind(this)} maximizePanel={this.maximizePanel.bind(this)} isMaximized={this.isMaximized}></RemixUIPanelHeader>} { ...state } />
266332
}
267333

268334
renderComponent() {

libs/remix-ui/app/src/lib/remix-app/style/remix-app.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ pre {
4949
transition : width 0.25s;
5050
padding-bottom : 1.4rem;
5151
}
52+
.right-panel-maximized {
53+
width : 100% !important;
54+
flex : 1;
55+
}
5256
.highlightcode {
5357
position : absolute;
5458
z-index : 20;

libs/remix-ui/panel/src/lib/plugins/panel-header.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ export interface RemixPanelProps {
1010
plugins: Record<string, PluginRecord>,
1111
pinView?: (profile: PluginRecord['profile'], view: PluginRecord['view']) => void,
1212
unPinView?: (profile: PluginRecord['profile']) => void,
13-
togglePanel?: () => void
13+
togglePanel?: () => void,
14+
maximizePanel?: () => void,
15+
isMaximized?: boolean
1416
}
1517
const RemixUIPanelHeader = (props: RemixPanelProps) => {
1618
const [plugin, setPlugin] = useState<PluginRecord>()
@@ -45,6 +47,10 @@ const RemixUIPanelHeader = (props: RemixPanelProps) => {
4547
props.togglePanel && props.togglePanel()
4648
}
4749

50+
const maximizePanelHandler = () => {
51+
props.maximizePanel && props.maximizePanel()
52+
}
53+
4854
const tooltipChild = <i className={`px-1 ms-2 pt-1 pb-2 ${!toggleExpander ? 'fas fa-angle-right' : 'fas fa-angle-down bg-light'}`} aria-hidden="true"></i>
4955

5056
const FilePanelHeading = () => {
@@ -99,6 +105,13 @@ const RemixUIPanelHeader = (props: RemixPanelProps) => {
99105
<div className="codicon codicon-layout-sidebar-left-dock ms-2 fs-6 fw-bold lh-1" style={{ marginTop: '2px' }}></div>
100106
</CustomTooltip>
101107
</div>
108+
<CustomTooltip placement="bottom-end" tooltipText={props.isMaximized ? "Restore Panels" : "Maximize Panel"}>
109+
<div
110+
className={`codicon ${props.isMaximized ? 'codicon-screen-normal' : 'codicon-screen-full'} ms-2 fs-5 fw-bold`}
111+
onClick={maximizePanelHandler}
112+
data-id="maximizeRightSidePanel"
113+
></div>
114+
</CustomTooltip>
102115
<CustomTooltip placement="bottom-end" tooltipText="Hide Panel">
103116
<div
104117
className="codicon codicon-close ms-2 fs-5 fw-bold"

0 commit comments

Comments
 (0)