From f2f59552641b6ef7c253d159ab01e7be73e13b19 Mon Sep 17 00:00:00 2001 From: Benedict Aas Date: Fri, 27 Oct 2017 19:41:47 +0100 Subject: [PATCH] feat(GUI): use tabindex and focus to navigate (#1745) * feat(GUI): use tabindex and focus to navigate We make navigating with the tab key easier by highlighting focused elements more visibly, adding `tabindex` attributes to elements, and making `open-external` links respond to keyboard events. Change-Type: minor Changelog-Entry: Improve tab-key navigation through tabindex and visual improvements. Connects-To: https://github.com/resin-io/etcher/issues/1734 * outline with 10s timeout * use orange "warning colour" as outline * smaller outline on settings buttons, fix order on settings page * allow selection in drive-selector * fix typo, better tabindexes --- .../controllers/drive-selector.js | 25 ++++++++++++++ .../templates/drive-selector-modal.tpl.html | 15 +++++--- .../templates/warning-modal.tpl.html | 6 +++- lib/gui/css/desktop.css | 6 ---- lib/gui/css/main.css | 34 +++++++++++-------- lib/gui/index.html | 31 ++++++++++++----- .../open-external/directives/open-external.js | 13 +++++++ lib/gui/pages/main/templates/main.tpl.html | 5 +++ .../settings/templates/settings.tpl.html | 5 +++ lib/gui/scss/components/_button.scss | 11 ++---- lib/gui/scss/main.scss | 16 +++++++++ 11 files changed, 123 insertions(+), 44 deletions(-) diff --git a/lib/gui/components/drive-selector/controllers/drive-selector.js b/lib/gui/components/drive-selector/controllers/drive-selector.js index 09cd5e54..2cc61249 100644 --- a/lib/gui/components/drive-selector/controllers/drive-selector.js +++ b/lib/gui/components/drive-selector/controllers/drive-selector.js @@ -251,4 +251,29 @@ module.exports = function ( this.getDriveStatuses = this.memoizeImmutableListReference((drive) => { return this.constraints.getDriveImageCompatibilityStatuses(drive, this.state.getImage()) }) + + /** + * @summary Keyboard event drive toggling + * @function + * @public + * + * @description + * Keyboard-event specific entry to the toggleDrive function. + * + * @param {Object} drive - drive + * @param {Object} $event - event + * + * @example + *
+ * Tab-select me and press enter or space! + *
+ */ + this.keyboardToggleDrive = (drive, $event) => { + console.log($event.keyCode) + const ENTER = 13 + const SPACE = 32 + if (_.includes([ ENTER, SPACE ], $event.keyCode)) { + this.toggleDrive(drive) + } + } } diff --git a/lib/gui/components/drive-selector/templates/drive-selector-modal.tpl.html b/lib/gui/components/drive-selector/templates/drive-selector-modal.tpl.html index ce8a1a07..7507df61 100644 --- a/lib/gui/components/drive-selector/templates/drive-selector-modal.tpl.html +++ b/lib/gui/components/drive-selector/templates/drive-selector-modal.tpl.html @@ -1,6 +1,6 @@ @@ -86,6 +90,7 @@