Skip to content

Commit

Permalink
altair-graphql#1645 | Added 'Hide Docs' button to touchbar. Added log…
Browse files Browse the repository at this point in the history
…ic to only show 'Show Docs'/'Hide Docs', depending on the display status of the docs-viewer.
  • Loading branch information
joshwalters12 committed Apr 7, 2023
1 parent 79bc1fd commit a20bd08
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/altair-electron/src/app/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export class ActionManager {
this.windowInstance.webContents.send('show-docs', true);
}

hideDocs() {
this.windowInstance.webContents.send('show-docs', false);
}

showSettings() {
this.windowInstance.webContents.send('show-settings', true);
}
Expand Down
12 changes: 10 additions & 2 deletions packages/altair-electron/src/app/touchbar.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { TouchBar } from 'electron';
import { BrowserWindow, TouchBar } from 'electron';
import { ActionManager } from './actions';

const { TouchBarButton, TouchBarSpacer } = TouchBar;

export class TouchbarManager {
constructor(private actionManager: ActionManager) {}
constructor(private actionManager: ActionManager, private windowInstance: BrowserWindow) {}

createTouchBar() {
const sendRequestButton = new TouchBarButton({
Expand All @@ -20,9 +20,16 @@ export class TouchbarManager {

const showDocsButton = new TouchBarButton({
label: 'Show Docs',
enabled: !this.windowInstance.webContents.showDocs,
click: () => this.actionManager.showDocs(),
});

const hideDocsButton = new TouchBarButton({
label: 'Hide Docs',
enabled: this.windowInstance.webContents.showDocs,
click: () => this.actionManager.hideDocs(),
});

const spacer = new TouchBarSpacer({
size: 'flexible',
});
Expand All @@ -34,6 +41,7 @@ export class TouchbarManager {
spacer,
reloadDocsButton,
showDocsButton,
hideDocsButton,
],
});

Expand Down

0 comments on commit a20bd08

Please sign in to comment.