Skip to content

Commit 930099d

Browse files
committed
feat(search-view): add copy-to-clipboard button for package names
1 parent 0164064 commit 930099d

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

app/components/Package/Card.vue

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ const pkgDescription = useMarkdown(() => ({
4040
}))
4141
4242
const numberFormatter = useNumberFormatter()
43+
const packageName = computed(() => props.result.package?.name ?? '')
44+
45+
const { copied: copiedPkgName, copy: copyPkgName } = useClipboard({
46+
source: packageName,
47+
copiedDuring: 2000,
48+
})
4349
</script>
4450

4551
<template>
@@ -49,14 +55,23 @@ const numberFormatter = useNumberFormatter()
4955
:is="headingLevel ?? 'h3'"
5056
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"
5157
>
52-
<NuxtLink
53-
:to="packageRoute(result.package.name)"
54-
:prefetch-on="prefetch ? 'visibility' : 'interaction'"
55-
class="decoration-none after:content-[''] after:absolute after:inset-0"
56-
:data-result-index="index"
57-
dir="ltr"
58-
>{{ result.package.name }}</NuxtLink
59-
>
58+
<span class="group relative inline-flex items-center gap-2">
59+
<CopyToClipboardButton
60+
:copied="copiedPkgName"
61+
:copy-text="$t('package.copy_name')"
62+
class="inline-flex items-center gap-2"
63+
@click.stop="copyPkgName()"
64+
>
65+
<NuxtLink
66+
:to="packageRoute(result.package.name)"
67+
:prefetch-on="prefetch ? 'visibility' : 'interaction'"
68+
class="decoration-none"
69+
:data-result-index="index"
70+
dir="ltr"
71+
>{{ result.package.name }}</NuxtLink
72+
>
73+
</CopyToClipboardButton>
74+
</span>
6075
<span
6176
v-if="isExactMatch"
6277
class="text-xs px-1.5 py-0.5 ms-2 rounded bg-bg-elevated border border-border-hover text-fg"

0 commit comments

Comments
 (0)