11<script setup lang="ts">
22const route = useRoute ()
33const isHome = computed (() => route .name === ' index' )
4+
5+ const modalRef = useTemplateRef (' modalRef' )
6+ const showModal = () => modalRef .value ?.showModal ?.()
47 </script >
58
69<template >
@@ -36,6 +39,73 @@ const isHome = computed(() => route.name === 'index')
3639 <LinkBase to =" https://chat.npmx.dev" >
3740 {{ $t('footer.chat') }}
3841 </LinkBase >
42+
43+ <button
44+ type =" button"
45+ class =" group inline-flex gap-x-1 items-center justify-center underline-offset-[0.2rem] underline decoration-1 decoration-fg/30 font-mono text-fg hover:(decoration-accent text-accent) focus-visible:(decoration-accent text-accent) transition-colors duration-200"
46+ @click.prevent =" showModal"
47+ aria-haspopup =" dialog"
48+ >
49+ {{ $t('footer.keyboard_shortcuts') }}
50+ </button >
51+
52+ <Modal
53+ ref =" modalRef"
54+ :modalTitle =" $t('footer.keyboard_shortcuts')"
55+ class =" w-auto max-w-lg"
56+ >
57+ <p class =" mb-2 font-mono text-fg-subtle" >
58+ {{ $t('shortcuts.section.global') }}
59+ </p >
60+ <ul class =" mb-6 flex flex-col gap-2" >
61+ <li class =" flex gap-2 items-center" >
62+ <kbd class =" kbd" >/</kbd >
63+ <span >{{ $t('shortcuts.focus_search') }}</span >
64+ </li >
65+ <li class =" flex gap-2 items-center" >
66+ <kbd class =" kbd" >?</kbd >
67+ <span >{{ $t('shortcuts.show_kbd_hints') }}</span >
68+ </li >
69+ <li class =" flex gap-2 items-center" >
70+ <kbd class =" kbd" >,</kbd >
71+ <span >{{ $t('shortcuts.settings') }}</span >
72+ </li >
73+ <li class =" flex gap-2 items-center" >
74+ <kbd class =" kbd" >c</kbd >
75+ <span >{{ $t('shortcuts.compare') }}</span >
76+ </li >
77+ </ul >
78+ <p class =" mb-2 font-mono text-fg-subtle" >
79+ {{ $t('shortcuts.section.search') }}
80+ </p >
81+ <ul class =" mb-6 flex flex-col gap-2" >
82+ <li class =" flex gap-2 items-center" >
83+ <kbd class =" kbd" >↑</kbd >/<kbd class =" kbd" >↓</kbd >
84+ <span >{{ $t('shortcuts.navigate_results') }}</span >
85+ </li >
86+ <li class =" flex gap-2 items-center" >
87+ <kbd class =" kbd" >Enter</kbd >
88+ <span >{{ $t('shortcuts.go_to_result') }}</span >
89+ </li >
90+ </ul >
91+ <p class =" mb-2 font-mono text-fg-subtle" >
92+ {{ $t('shortcuts.section.package') }}
93+ </p >
94+ <ul class =" mb-6 flex flex-col gap-2" >
95+ <li class =" flex gap-2 items-center" >
96+ <kbd class =" kbd" >.</kbd >
97+ <span >{{ $t('shortcuts.open_code_view') }}</span >
98+ </li >
99+ <li class =" flex gap-2 items-center" >
100+ <kbd class =" kbd" >d</kbd >
101+ <span >{{ $t('shortcuts.open_docs') }}</span >
102+ </li >
103+ <li class =" flex gap-2 items-center" >
104+ <kbd class =" kbd" >c</kbd >
105+ <span >{{ $t('shortcuts.compare_from_package') }}</span >
106+ </li >
107+ </ul >
108+ </Modal >
39109 </div >
40110 </div >
41111 <p class =" text-xs text-fg-muted text-center sm:text-start m-0" >
@@ -45,3 +115,9 @@ const isHome = computed(() => route.name === 'index')
45115 </div >
46116 </footer >
47117</template >
118+
119+ <style scoped>
120+ .kbd {
121+ @apply items-center justify-center text-sm text-fg bg-bg-muted border border-border rounded px- 2;
122+ }
123+ </style >
0 commit comments