From 021f1390ab17cad76ee8aec04f5afd8e6bdacbea Mon Sep 17 00:00:00 2001 From: Kushagra Gour Date: Sat, 27 Oct 2018 18:56:38 +0530 Subject: [PATCH] Add keyboard navigation to command palette. --- src/components/CommandPalette.jsx | 48 +++++++++++++++++----- src/components/Modal.jsx | 28 +++++++------ src/style.css | 67 ++++++++++++++++++++----------- 3 files changed, 98 insertions(+), 45 deletions(-) diff --git a/src/components/CommandPalette.jsx b/src/components/CommandPalette.jsx index f48a9fb..63b6ac7 100644 --- a/src/components/CommandPalette.jsx +++ b/src/components/CommandPalette.jsx @@ -7,6 +7,7 @@ import { SWITCH_FILE_EVENT } from '../commandPaletteService'; import { FileIcon } from './FileIcon'; +import { UP_KEY, DOWN_KEY, ENTER_KEY } from '../keyboardKeys'; function getFolder(filePath) { const split = filePath.split('/'); @@ -16,14 +17,19 @@ function getFolder(filePath) { } return ''; } -function Row({ item, onClick }) { +function Row({ item, onClick, isSelected }) { return (
  • - + {this.props.hideCloseButton ? null : ( + + )} {this.props.children} diff --git a/src/style.css b/src/style.css index 885dc92..a2c99de 100644 --- a/src/style.css +++ b/src/style.css @@ -1,5 +1,6 @@ :root { - --color-text: #d4cde9; + --color-text: #e2daf9; + --color-text-dark-1: #b3aec4; --color-bg: #252637; --color-popup: #3a2b63; --code-font-size: 16px; @@ -74,6 +75,10 @@ button { .d-i { display: inline; } + +.d-b { + display: block; +} .flex { display: flex; } @@ -1688,28 +1693,6 @@ body:not(.is-app) .show-when-app { .is-file-mode .hide-in-file-mode { display: none !important; } -@media screen and (max-width: 600px) { - body { - font-size: 70%; - } - - .main-header { - overflow-x: auto; - } - - .main-header__btn-wrap { - flex-shrink: 0; - } - - .modal__content { - padding: 1em; - } - - .saved-items-pane { - width: 77vw; - padding: 10px 20px; - } -} /* Codemirror themes basic bg styles. This is here so that there is no big FOUC while the theme CSS file is loading */ @@ -1807,3 +1790,41 @@ while the theme CSS file is loading */ .cm-s-midnight .CodeMirror-activeline-background { background: #253540; } +.command-palette__option-row { + padding: 4px 5px; + width: 100%; + text-align: left; + border: 0; + background: transparent; + color: var(--color-text); +} +.command-palette__option-row--selected { + background: rgba(0, 0, 0, 0.2); +} +.command-palette__option-subtitle { + color: var(--color-text-dark-1); + margin-left: 10px; + font-size: 0.8em; +} +@media screen and (max-width: 600px) { + body { + font-size: 70%; + } + + .main-header { + overflow-x: auto; + } + + .main-header__btn-wrap { + flex-shrink: 0; + } + + .modal__content { + padding: 1em; + } + + .saved-items-pane { + width: 77vw; + padding: 10px 20px; + } +}