Pinafore-Web-Client-Frontend/src/routes/_components/NavShortcuts.html

63 lines
2.2 KiB
HTML

<Shortcut key="g t" on:pressed="goto('/federated')"/>
<Shortcut key="g f" on:pressed="goto('/favorites')"/>
<Shortcut key="g l" on:pressed="goto('/local')"/>
<Shortcut key="g h" on:pressed="goto('/')"/>
<Shortcut key="g n" on:pressed="goto('/notifications')"/>
<Shortcut key="g c" on:pressed="goto('/community')"/>
<Shortcut key="g d" on:pressed="goto('/direct')"/>
<Shortcut key="s|/" on:pressed="goToSearch()"/>
<Shortcut key="h|?" on:pressed="showShortcutHelpDialog()"/>
<Shortcut key="c|7" on:pressed="showComposeDialog()"/>
{#if !$leftRightChangesFocus}
<Shortcut key="ArrowLeft" on:pressed="goLeftOrRight(true)" />
<Shortcut key="ArrowRight" on:pressed="goLeftOrRight(false)" />
{/if}
{#each $navPages as navPage, i}
<Shortcut key={(i + 1).toString()} on:pressed="goto(navPage.href)" />
{/each}
<script>
import Shortcut from './shortcut/Shortcut.html'
import { goto } from '../../../__sapper__/client.js'
import { importShowShortcutHelpDialog } from './dialog/asyncDialogs/importShowShortcutHelpDialog.js'
import { importShowComposeDialog } from './dialog/asyncDialogs/importShowComposeDialog.js'
import { store } from '../_store/store.js'
import { normalizePageName } from '../_utils/normalizePageName.js'
import { goToSearch } from '../_actions/goToSearch.js'
export default {
store: () => store,
components: {
Shortcut
},
methods: {
oncreate () {
console.log('nav shortcuts')
},
goto,
goToSearch,
async showShortcutHelpDialog () {
const showShortcutHelpDialog = await importShowShortcutHelpDialog()
showShortcutHelpDialog()
},
async showComposeDialog () {
const showComposeDialog = await importShowComposeDialog()
showComposeDialog()
},
goLeftOrRight (left) {
let { currentPage, navPages } = this.store.get()
currentPage = normalizePageName(currentPage)
const idx = navPages.findIndex(_ => _.name === currentPage)
if (idx === -1) {
return
}
if (left && idx > 0) {
goto(navPages[idx - 1].href)
} else if (!left && idx < navPages.length - 1) {
goto(navPages[idx + 1].href)
}
}
}
}
</script>