Skip to content

Commit a96417e

Browse files
Merge branch 'feat/action-bar' of https://github.com/MatteoGabriele/npmx.dev into feat/action-bar
2 parents bab24a2 + 1ee8c67 commit a96417e

37 files changed

Lines changed: 1924 additions & 250 deletions

File tree

app/app.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,12 @@ if (import.meta.server) {
4747
setJsonLd(createWebSiteSchema())
4848
}
4949
50+
const keyboardShortcuts = useKeyboardShortcuts()
51+
5052
onKeyDown(
5153
'/',
5254
e => {
53-
if (isEditableElement(e.target)) return
55+
if (!keyboardShortcuts.value || isEditableElement(e.target)) return
5456
e.preventDefault()
5557
5658
const searchInput = document.querySelector<HTMLInputElement>(
@@ -70,7 +72,7 @@ onKeyDown(
7072
onKeyDown(
7173
'?',
7274
e => {
73-
if (isEditableElement(e.target)) return
75+
if (!keyboardShortcuts.value || isEditableElement(e.target)) return
7476
e.preventDefault()
7577
showKbdHints.value = true
7678
},
@@ -80,7 +82,7 @@ onKeyDown(
8082
onKeyUp(
8183
'?',
8284
e => {
83-
if (isEditableElement(e.target)) return
85+
if (!keyboardShortcuts.value || isEditableElement(e.target)) return
8486
e.preventDefault()
8587
showKbdHints.value = false
8688
},

app/assets/main.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,11 @@ input[type='search']::-webkit-search-results-decoration {
335335
animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
336336
}
337337

338+
/* Hide keyboard shortcut hints before hydration when user disabled them */
339+
:root[data-kbd-shortcuts='false'] [data-kbd-hint] {
340+
display: none;
341+
}
342+
338343
/* Locking the scroll whenever any of the modals are open */
339344
html:has(dialog:modal) {
340345
overflow: hidden;

app/components/AppFooter.vue

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const isHome = computed(() => route.name === 'index')
66
77
const modalRef = useTemplateRef('modalRef')
88
const showModal = () => modalRef.value?.showModal?.()
9+
const closeModal = () => modalRef.value?.close?.()
910
</script>
1011

1112
<template>
@@ -81,7 +82,7 @@ const showModal = () => modalRef.value?.showModal?.()
8182
<p class="mb-2 font-mono text-fg-subtle">
8283
{{ $t('shortcuts.section.package') }}
8384
</p>
84-
<ul class="mb-6 flex flex-col gap-2">
85+
<ul class="mb-8 flex flex-col gap-2">
8586
<li class="flex gap-2 items-center">
8687
<kbd class="kbd">.</kbd>
8788
<span>{{ $t('shortcuts.open_code_view') }}</span>
@@ -95,6 +96,19 @@ const showModal = () => modalRef.value?.showModal?.()
9596
<span>{{ $t('shortcuts.compare_from_package') }}</span>
9697
</li>
9798
</ul>
99+
<p class="text-fg-muted leading-relaxed">
100+
<i18n-t keypath="shortcuts.disable_shortcuts" tag="span" scope="global">
101+
<template #settings>
102+
<NuxtLink
103+
:to="{ name: 'settings' }"
104+
class="hover:text-fg underline decoration-fg-subtle/50 hover:decoration-fg"
105+
@click="closeModal"
106+
>
107+
{{ $t('settings.title') }}
108+
</NuxtLink>
109+
</template>
110+
</i18n-t>
111+
</p>
98112
</Modal>
99113
<LinkBase :to="NPMX_DOCS_SITE">
100114
{{ $t('footer.docs') }}

app/components/AppHeader.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import type { NavigationConfig, NavigationConfigWithGroups } from '~/types'
44
import { isEditableElement } from '~/utils/input'
55
import { NPMX_DOCS_SITE } from '#shared/utils/constants'
66
7+
const keyboardShortcuts = useKeyboardShortcuts()
8+
79
withDefaults(
810
defineProps<{
911
showLogo?: boolean
@@ -175,7 +177,7 @@ function handleSearchFocus() {
175177
176178
onKeyStroke(
177179
e => {
178-
if (isEditableElement(e.target)) {
180+
if (!keyboardShortcuts.value || isEditableElement(e.target)) {
179181
return
180182
}
181183

app/components/Button/Base.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ const props = withDefaults(
2626
2727
const el = useTemplateRef('el')
2828
29+
const keyboardShortcutsEnabled = useKeyboardShortcuts()
30+
2931
defineExpose({
3032
focus: () => el.value?.focus(),
3133
getBoundingClientRect: () => el.value?.getBoundingClientRect(),
@@ -56,12 +58,13 @@ defineExpose({
5658
*/
5759
disabled ? true : undefined
5860
"
59-
:aria-keyshortcuts="ariaKeyshortcuts"
61+
:aria-keyshortcuts="keyboardShortcutsEnabled ? ariaKeyshortcuts : undefined"
6062
>
6163
<span v-if="classicon" class="size-[1em]" :class="classicon" aria-hidden="true" />
6264
<slot />
6365
<kbd
64-
v-if="ariaKeyshortcuts"
66+
v-if="keyboardShortcutsEnabled && ariaKeyshortcuts"
67+
data-kbd-hint
6568
class="ms-2 inline-flex items-center justify-center w-4 h-4 text-xs text-fg bg-bg-muted border border-border rounded no-underline"
6669
aria-hidden="true"
6770
>

app/components/Compare/PackageSelector.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ onClickOutside(containerRef, () => {
301301
v-if="result.description"
302302
class="text-xs text-fg-muted truncate mt-0.5 w-full block"
303303
>
304-
{{ decodeHtmlEntities(result.description) }}
304+
{{ stripHtmlTags(decodeHtmlEntities(result.description)) }}
305305
</span>
306306
</ButtonBase>
307307
</div>

app/components/Link/Base.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const isLink = computed(() => props.variant === 'link')
5959
const isButton = computed(() => !isLink.value)
6060
const isButtonSmall = computed(() => props.size === 'small' && !isLink.value)
6161
const isButtonMedium = computed(() => props.size === 'medium' && !isLink.value)
62+
const keyboardShortcutsEnabled = useKeyboardShortcuts()
6263
</script>
6364

6465
<template>
@@ -97,7 +98,7 @@ const isButtonMedium = computed(() => props.size === 'medium' && !isLink.value)
9798
variant === 'button-primary',
9899
}"
99100
:to="to"
100-
:aria-keyshortcuts="ariaKeyshortcuts"
101+
:aria-keyshortcuts="keyboardShortcutsEnabled ? ariaKeyshortcuts : undefined"
101102
:target="isLinkExternal ? '_blank' : undefined"
102103
>
103104
<span v-if="classicon" class="size-[1em]" :class="classicon" aria-hidden="true" />
@@ -114,7 +115,8 @@ const isButtonMedium = computed(() => props.size === 'medium' && !isLink.value)
114115
aria-hidden="true"
115116
/>
116117
<kbd
117-
v-if="ariaKeyshortcuts"
118+
v-if="keyboardShortcutsEnabled && ariaKeyshortcuts"
119+
data-kbd-hint
118120
class="ms-2 inline-flex items-center justify-center size-4 text-xs text-fg bg-bg-muted border border-border rounded no-underline"
119121
aria-hidden="true"
120122
>

app/components/Package/TableRow.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const allMaintainersText = computed(() => {
7373
v-if="isColumnVisible('description')"
7474
class="py-2 px-3 text-sm text-fg-muted max-w-xs truncate"
7575
>
76-
{{ decodeHtmlEntities(pkg.description || '-') }}
76+
{{ stripHtmlTags(decodeHtmlEntities(pkg.description || '-')) }}
7777
</td>
7878

7979
<!-- Downloads -->

app/components/Package/TrendsChart.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,10 +1729,10 @@ watch(selectedMetric, value => {
17291729
v-if="showResetButton"
17301730
type="button"
17311731
aria-label="Reset date range"
1732-
class="self-end flex items-center justify-center px-2.5 py-1.75 border border-transparent rounded-md text-fg-subtle hover:text-fg transition-colors hover:border-border focus-visible:outline-accent/70 sm:mb-0"
1732+
class="self-end flex items-center justify-center px-2.5 py-2.25 border border-transparent rounded-md text-fg-subtle hover:text-fg transition-colors hover:border-border focus-visible:outline-accent/70 sm:mb-0"
17331733
@click="resetDateRange"
17341734
>
1735-
<span class="i-lucide:undo-2 w-5 h-5" aria-hidden="true" />
1735+
<span class="block i-lucide:undo-2 w-5 h-5" aria-hidden="true" />
17361736
</button>
17371737
</div>
17381738

app/components/Package/WeeklyDownloadStats.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ const config = computed<VueUiSparklineConfig>(() => {
296296
<span v-else-if="isLoadingWeeklyDownloads" class="min-w-6 min-h-6 -m-1 p-1" />
297297
</template>
298298

299-
<div class="w-full overflow-hidden h-[110px] motion-safe:h-[140px]">
299+
<div class="w-full overflow-hidden h-[76px] motion-safe:h-[calc(92px+0.75rem)]">
300300
<template v-if="isLoadingWeeklyDownloads || hasWeeklyDownloads">
301301
<ClientOnly>
302302
<VueUiSparkline class="w-full max-w-xs" :dataset :config>

0 commit comments

Comments
 (0)