Skip to content

Commit 4906004

Browse files
authored
Merge branch 'main' into feat/facet-selector-a11y
2 parents b0c666f + b4b9cc8 commit 4906004

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+2449
-592
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ jobs:
199199
run: pnpm knip
200200

201201
- name: 🧹 Check for unused production code
202-
run: pnpm knip --production
202+
run: pnpm knip --production --exclude dependencies
203203

204204
i18n:
205205
name: 🌐 i18n validation

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ We welcome contributions – please do feel free to explore the project and
159159
- [npmx-weekly](https://npmx-weekly.trueberryless.org/) – A weekly newsletter for the npmx ecosystem. Add your own content via suggestions in the weekly PR on [GitHub](https://github.com/trueberryless-org/npmx-weekly/pulls?q=is%3Aopen+is%3Apr+label%3A%22%F0%9F%95%94+weekly+post%22).
160160
- [npmx-digest](https://npmx-digest.trueberryless.org/) – An automated news aggregation website that summarizes npmx activity from GitHub and Bluesky every 8 hours.
161161
- [npmx-redirect](https://github.com/iaverages/npmx-redirect) – Browser extension that automatically redirects npmjs.com URLs to npmx.dev.
162+
- [npmx-badge](https://npmx-badge.vercel.app/) – A playground to help you create custom badges quickly.
162163

163164
If you're building something cool, let us know! 🙏
164165

app/components/BaseCard.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
defineProps<{
33
/** Whether this is an exact match for the query */
44
isExactMatch?: boolean
5+
selected?: boolean
56
}>()
67
</script>
78

@@ -10,6 +11,7 @@ defineProps<{
1011
class="group bg-bg-subtle border border-border rounded-lg p-4 sm:p-6 transition-[border-color,background-color] duration-200 hover:(border-border-hover bg-bg-muted) cursor-pointer relative focus-within:outline-none focus-within:ring-2 focus-within:ring-offset-bg focus-within:ring-offset-2 focus-within:ring-fg/50 focus-within:bg-bg-muted focus-within:border-border-hover"
1112
:class="{
1213
'border-accent/30 contrast-more:border-accent/90 bg-accent/5': isExactMatch,
14+
'bg-fg-subtle/15!': selected,
1315
}"
1416
>
1517
<!-- Glow effect for exact matches -->

app/components/ColumnPicker.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const columnLabels = computed(() => ({
5454
maintenanceScore: $t('filters.columns.maintenance_score'),
5555
combinedScore: $t('filters.columns.combined_score'),
5656
security: $t('filters.columns.security'),
57+
selection: $t('filters.columns.selection'),
5758
}))
5859
5960
function getColumnLabel(id: ColumnId): string {

app/components/Compare/ComparisonGrid.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts">
22
import type { ModuleReplacement } from 'module-replacements'
33
4-
export interface ComparisonGridColumn {
4+
interface ComparisonGridColumn {
55
name: string
66
version?: string
77
/** Module replacement data for this package (if available) */
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<script setup lang="ts">
2+
const { selectedPackages, selectedPackagesParam, clearSelectedPackages } = usePackageSelection()
3+
4+
const shortcutKey = 'b'
5+
const actionBar = useTemplateRef('actionBarRef')
6+
onKeyStroke(
7+
e => {
8+
const target = e.target as HTMLElement
9+
const isCheckbox = target.hasAttribute('data-package-card-checkbox')
10+
return isKeyWithoutModifiers(e, shortcutKey) && (!isEditableElement(target) || isCheckbox)
11+
},
12+
e => {
13+
if (selectedPackages.value.length === 0) {
14+
return
15+
}
16+
17+
e.preventDefault()
18+
actionBar.value?.focus()
19+
},
20+
)
21+
</script>
22+
23+
<template>
24+
<Transition name="action-bar-slide" appear>
25+
<section
26+
v-if="selectedPackages.length"
27+
aria-labelledby="action-bar-title"
28+
class="group fixed bottom-10 inset-is-0 w-full flex items-center justify-center z-36 pointer-events-none focus:outline-none"
29+
tabindex="-1"
30+
aria-keyshortcuts="b"
31+
ref="actionBarRef"
32+
>
33+
<h3 id="action-bar-title" class="sr-only">
34+
{{ $t('action_bar.title') }}
35+
</h3>
36+
<div
37+
class="group-focus:outline-accent group-focus:outline-2 group-focus:outline-offset-2 pointer-events-auto bg-bg shadow-2xl shadow-accent/20 border-2 border-accent/60 p-3 min-w-[300px] rounded-xl flex gap-3 items-center justify-between animate-in ring-1 ring-accent/30"
38+
>
39+
<div aria-live="polite" aria-atomic="true" class="sr-only">
40+
{{ $t('action_bar.selection', selectedPackages.length) }}.
41+
{{ $t('action_bar.shortcut', { key: shortcutKey }) }}.
42+
</div>
43+
44+
<div class="flex items-center gap-2">
45+
<span class="text-fg font-semibold text-sm flex items-center gap-1.5">
46+
{{ $t('action_bar.selection', selectedPackages.length) }}
47+
</span>
48+
<button
49+
@click="clearSelectedPackages"
50+
class="flex items-center ms-1 text-fg-muted hover:(text-fg bg-accent/10) p-1.5 rounded-lg transition-colors"
51+
:aria-label="$t('action_bar.button_close_aria_label')"
52+
>
53+
<span class="i-lucide:x text-sm" aria-hidden="true" />
54+
</button>
55+
</div>
56+
57+
<LinkBase
58+
:to="{ name: 'compare', query: { packages: selectedPackagesParam } }"
59+
variant="button-secondary"
60+
classicon="i-lucide:git-compare"
61+
>
62+
{{ $t('package.links.compare') }}
63+
</LinkBase>
64+
</div>
65+
</section>
66+
</Transition>
67+
</template>
68+
69+
<style scoped>
70+
/* Action bar slide/fade animation */
71+
.action-bar-slide-enter-active,
72+
.action-bar-slide-leave-active {
73+
transition:
74+
opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1),
75+
transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
76+
}
77+
.action-bar-slide-enter-from,
78+
.action-bar-slide-leave-to {
79+
opacity: 0;
80+
transform: translateY(40px) scale(0.98);
81+
}
82+
.action-bar-slide-enter-to,
83+
.action-bar-slide-leave-from {
84+
opacity: 1;
85+
transform: translateY(0) scale(1);
86+
}
87+
</style>

app/components/Package/Card.vue

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ const props = defineProps<{
1616
searchQuery?: string
1717
}>()
1818
19+
const { isPackageSelected, togglePackageSelection, canSelectMore } = usePackageSelection()
20+
const isSelected = computed<boolean>(() => {
21+
return isPackageSelected(props.result.package.name)
22+
})
23+
1924
const emit = defineEmits<{
2025
clickKeyword: [keyword: string]
2126
}>()
@@ -39,16 +44,16 @@ const numberFormatter = useNumberFormatter()
3944
</script>
4045

4146
<template>
42-
<BaseCard :isExactMatch="isExactMatch">
43-
<div class="mb-2 flex items-baseline justify-start gap-2">
47+
<BaseCard :selected="isSelected" :isExactMatch="isExactMatch">
48+
<header class="mb-4 flex items-baseline justify-between gap-2">
4449
<component
4550
:is="headingLevel ?? 'h3'"
4651
class="font-mono text-sm sm:text-base font-medium text-fg group-hover:text-fg transition-colors duration-200 min-w-0 break-all"
4752
>
4853
<NuxtLink
4954
:to="packageRoute(result.package.name)"
5055
:prefetch-on="prefetch ? 'visibility' : 'interaction'"
51-
class="decoration-none scroll-mt-48 scroll-mb-6 after:content-[''] after:absolute after:inset-0"
56+
class="decoration-none after:content-[''] after:absolute after:inset-0"
5257
:data-result-index="index"
5358
dir="ltr"
5459
>{{ result.package.name }}</NuxtLink
@@ -59,28 +64,17 @@ const numberFormatter = useNumberFormatter()
5964
>{{ $t('search.exact_match') }}</span
6065
>
6166
</component>
62-
<span aria-hidden="true" class="flex-shrink-1 flex-grow-1" />
63-
<!-- Mobile: version next to package name -->
64-
<div class="sm:hidden text-fg-subtle flex items-center gap-1.5 shrink-0">
65-
<span
66-
v-if="result.package.version"
67-
class="font-mono text-xs truncate max-w-20"
68-
:title="result.package.version"
69-
>
70-
v{{ result.package.version }}
71-
</span>
72-
<ProvenanceBadge
73-
v-if="result.package.publisher?.trustedPublisher"
74-
:provider="result.package.publisher.trustedPublisher.id"
75-
:package-name="result.package.name"
76-
:version="result.package.version"
77-
:linked="false"
78-
compact
79-
/>
80-
</div>
81-
</div>
82-
<div class="flex justify-start items-start gap-4 sm:gap-8">
83-
<div class="min-w-0">
67+
68+
<PackageSelectionCheckbox
69+
:package-name="result.package.name"
70+
:disabled="!canSelectMore && !isSelected"
71+
:checked="isSelected"
72+
@change="togglePackageSelection"
73+
/>
74+
</header>
75+
76+
<div class="flex flex-col sm:flex-row sm:justify-start sm:items-start gap-6 sm:gap-8">
77+
<div class="min-w-0 w-full">
8478
<p v-if="pkgDescription" class="text-fg-muted text-xs sm:text-sm line-clamp-2 mb-2 sm:mb-3">
8579
<span v-html="pkgDescription" />
8680
</p>
@@ -124,10 +118,9 @@ const numberFormatter = useNumberFormatter()
124118
</div>
125119
</dl>
126120
</div>
127-
<span aria-hidden="true" class="flex-shrink-1 flex-grow-1" />
128-
<!-- Desktop: version and downloads on right side -->
129-
<div class="hidden sm:flex flex-col gap-2 shrink-0">
130-
<div class="text-fg-subtle flex items-start gap-2 justify-end">
121+
122+
<div class="flex flex-col gap-2 shrink-0">
123+
<div class="text-fg-subtle flex items-start gap-2 sm:justify-end">
131124
<span
132125
v-if="result.package.version"
133126
class="font-mono text-xs truncate max-w-32"
@@ -150,7 +143,7 @@ const numberFormatter = useNumberFormatter()
150143
</div>
151144
<div
152145
v-if="result.downloads?.weekly"
153-
class="text-fg-subtle gap-2 flex items-center justify-end"
146+
class="text-fg-subtle gap-2 flex items-center sm:justify-end"
154147
>
155148
<span class="i-lucide:chart-line w-3.5 h-3.5" aria-hidden="true" />
156149
<span class="font-mono text-xs">

app/components/Package/Header.vue

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const props = defineProps<{
1818
}>()
1919
2020
const { requestedVersion, orgName } = usePackageRoute()
21-
const { scrollToTop, isTouchDeviceClient } = useScrollToTop()
21+
const { scrollToTop } = useScrollToTop()
2222
const packageHeaderHeight = usePackageHeaderHeight()
2323
2424
const header = useTemplateRef('header')
@@ -61,9 +61,7 @@ onBeforeUnmount(() => {
6161
const navExtraOffsetStyle = { '--package-nav-extra': '0px' }
6262
6363
const { y: scrollY } = useScroll(window)
64-
const showScrollToTop = computed(
65-
() => isTouchDeviceClient.value && scrollY.value > SCROLL_TO_TOP_THRESHOLD,
66-
)
64+
const showScrollToTop = computed(() => scrollY.value > SCROLL_TO_TOP_THRESHOLD)
6765
6866
const packageName = computed(() => props.pkg?.name ?? '')
6967
const compactNumberFormatter = useCompactNumberFormatter()
@@ -247,7 +245,7 @@ const likeAction = async () => {
247245

248246
<template>
249247
<!-- Package header -->
250-
<header class="bg-bg pt-5 w-full container">
248+
<header class="bg-bg pt-5 pb-1 w-full container">
251249
<!-- Package name and version -->
252250
<div class="flex items-baseline justify-between gap-x-2 gap-y-1 flex-wrap min-w-0">
253251
<CopyToClipboardButton
@@ -319,7 +317,7 @@ const likeAction = async () => {
319317
</header>
320318
<div
321319
ref="header"
322-
class="w-full bg-bg sticky top-14 z-50 border-b border-border pt-2"
320+
class="w-full bg-bg sticky top-14 z-10 border-b border-border pt-2"
323321
:class="[$style.packageHeader]"
324322
data-testid="package-subheader"
325323
>
@@ -395,7 +393,7 @@ const likeAction = async () => {
395393
v-if="mainLink"
396394
:to="mainLink"
397395
aria-keyshortcuts="m"
398-
class="decoration-none border-b-2 p-1 hover:border-accent/50 lowercase"
396+
class="decoration-none border-b-2 p-1 hover:border-accent/50 lowercase focus-visible:[outline-offset:-2px]!"
399397
:class="page === 'main' ? 'border-accent text-accent!' : 'border-transparent'"
400398
>
401399
{{ $t('package.links.main') }}
@@ -404,7 +402,7 @@ const likeAction = async () => {
404402
v-if="docsLink"
405403
:to="docsLink"
406404
aria-keyshortcuts="d"
407-
class="decoration-none border-b-2 p-1 hover:border-accent/50"
405+
class="decoration-none border-b-2 p-1 hover:border-accent/50 focus-visible:[outline-offset:-2px]!"
408406
:class="page === 'docs' ? 'border-accent text-accent!' : 'border-transparent'"
409407
>
410408
{{ $t('package.links.docs') }}
@@ -413,7 +411,7 @@ const likeAction = async () => {
413411
v-if="codeLink"
414412
:to="codeLink"
415413
aria-keyshortcuts="."
416-
class="decoration-none border-b-2 p-1 hover:border-accent/50"
414+
class="decoration-none border-b-2 p-1 hover:border-accent/50 focus-visible:[outline-offset:-2px]!"
417415
:class="page === 'code' ? 'border-accent text-accent!' : 'border-transparent'"
418416
>
419417
{{ $t('package.links.code') }}
@@ -423,7 +421,7 @@ const likeAction = async () => {
423421
:to="diffLink"
424422
:title="$t('compare.compare_versions_title')"
425423
aria-keyshortcuts="f"
426-
class="decoration-none border-b-2 p-1 hover:border-accent/50"
424+
class="decoration-none border-b-2 p-1 hover:border-accent/50 focus-visible:[outline-offset:-2px]!"
427425
:class="page === 'diff' ? 'border-accent text-accent!' : 'border-transparent'"
428426
>
429427
{{ $t('compare.compare_versions') }}

app/components/Package/List.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ defineExpose({
166166
<template #default="{ item, index }">
167167
<div class="pb-4">
168168
<PackageCard
169-
:result="item as NpmSearchResult"
169+
:key="item.package.name"
170+
:result="item"
170171
:heading-level="headingLevel"
171172
:show-publisher="showPublisher"
172173
:index="index"

app/components/Package/ListControls.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
export type SortOption = 'downloads' | 'updated' | 'name-asc' | 'name-desc'
2+
type SortOption = 'downloads' | 'updated' | 'name-asc' | 'name-desc'
33
44
const props = defineProps<{
55
/** Current search/filter text */

0 commit comments

Comments
 (0)