Skip to content

Commit 6308420

Browse files
committed
refactor: Improve handling of copying package name
1 parent 35d4105 commit 6308420

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

app/pages/[...package].vue

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,14 @@ function handleClick(event: MouseEvent) {
370370
router.push(route)
371371
}
372372
}
373+
374+
function handleCopy() {
375+
const selection = window.getSelection()
376+
if (selection && selection.toString().length > 0) {
377+
return
378+
}
379+
copyPkgName()
380+
}
373381
</script>
374382

375383
<template>
@@ -391,20 +399,14 @@ function handleClick(event: MouseEvent) {
391399
class="text-fg-muted hover:text-fg transition-colors duration-200"
392400
>@{{ orgName }}</NuxtLink
393401
><span v-if="orgName">/</span>
394-
<span>{{ orgName ? pkg.name.replace(`@${orgName}/`, '') : pkg.name }}</span>
395402
<AnnounceTooltip :text="$t('common.copied')" :isVisible="copiedPkgName">
396-
<button
397-
@click="copyPkgName()"
398-
aria-describedby="copy-pkg-name"
399-
class="cursor-copy ms-2 text-fg-subtle hover:text-fg transition-colors active:scale-95 inline-flex items-center justify-center align-middle"
403+
<span
404+
@click="handleCopy"
405+
class="cursor-copy hover:text-fg transition-colors duration-200"
406+
:class="{ 'text-fg-muted': orgName }"
400407
>
401-
<span v-if="!copiedPkgName" class="i-carbon:copy w-5 h-5" aria-hidden="true" />
402-
<span
403-
v-else
404-
class="i-carbon:checkmark w-5 h-5 text-green-500"
405-
aria-hidden="true"
406-
/>
407-
</button>
408+
{{ orgName ? pkg.name.replace(`@${orgName}/`, '') : pkg.name }}
409+
</span>
408410
</AnnounceTooltip>
409411
</h1>
410412

0 commit comments

Comments
 (0)