Skip to content
Open
Changes from all 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
31 changes: 23 additions & 8 deletions app/components/Package/Card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ const pkgDescription = useMarkdown(() => ({
}))

const numberFormatter = useNumberFormatter()
const packageName = computed(() => props.result.package?.name ?? '')

const { copied: copiedPkgName, copy: copyPkgName } = useClipboard({
source: packageName,
copiedDuring: 2000,
})
</script>

<template>
Expand All @@ -49,14 +55,23 @@ const numberFormatter = useNumberFormatter()
:is="headingLevel ?? 'h3'"
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"
>
<NuxtLink
:to="packageRoute(result.package.name)"
:prefetch-on="prefetch ? 'visibility' : 'interaction'"
class="decoration-none after:content-[''] after:absolute after:inset-0"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic that the entire card should be clickable seems not to work now. I think this is a more important feature on the search page than copying a name.
The copy button on the side will probably fix this (but it will create an extra interaction)

Could you please share, what user case would this might solve? I feel like user know the name they're looking for in the search already and then open the needed package and interact there

:data-result-index="index"
dir="ltr"
>{{ result.package.name }}</NuxtLink
>
<span class="group relative inline-flex items-center gap-2">
<CopyToClipboardButton
:copied="copiedPkgName"
:copy-text="$t('package.copy_name')"
class="inline-flex items-center gap-2"
@click.stop="copyPkgName()"
>
<NuxtLink
:to="packageRoute(result.package.name)"
:prefetch-on="prefetch ? 'visibility' : 'interaction'"
class="decoration-none"
:data-result-index="index"
dir="ltr"
>{{ result.package.name }}</NuxtLink
>
</CopyToClipboardButton>
</span>
<span
v-if="isExactMatch"
class="text-xs px-1.5 py-0.5 ms-2 rounded bg-bg-elevated border border-border-hover text-fg"
Expand Down
Loading