forked from npmx-dev/npmx.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSelectionView.vue
More file actions
71 lines (66 loc) · 2.12 KB
/
SelectionView.vue
File metadata and controls
71 lines (66 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<script setup lang="ts">
defineProps<{
viewMode?: ViewMode
}>()
const { selectedPackages, clearSelectedPackages, selectedPackagesParam, closeSelectionView } =
usePackageSelection()
const { data, pending } = useAsyncData(
async () => {
const results = await Promise.all(
selectedPackages.value.map(name =>
$fetch(`/api/registry/package-meta/${encodeURIComponent(name)}`)
.then(response => ({ package: response }))
.catch(() => null),
),
)
return results.filter(result => result !== null)
},
{
default: () => [],
},
)
</script>
<template>
<section>
<header class="mb-6 flex items-center justify-between">
<button
type="button"
class="cursor-pointer inline-flex items-center gap-2 font-mono text-sm text-fg-muted hover:text-fg transition-colors duration-200 rounded focus-visible:outline-accent/70"
@click="closeSelectionView"
:aria-label="$t('nav.back')"
>
<span class="i-lucide:arrow-left rtl-flip w-4 h-4" aria-hidden="true" />
<span class="hidden sm:inline">{{ $t('nav.back') }}</span>
</button>
<div class="flex items-center gap-2">
<ButtonBase variant="secondary" @click="clearSelectedPackages">
{{ $t('filters.clear_all') }}
</ButtonBase>
<LinkBase
:to="{ name: 'compare', query: { packages: selectedPackagesParam } }"
variant="button-primary"
classicon="i-lucide:git-compare"
>
{{ $t('package.links.compare') }}
</LinkBase>
</div>
</header>
<p class="text-fg-muted text-sm font-mono">
{{ $t('action_bar.selection', selectedPackages.length) }}
</p>
<div class="mt-6">
<div v-if="pending" class="flex items-center justify-center py-12">
<LoadingSpinner :text="$t('common.loading')" />
</div>
<PackageList
v-else-if="data?.length"
:view-mode="viewMode"
:results="data"
heading-level="h2"
/>
<p v-else class="text-fg-muted text-sm">
{{ $t('filters.table.no_packages') }}
</p>
</div>
</section>
</template>