Skip to content
This repository has been archived by the owner on Jan 8, 2022. It is now read-only.

feat: Users can now toggle the header on and off. #140

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = new Config({
shortcut: {
toggleApp: null
},
showHeader: true,
mode: 'dark'
}
})
3 changes: 2 additions & 1 deletion app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ function createMainWindow() {
},
webPreferences: {
nodeIntegration: true,
webviewTag: true
webviewTag: true,
// preload: "renderer/preload-index.js"
}
})

Expand Down
12 changes: 11 additions & 1 deletion app/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ const {
shell,
globalShortcut,
BrowserWindow,
dialog
dialog,
ipcMain: ipc
} = require('electron')
const axios = require('axios')
const semverCompare = require('semver-compare')
Expand Down Expand Up @@ -48,6 +49,15 @@ function createMenu(opts) {
shell.openItem(configDir('custom.js'))
}
},
{
label: 'Toggle Header Bar',
click() {
const [win] = BrowserWindow.getAllWindows();
const showHeader = !config.get("showHeader");
win.webContents.send("toggle-header", showHeader);
config.set("showHeader", showHeader);
}
},
{
label: `${
toggleAppAcceleratorRegistered ? 'Disable' : 'Enable'
Expand Down
6 changes: 6 additions & 0 deletions app/renderer/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,16 @@ function ensureCustomFiles() {
}
}

ipc.on('toggle-header', (event, state) => {
const headerBar = document.getElementsByTagName("header")[0];
headerBar.style.display = state ? "" : "none";
});

function createHeader() {
const header = document.createElement('header')
header.className = 'header'
header.innerHTML = '<h1 id="title" class="app-title">Loading DevDocs...</h1>'
header.style.display = config.get("showHeader") ? "" : "none";
header.addEventListener('dblclick', () => {
win.maximize()
})
Expand Down