Skip to content

Commit

Permalink
slim down the menu boilerplate \o/
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jun 23, 2016
1 parent 8cb5c49 commit 027d497
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 56 deletions.
52 changes: 1 addition & 51 deletions menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ if (process.platform !== 'darwin') {
helpSubmenu.push({
type: 'separator'
}, {
label: process.platform === 'linux' ? 'About' : `About ${appName}`,
role: 'about',
click() {
electron.dialog.showMessageBox({
title: `About ${appName}`,
Expand All @@ -88,7 +88,6 @@ const darwinTpl = [
label: appName,
submenu: [
{
label: `About ${appName}`,
role: 'about'
},
{
Expand Down Expand Up @@ -121,33 +120,25 @@ const darwinTpl = [
type: 'separator'
},
{
label: 'Services',
role: 'services',
submenu: []
},
{
type: 'separator'
},
{
label: `Hide ${appName}`,
accelerator: 'Cmd+H',
role: 'hide'
},
{
label: 'Hide Others',
accelerator: 'Cmd+Shift+H',
role: 'hideothers'
},
{
label: 'Show All',
role: 'unhide'
},
{
type: 'separator'
},
{
label: `Quit ${appName}`,
accelerator: 'Cmd+Q',
role: 'quit'
}
]
Expand Down Expand Up @@ -192,45 +183,30 @@ const darwinTpl = [
label: 'Edit',
submenu: [
{
label: 'Undo',
accelerator: 'Cmd+Z',
role: 'undo'
},
{
label: 'Redo',
accelerator: 'Shift+Cmd+Z',
role: 'redo'
},
{
type: 'separator'
},
{
label: 'Cut',
accelerator: 'Cmd+X',
role: 'cut'
},
{
label: 'Copy',
accelerator: 'Cmd+C',
role: 'copy'
},
{
label: 'Paste',
accelerator: 'Cmd+V',
role: 'paste'
},
{
label: 'Paste and Match Style',
accelerator: 'Shift+Cmd+V',
role: 'pasteandmatchstyle'
},
{
label: 'Delete',
role: 'delete'
},
{
label: 'Select All',
accelerator: 'Cmd+A',
role: 'selectall'
}
]
Expand All @@ -240,17 +216,12 @@ const darwinTpl = [
submenu: viewSubmenu
},
{
label: 'Window',
role: 'window',
submenu: [
{
label: 'Minimize',
accelerator: 'Cmd+M',
role: 'minimize'
},
{
label: 'Close',
accelerator: 'Cmd+W',
role: 'close'
},
{
Expand Down Expand Up @@ -281,17 +252,14 @@ const darwinTpl = [
type: 'separator'
},
{
label: 'Bring All to Front',
role: 'front'
},
{
accelerator: 'Ctrl+Cmd+F',
role: 'togglefullscreen'
}
]
},
{
label: 'Help',
role: 'help',
submenu: helpSubmenu
}
Expand Down Expand Up @@ -355,7 +323,6 @@ const otherTpl = [
type: 'separator'
},
{
label: process.platform === 'linux' ? 'Quit' : 'Exit',
role: 'quit'
}
]
Expand All @@ -364,49 +331,33 @@ const otherTpl = [
label: 'Edit',
submenu: [
{
label: 'Undo',
accelerator: 'Ctrl+Z',
role: 'undo'
},
{
label: 'Redo',
accelerator: 'Shift+Ctrl+Z',
role: 'redo'
},
{
type: 'separator'
},
{
label: 'Cut',
accelerator: 'Ctrl+X',
role: 'cut'
},
{
label: 'Copy',
accelerator: 'Ctrl+C',
role: 'copy'
},
{
label: 'Paste',
accelerator: 'Ctrl+V',
role: 'paste'
},
{
label: 'Paste and Match Style',
accelerator: 'Shift+Ctrl+V',
role: 'pasteandmatchstyle'
},
{
label: 'Delete',
accelerator: 'Delete',
role: 'delete'
},
{
type: 'separator'
},
{
label: 'Select All',
accelerator: 'Ctrl+A',
role: 'selectall'
},
{
Expand All @@ -426,7 +377,6 @@ const otherTpl = [
submenu: viewSubmenu
},
{
label: 'Help',
role: 'help',
submenu: helpSubmenu
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
},
"devDependencies": {
"electron-packager": "^7.0.0",
"electron-prebuilt": "^1.2.4",
"electron-prebuilt": "^1.2.5",
"xo": "*"
},
"xo": {
Expand Down
5 changes: 1 addition & 4 deletions tray.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ exports.create = win => {
type: 'separator'
},
{
label: 'Quit',
click() {
app.quit();
}
role: 'quit'
}
]);

Expand Down

0 comments on commit 027d497

Please sign in to comment.