From e09db23049d3e880e5bac9c90e015c6ad2e7c289 Mon Sep 17 00:00:00 2001 From: radibit Date: Mon, 25 Jul 2016 23:56:13 +0200 Subject: [PATCH 1/8] create helper window and add keyboard shortcuts - fix #7 --- app/electron.js | 23 +++- app/main/menu.js | 5 + app/src/App.vue | 6 +- app/src/components/AboutView.vue | 31 +---- app/src/components/HelpView.vue | 127 ++++++++++++++++++++ app/src/routes.js | 4 + app/src/styles/components/_drag-handle.scss | 12 ++ app/src/styles/components/_logo.scss | 13 ++ 8 files changed, 190 insertions(+), 31 deletions(-) create mode 100644 app/src/components/HelpView.vue create mode 100644 app/src/styles/components/_drag-handle.scss create mode 100644 app/src/styles/components/_logo.scss diff --git a/app/electron.js b/app/electron.js index 6e26908..5749f8f 100644 --- a/app/electron.js +++ b/app/electron.js @@ -8,6 +8,7 @@ const windowStateKeeper = require( 'electron-window-state' ); let mainWindows = []; let aboutWindow; +let helpWindow; let config = {}; // fix path to guarantee that npm and node are available @@ -20,10 +21,12 @@ if ( process.env.NODE_ENV === 'development' ) { config = require( '../config' ).config; config.url = `http://localhost:${ config.port }`; config.aboutUrl = `http://localhost:${ config.port }#!/about`; + config.helpUrl = `http://localhost:${ config.port }#!/help`; } else { config.devtron = false; config.url = `file://${ __dirname }/dist/index.html`; config.aboutUrl = `file://${ __dirname }/dist/index.html#!/about`; + config.helpUrl = `file://${ __dirname }/dist/index.html#!/help`; } ipcMain.on( 'updatedAppSetting', ( event, key, value ) => { @@ -59,6 +62,23 @@ function openAboutWindow() { } } +function openHelpWindow() { + if ( ! helpWindow ) { + helpWindow = new BrowserWindow( { + height : 500, + width : 475, + titleBarStyle : 'hidden', + resizable : false + } ); + + helpWindow.loadURL( config.helpUrl ); + + helpWindow.on( 'closed', () => helpWindow = null ); + } else { + helpWindow.focus(); + } +} + /** * */ @@ -114,7 +134,8 @@ function createWindow( event, hash ) { if ( mainWindows.length === 1 ) { menu.init( { createWindow, - openAboutWindow + openAboutWindow, + openHelpWindow } ); } diff --git a/app/main/menu.js b/app/main/menu.js index 7261df0..9f8a1cb 100644 --- a/app/main/menu.js +++ b/app/main/menu.js @@ -71,6 +71,11 @@ module.exports = { { role : 'help', submenu : [ + { + label : 'Keyboard Shortcuts', + accelerator : 'CmdOrCtrl+/', + click() { options.openHelpWindow(); } + }, { label : 'Learn More', click() { electron.shell.openExternal( 'http://electron.atom.io' ); } diff --git a/app/src/App.vue b/app/src/App.vue index 7d33bb9..e13d69f 100644 --- a/app/src/App.vue +++ b/app/src/App.vue @@ -8,6 +8,8 @@ @import './styles/objects/paragraphs'; @import './styles/objects/lists'; @import './styles/objects/small'; + @import './styles/components/drag-handle'; + @import './styles/components/logo'; @import './styles/animations/move-down'; @import './styles/transitions/slide-right--slide-left'; @import './styles/transitions/slide-up--slide-down'; @@ -138,7 +140,9 @@ From cecf3bf3751fccd218054748970483c33be8707f Mon Sep 17 00:00:00 2001 From: radibit Date: Tue, 26 Jul 2016 18:48:06 +0200 Subject: [PATCH 3/8] create groups for the help page - fix #7 --- app/electron.js | 2 +- app/src/components/HelpView.vue | 101 ++++++++++++++++++-------------- 2 files changed, 57 insertions(+), 46 deletions(-) diff --git a/app/electron.js b/app/electron.js index 7285d0b..96d176b 100644 --- a/app/electron.js +++ b/app/electron.js @@ -21,7 +21,7 @@ const staticWindows = { help : { config : { height : 625, - width : 475, + width : 725, titleBarStyle : 'hidden', resizable : false }, diff --git a/app/src/components/HelpView.vue b/app/src/components/HelpView.vue index 21236ef..5b8754f 100644 --- a/app/src/components/HelpView.vue +++ b/app/src/components/HelpView.vue @@ -11,12 +11,12 @@ dt { clear : both; - width : 20%; + width : 25%; padding : .5em 0; } dd { - width : 80%; + width : 75%; text-align : left; padding : .5em 0 .5em .5em; @@ -100,48 +100,59 @@

