feat: 1-6 hotkeys switch columns (#888)

This commit is contained in:
Nolan Lawson 2019-01-13 14:02:08 -08:00 committed by GitHub
parent 6d1bb64bbb
commit 4a6f7b74a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 0 deletions

View file

@ -6,13 +6,18 @@
<Shortcut key="g c" on:pressed="goto('/community')"/>
<Shortcut key="s" on:pressed="goto('/search')"/>
<Shortcut key="h|?" on:pressed="showShortcutHelpDialog()"/>
{#each $navPages as navPage, i}
<Shortcut key={(i + 1).toString()} on:pressed="goto(navPage.href)" />
{/each}
<script>
import Shortcut from './shortcut/Shortcut'
import { goto } from '../../../__sapper__/client'
import { importShowShortcutHelpDialog } from './dialog/asyncDialogs'
import { store } from '../_store/store'
export default {
store: () => store,
components: {
Shortcut
},

View file

@ -3,6 +3,7 @@
<ul>
<li><kbd>s</kbd> to search</li>
<li><kbd>1</kbd> - <kbd>6</kbd> to switch columns</li>
<li><kbd>g</kbd> + <kbd>h</kbd> to go home</li>
<li><kbd>g</kbd> + <kbd>n</kbd> to go to the notifications page</li>
<li><kbd>g</kbd> + <kbd>l</kbd> to go to the local stream page</li>

View file

@ -93,3 +93,19 @@ test('Global shortcut has no effects while in modal dialog', async t => {
.pressKey('s') // now works
.expect(getUrl()).contains('/search')
})
test('Shortcut 1 goes to the home timeline', async t => {
await loginAsFoobar(t)
await t
.expect(getUrl()).eql('http://localhost:4002/')
.pressKey('1')
.expect(getUrl()).contains('/')
})
test('Shortcut 6 goes to the settings', async t => {
await loginAsFoobar(t)
await t
.expect(getUrl()).eql('http://localhost:4002/')
.pressKey('6')
.expect(getUrl()).contains('/settings')
})