Skip to content

Commit 92c6338

Browse files
committed
fix: copy button
1 parent f8cc8b6 commit 92c6338

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

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

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ function handleClick(event: MouseEvent) {
432432
>
433433
<!-- Package name and version -->
434434
<div class="flex items-baseline gap-2 sm:gap-3 flex-wrap min-w-0">
435-
<div class="group flex items-baseline min-w-0">
435+
<div class="group relative flex flex-col items-start min-w-0">
436436
<h1
437437
class="font-mono text-2xl sm:text-3xl font-medium min-w-0 break-words"
438438
:title="pkg.name"
@@ -441,24 +441,28 @@ function handleClick(event: MouseEvent) {
441441
v-if="orgName"
442442
:to="{ name: 'org', params: { org: orgName } }"
443443
class="text-fg-muted hover:text-fg transition-colors duration-200"
444-
>@{{ orgName }}</NuxtLink
445-
><span v-if="orgName">/</span>
444+
>
445+
@{{ orgName }}
446+
</NuxtLink>
447+
<span v-if="orgName">/</span>
446448
<span :class="{ 'text-fg-muted': orgName }">
447449
{{ orgName ? pkg.name.replace(`@${orgName}/`, '') : pkg.name }}
448450
</span>
449451
</h1>
452+
453+
<!-- Floating copy button -->
450454
<TooltipAnnounce :text="$t('common.copied')" :isVisible="copiedPkgName">
451455
<button
452456
type="button"
453-
@click="() => copyPkgName()"
454-
class="opacity-100 sm:opacity-0 sm:group-hover:opacity-100 focus:opacity-100 transition-opacity p-2 rounded text-fg-muted hover:text-fg hover:bg-bg-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fg/50 align-middle ms-1"
457+
@click="copyPkgName()"
458+
class="absolute z-20 left-0 top-full inline-flex items-center gap-1 px-2 py-1 rounded border text-xs font-mono whitespace-nowrap text-fg-muted bg-bg border-border opacity-0 -translate-y-1 pointer-events-none transition-all duration-150 group-hover:opacity-100 group-hover:translate-y-0 group-hover:pointer-events-auto focus-visible:opacity-100 focus-visible:translate-y-0 focus-visible:pointer-events-auto hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fg/40"
455459
:aria-label="$t('package.copy_name')"
456460
>
457-
<span class="i-carbon:copy w-5 h-5 block" aria-hidden="true" />
461+
<span class="i-carbon:copy w-3.5 h-3.5" aria-hidden="true" />
462+
{{ $t('package.copy_name') }}
458463
</button>
459464
</TooltipAnnounce>
460465
</div>
461-
462466
<span
463467
v-if="displayVersion"
464468
class="inline-flex items-baseline gap-1.5 font-mono text-base sm:text-lg text-fg-muted shrink-0"
@@ -1244,4 +1248,10 @@ function handleClick(event: MouseEvent) {
12441248
max-width: 100%;
12451249
min-width: 0;
12461250
}
1251+
1252+
@media (hover: none) {
1253+
.copy-button {
1254+
display: none;
1255+
}
1256+
}
12471257
</style>

0 commit comments

Comments
 (0)