Keyboard Shortcuts

-
-
- - -
-
Navigate between the home and project screens
- -
- - -
-
Navigate between the available projects and commands
- -
- tab -
-
Focus on the next action
- -
- shift + tab -
-
Focus on the previous action
- -
- esc -
-
Close a running command
- -
- -
-
Run a given command when in project panel
- -
- -
-
Terminate a running command
- -
- right mouse click -
-
Display more options when click on project
-
+
+
+

Home & Projects

+ +
+
+ + +
+
Navigate between the home and project panels
+ +
+ + +
+
Navigate between the available projects and commands
+ +
+ tab +
+
Focus on the next action
+ +
+ shift + tab +
+
Focus on the previous action
+ +
+ right mouse click +
+
Display more options when click on a project
+
+
+
+

Commands

+ +
+
+ esc +
+
Close a running command
+ +
+ +
+
Run a given command when in project panel
+ +
+ +
+
Terminate a running command
+
+
+
From 59e6cef93731d01d9b3b8995a98e3a1cdda618b2 Mon Sep 17 00:00:00 2001 From: radibit Date: Tue, 26 Jul 2016 23:09:49 +0200 Subject: [PATCH 4/8] change the style of the help window - #7 --- app/electron.js | 10 ++-- app/main/menu.js | 9 ++- app/src/App.vue | 1 + app/src/components/HelpView.vue | 103 ++++++++++++++++++-------------- app/src/styles/_utils.scss | 10 +++- 5 files changed, 78 insertions(+), 55 deletions(-) diff --git a/app/electron.js b/app/electron.js index 8c7dcb6..f5996a4 100644 --- a/app/electron.js +++ b/app/electron.js @@ -16,28 +16,26 @@ const staticWindows = { titleBarStyle : 'hidden', resizable : false }, - hash : '#!/about', + hash : '#!/about', initializedWindow : null }, help : { config : { height : 625, - width : 725, + width : 625, backgroundColor : '#f1f1f1', titleBarStyle : 'hidden', resizable : false }, - hash : '#!/help', + hash : '#!/help', initializedWindow : null } }; let mainWindows = []; -let aboutWindow; -let helpWindow; let config = {}; let baseUrl = { - development : ``, + development : '', production : `file://${ __dirname }/dist/index.html` }; diff --git a/app/main/menu.js b/app/main/menu.js index d43d779..c7384fe 100644 --- a/app/main/menu.js +++ b/app/main/menu.js @@ -1,4 +1,5 @@ const electron = require( 'electron' ); +const shell = electron.shell; const Menu = electron.Menu; module.exports = { @@ -72,9 +73,13 @@ module.exports = { role : 'help', submenu : [ { - label : 'Keyboard Shortcuts', + label : 'Shortcuts', accelerator : 'CmdOrCtrl+/', click() { options.openStaticWindow( 'help' ); } + }, + { + label : 'Report an Issue', + click() { shell.openExternal( 'https://github.com/stefanjudis/forrest/issues' ) } } ] } @@ -93,7 +98,7 @@ module.exports = { type : 'separator' }, { - label : 'Open new window', + label : 'Open New Window', accelerator : 'CmdOrCtrl+N', click() { options.createWindow(); } }, diff --git a/app/src/App.vue b/app/src/App.vue index e13d69f..10da1ec 100644 --- a/app/src/App.vue +++ b/app/src/App.vue @@ -35,6 +35,7 @@ --svg-fill : #2a333c; --svg-fill-red : var(--npm-red); --svg-fill-green : #399039; + --svg-fill-white : #ffffff; --svg-fill-bright : var(--main-bg-color); diff --git a/app/src/components/HelpView.vue b/app/src/components/HelpView.vue index 5b8754f..4d2236d 100644 --- a/app/src/components/HelpView.vue +++ b/app/src/components/HelpView.vue @@ -7,8 +7,6 @@ text-align : center; &--definitionList { - font-size : .9em; - dt { clear : both; width : 25%; @@ -16,6 +14,8 @@ } dd { + font-size : .9em; + width : 75%; text-align : left; @@ -31,17 +31,12 @@ &--key { display : inline-block; - background-color : var(--header-background); - border-radius : 2px; - - color : var( --code-color ); - - padding : .25em .5em; + font-size : 1em; + font-weight : bold; + color : var(--header-background); + text-align : center; - text-align : center; - - min-width : 2em; - min-height : 2em; + min-height : 2em; } } @@ -97,62 +92,78 @@
-

