Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions app/components/AppFooter.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,42 @@
<script setup lang="ts">
import { ref, computed } from 'vue'
import { onKeyDown } from '@vueuse/core'
import Modal from './Modal.client.vue'
Comment thread
whitep4nth3r marked this conversation as resolved.
Outdated

const route = useRoute()
const isHome = computed(() => route.name === 'index')

const triggerRef = ref<HTMLElement | null>(null)
Comment thread
whitep4nth3r marked this conversation as resolved.
Outdated
const modalRef = useTemplateRef<HTMLElement>('modalRef')
Comment thread
whitep4nth3r marked this conversation as resolved.
Outdated
const modalOpen = ref(false)

const togglePopover = (e?: Event) => {
e?.stopPropagation()
if (!modalOpen.value) {
modalRef.value?.showModal?.()

Check failure on line 16 in app/components/AppFooter.vue

View workflow job for this annotation

GitHub Actions / 💪 Type check

Property 'showModal' does not exist on type 'HTMLElement'.
modalOpen.value = true
} else {
modalRef.value?.close?.()

Check failure on line 19 in app/components/AppFooter.vue

View workflow job for this annotation

GitHub Actions / 💪 Type check

Property 'close' does not exist on type 'HTMLElement'. Did you mean 'closest'?
modalOpen.value = false
}
}

onKeyDown(
'Escape',
(e: KeyboardEvent) => {
if (!modalOpen.value) return
e.preventDefault()
e.stopImmediatePropagation()
modalRef.value?.close?.()

Check failure on line 30 in app/components/AppFooter.vue

View workflow job for this annotation

GitHub Actions / 💪 Type check

Property 'close' does not exist on type 'HTMLElement'. Did you mean 'closest'?
modalOpen.value = false
},
{ dedupe: true },
)

function onModalClosed() {
modalOpen.value = false
triggerRef.value?.focus?.()
}
</script>

<template>
Expand Down Expand Up @@ -33,6 +69,85 @@
<LinkBase to="https://chat.npmx.dev">
{{ $t('footer.chat') }}
</LinkBase>

<button
ref="triggerRef"
type="button"
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"
@click.prevent="togglePopover"
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
:aria-expanded="modalOpen ? 'true' : 'false'"
aria-haspopup="dialog"
>
{{ $t('footer.keyboard_shortcuts') }}
</button>

<Modal
ref="modalRef"
@close="onModalClosed"
:modalTitle="$t('footer.keyboard_shortcuts')"
class="w-auto max-w-lg"
>
<p class="mb-2 font-mono text-fg-subtle">
{{ $t('shortcuts.section.global') }}
</p>
<ul class="mb-6 flex flex-col gap-2">
<li class="flex gap-2 items-center">
<kbd
class="items-center justify-center text-sm text-fg bg-bg-muted border border-border rounded px-2"
>,</kbd
><span>{{ $t('shortcuts.settings') }}</span>
</li>
<li class="flex gap-2 items-center">
<kbd
class="items-center justify-center text-sm text-fg bg-bg-muted border border-border rounded px-2"
>c</kbd
><span>{{ $t('shortcuts.compare') }}</span>
</li>
</ul>
<p class="mb-2 font-mono text-fg-subtle">
{{ $t('shortcuts.section.search') }}
</p>
<ul class="mb-6 flex flex-col gap-2">
<li class="flex gap-2 items-center">
<kbd
class="items-center justify-center text-sm text-fg bg-bg-muted border border-border rounded px-2"
>↑</kbd
>/<kbd
class="items-center justify-center text-sm text-fg bg-bg-muted border border-border rounded px-2"
>↓</kbd
><span>{{ $t('shortcuts.navigate_results') }}</span>
</li>
<li class="flex gap-2 items-center">
<kbd
class="items-center justify-center text-sm text-fg bg-bg-muted border border-border rounded px-2"
>Enter</kbd
><span>{{ $t('shortcuts.go_to_result') }}</span>
</li>
</ul>
<p class="mb-2 font-mono text-fg-subtle">
{{ $t('shortcuts.section.package') }}
</p>
<ul class="mb-6 flex flex-col gap-2">
<li class="flex gap-2 items-center">
<kbd
class="items-center justify-center text-sm text-fg bg-bg-muted border border-border rounded px-2"
>.</kbd
><span>{{ $t('shortcuts.open_code_view') }}</span>
</li>
<li class="flex gap-2 items-center">
<kbd
class="items-center justify-center text-sm text-fg bg-bg-muted border border-border rounded px-2"
>d</kbd
><span>{{ $t('shortcuts.open_docs') }}</span>
</li>
<li class="flex gap-2 items-center">
<kbd
class="items-center justify-center text-sm text-fg bg-bg-muted border border-border rounded px-2"
>c</kbd
><span>{{ $t('shortcuts.open_compare_prefilled') }}</span>
</li>
</ul>
</Modal>
</div>
</div>
<p class="text-xs text-fg-muted text-center sm:text-start m-0">
Expand Down
17 changes: 16 additions & 1 deletion i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,22 @@
"docs": "docs",
"source": "source",
"social": "social",
"chat": "chat"
"chat": "chat",
"keyboard_shortcuts": "keyboard shortcuts"
},
"shortcuts": {
"section": {
"global": "Global",
"search": "Search",
"package": "Package"
},
"settings": "Open settings",
"compare": "Open compare",
"navigate_results": "Navigate results",
"go_to_result": "Go to result",
"open_code_view": "Open code view",
"open_docs": "Open docs",
"open_compare_prefilled": "Open compare (prefilled with current package)"
},
"search": {
"label": "Search npm packages",
Expand Down
17 changes: 16 additions & 1 deletion lunaria/files/en-GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,22 @@
"docs": "docs",
"source": "source",
"social": "social",
"chat": "chat"
"chat": "chat",
"keyboard_shortcuts": "keyboard shortcuts"
},
"shortcuts": {
"section": {
"global": "Global",
"search": "Search",
"package": "Package"
},
"settings": "Open settings",
"compare": "Open compare",
"navigate_results": "Navigate results",
"go_to_result": "Go to result",
"open_code_view": "Open code view",
"open_docs": "Open docs",
"open_compare_prefilled": "Open compare (prefilled with current package)"
},
"search": {
"label": "Search npm packages",
Expand Down
17 changes: 16 additions & 1 deletion lunaria/files/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,22 @@
"docs": "docs",
"source": "source",
"social": "social",
"chat": "chat"
"chat": "chat",
"keyboard_shortcuts": "keyboard shortcuts"
},
"shortcuts": {
"section": {
"global": "Global",
"search": "Search",
"package": "Package"
},
"settings": "Open settings",
"compare": "Open compare",
"navigate_results": "Navigate results",
"go_to_result": "Go to result",
"open_code_view": "Open code view",
"open_docs": "Open docs",
"open_compare_prefilled": "Open compare (prefilled with current package)"
},
"search": {
"label": "Search npm packages",
Expand Down
Loading