Keyboard Shortcuts

+

Shortcuts

-
+
-

Home & Projects

+

Home

-
- - -
-
Navigate between the home and project panels
- -
- - -
-
Navigate between the available projects and commands
- -
- tab +
+ + + + +
-
Focus on the next action
+
Show more project options
-
- shift + tab +
+ + + +
-
Focus on the previous action
+
Open project
-
- right mouse click +
+ + + + + + + +
-
Display more options when click on a project
+
Navigate through projects
-
-

Commands

+
+

Projects

- esc + esc
-
Close a running command
+
Terminate running command
-
- +
+ + + +
-
Run a given command when in project panel
+
Go Home / Terminate running command
-
- +
+ + + + + + + +
-
Terminate a running command
+
Navigate through commands
+ +

+ To reach other actions use the tab key when needed. +

diff --git a/app/src/styles/_utils.scss b/app/src/styles/_utils.scss index 33546f2..ced248a 100644 --- a/app/src/styles/_utils.scss +++ b/app/src/styles/_utils.scss @@ -85,6 +85,10 @@ fill : var(--svg-fill-green); } +.u-fillWhite { + fill : var(--svg-fill-white); +} + .u-fullHeight { height : 100%; } @@ -110,4 +114,8 @@ .u-fontSizeSmall { font-size : .9em; -} \ No newline at end of file +} + +.u-textTransformUppercase { + text-transform : uppercase; +} From 096e411777fdbc24e5ff475793a882136d70a1ea Mon Sep 17 00:00:00 2001 From: radibit Date: Tue, 26 Jul 2016 23:14:12 +0200 Subject: [PATCH 5/8] fix lint issues - #7 --- app/main/menu.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/main/menu.js b/app/main/menu.js index c7384fe..6f64741 100644 --- a/app/main/menu.js +++ b/app/main/menu.js @@ -78,8 +78,8 @@ module.exports = { click() { options.openStaticWindow( 'help' ); } }, { - label : 'Report an Issue', - click() { shell.openExternal( 'https://github.com/stefanjudis/forrest/issues' ) } + label : 'Report an Issue', + click() { shell.openExternal( 'https://github.com/stefanjudis/forrest/issues' ); } } ] } From 6a16dcc8816439a2451d2e964fd54d7b1c219ace Mon Sep 17 00:00:00 2001 From: radibit Date: Mon, 25 Jul 2016 23:56:13 +0200 Subject: [PATCH 6/8] create helper window, document shortcuts and update styles - fix #7 --- app/electron.js | 78 ++++++--- app/main/menu.js | 14 +- app/src/App.vue | 7 +- app/src/components/AboutView.vue | 31 +--- app/src/components/AppView/Settings.vue | 2 +- app/src/components/HelpView.vue | 169 ++++++++++++++++++++ app/src/routes.js | 4 + app/src/styles/_utils.scss | 10 +- app/src/styles/components/_drag-handle.scss | 12 ++ app/src/styles/components/_logo.scss | 13 ++ 10 files changed, 283 insertions(+), 57 deletions(-) create mode 100644 app/src/components/HelpView.vue create mode 100644 app/src/styles/components/_drag-handle.scss create mode 100644 app/src/styles/components/_logo.scss diff --git a/app/electron.js b/app/electron.js index 6e26908..f5996a4 100644 --- a/app/electron.js +++ b/app/electron.js @@ -6,9 +6,38 @@ const menu = require( './main/menu' ); const fixPath = require( 'fix-path' ); const windowStateKeeper = require( 'electron-window-state' ); +// configuration for the available static windows +const staticWindows = { + about : { + config : { + height : 625, + width : 475, + backgroundColor : '#f1f1f1', + titleBarStyle : 'hidden', + resizable : false + }, + hash : '#!/about', + initializedWindow : null + }, + help : { + config : { + height : 625, + width : 625, + backgroundColor : '#f1f1f1', + titleBarStyle : 'hidden', + resizable : false + }, + hash : '#!/help', + initializedWindow : null + } +}; + let mainWindows = []; -let aboutWindow; -let config = {}; +let config = {}; +let baseUrl = { + development : '', + production : `file://${ __dirname }/dist/index.html` +}; // fix path to guarantee that npm and node are available fixPath(); @@ -17,13 +46,13 @@ fixPath(); app.commandLine.appendSwitch( '--enable-experimental-web-platform-features' ); if ( process.env.NODE_ENV === 'development' ) { - config = require( '../config' ).config; - config.url = `http://localhost:${ config.port }`; - config.aboutUrl = `http://localhost:${ config.port }#!/about`; + config = require( '../config' ).config; + baseUrl.development = `http://localhost:${ config.port }`; + + config.url = `${ baseUrl.development }`; } else { config.devtron = false; - config.url = `file://${ __dirname }/dist/index.html`; - config.aboutUrl = `file://${ __dirname }/dist/index.html#!/about`; + config.url = `${ baseUrl.production }`; } ipcMain.on( 'updatedAppSetting', ( event, key, value ) => { @@ -42,20 +71,26 @@ ipcMain.on( 'updatedRepos', ( event, reposString ) => { ipcMain.on( 'openNewWindow', createWindow ); -function openAboutWindow() { - if ( ! aboutWindow ) { - aboutWindow = new BrowserWindow( { - height : 625, - width : 475, - titleBarStyle : 'hidden', - resizable : false - } ); - - aboutWindow.loadURL( config.aboutUrl ); - - aboutWindow.on( 'closed', () => aboutWindow = null ); +/** + * Open a selected static window + * + * @param {String} type - name of the selected window type + */ +function openStaticWindow( type ) { + if ( ! staticWindows[ type ].initializedWindow ) { + staticWindows[ type ].initializedWindow = new BrowserWindow( + staticWindows[ type ].config + ); + + staticWindows[ type ].initializedWindow.loadURL( + `${ config.url }` + staticWindows[ type ].hash + ); + + staticWindows[ type ].initializedWindow.on( + 'closed', () => staticWindows[ type ].initializedWindow = null + ); } else { - aboutWindow.focus(); + staticWindows[ type ].initializedWindow.focus(); } } @@ -76,6 +111,7 @@ function createWindow( event, hash ) { width : mainWindowState.width, x : mainWindowState.x, y : mainWindowState.y, + backgroundColor : '#f1f1f1', minWidth : 250, titleBarStyle : 'hidden', 'web-preferences' : { @@ -114,7 +150,7 @@ function createWindow( event, hash ) { if ( mainWindows.length === 1 ) { menu.init( { createWindow, - openAboutWindow + openStaticWindow } ); } diff --git a/app/main/menu.js b/app/main/menu.js index 7261df0..6f64741 100644 --- a/app/main/menu.js +++ b/app/main/menu.js @@ -1,4 +1,5 @@ const electron = require( 'electron' ); +const shell = electron.shell; const Menu = electron.Menu; module.exports = { @@ -72,8 +73,13 @@ module.exports = { role : 'help', submenu : [ { - label : 'Learn More', - click() { electron.shell.openExternal( 'http://electron.atom.io' ); } + label : 'Shortcuts', + accelerator : 'CmdOrCtrl+/', + click() { options.openStaticWindow( 'help' ); } + }, + { + label : 'Report an Issue', + click() { shell.openExternal( 'https://github.com/stefanjudis/forrest/issues' ); } } ] } @@ -86,13 +92,13 @@ module.exports = { submenu : [ { label : 'About Forrest', - click() { options.openAboutWindow(); } + click() { options.openStaticWindow( 'about' ); } }, { type : 'separator' }, { - label : 'Open new window', + label : 'Open New Window', accelerator : 'CmdOrCtrl+N', click() { options.createWindow(); } }, diff --git a/app/src/App.vue b/app/src/App.vue index 7d33bb9..10da1ec 100644 --- a/app/src/App.vue +++ b/app/src/App.vue @@ -8,6 +8,8 @@ @import './styles/objects/paragraphs'; @import './styles/objects/lists'; @import './styles/objects/small'; + @import './styles/components/drag-handle'; + @import './styles/components/logo'; @import './styles/animations/move-down'; @import './styles/transitions/slide-right--slide-left'; @import './styles/transitions/slide-up--slide-down'; @@ -33,6 +35,7 @@ --svg-fill : #2a333c; --svg-fill-red : var(--npm-red); --svg-fill-green : #399039; + --svg-fill-white : #ffffff; --svg-fill-bright : var(--main-bg-color); @@ -138,7 +141,9 @@