Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
45 changes: 35 additions & 10 deletions app/components/Package/Header.vue
Copy link
Copy Markdown
Member

@knowler knowler May 7, 2026

Choose a reason for hiding this comment

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

If I recall, the previous layout of package pages had the version number next to the package name which was a better candidate for a convenience like this. Now, with the version being a part of the version selector — a component that has significant issues on its own — this seems like a bit too much is going on. If we want this functionality, I think a dedicated button next to the version number would be better, as it avoids two popover interactions for the same element and the button on hover could be inferred as a tooltip for what the version selector does. That or we should find somewhere else to do this.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I made the change to copy the version number on hover to make sure that it is consistent within the application. @gameroman Should I go ahead and include a copy button next to version number?

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import type { RouteLocationRaw } from 'vue-router'
import type { CommandPaletteContextCommandInput } from '~/types/command-palette'
import { SCROLL_TO_TOP_THRESHOLD } from '~/composables/useScrollToTop'
import { useClipboard } from '@vueuse/core'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

iirc, this isn't necessary since it's auto-imported


const props = defineProps<{
pkg?: Pick<SlimPackument, 'name' | 'versions' | 'dist-tags'> | null
Expand Down Expand Up @@ -61,6 +62,7 @@ const { y: scrollY } = useScroll(window)
const showScrollToTop = computed(() => scrollY.value > SCROLL_TO_TOP_THRESHOLD)

const packageName = computed(() => props.pkg?.name ?? '')
const resolvedVersionDisplay = computed(() => props.resolvedVersion ?? '')
const fundingUrl = computed(() => {
let funding = props.displayVersion?.funding
if (Array.isArray(funding)) funding = funding[0]
Expand All @@ -75,6 +77,11 @@ const { copied: copiedPkgName, copy: copyPkgName } = useClipboard({
copiedDuring: 2000,
})

const { copied: copiedPkgVersion, copy: copyPkgVersion } = useClipboard({
source: resolvedVersionDisplay,
copiedDuring: 2000,
})

function hasProvenance(version: PackumentVersion | null): boolean {
if (!version?.dist) return false
return !!(version.dist as { attestations?: unknown }).attestations
Expand All @@ -98,6 +105,17 @@ useCommandPaletteContextCommands(
announce($t('command_palette.announcements.copied_to_clipboard'))
},
},
{
id: 'package-copy-version',
group: 'package',
label: $t('package.versions.copy_version'),
keywords: [props.resolvedVersion],
iconClass: 'i-lucide:copy',
action: () => {
copyPkgVersion()
announce($t('command_palette.announcements.copied_to_clipboard'))
},
},
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

coderabbit's suggestions makes sense here. I would do something like this here

const commands: CommandPaletteContextCommandInput[] = []

if (packageName.value) {
  commands.push({
    id: 'package-copy-name',
    group: 'package',
    label: $t('package.copy_name'),
    keywords: [packageName.value],
    iconClass: 'i-lucide:copy',
    action: () => {
      copyPkgName()
      announce($t('command_palette.announcements.copied_to_clipboard'))
    },
  })
}

if (props.resolvedVersion) {
  commands.push({
    id: 'package-copy-version',
    group: 'package',
    label: $t('package.versions.copy_version'),
    keywords: [props.resolvedVersion],
    iconClass: 'i-lucide:copy',
    action: () => {
      copyPkgVersion()
      announce($t('command_palette.announcements.copied_to_clipboard'))
    },
  })
}


if (fundingUrl.value) {
Expand Down Expand Up @@ -287,16 +305,23 @@ useShortcuts({
<span class="i-lucide:cable rtl-flip min-w-3 w-3 h-3 mx-1" aria-hidden="true" />
</TooltipApp>
</template>
<!-- Version selector -->
<VersionSelector
v-if="resolvedVersion && pkg?.versions && pkg?.['dist-tags']"
:package-name="packageName"
:current-version="resolvedVersion"
:versions="pkg.versions"
:dist-tags="pkg['dist-tags']"
:url-pattern="versionUrlPattern"
position-class="max-md:inset-is-0 md:inset-ie-0"
/>
<CopyToClipboardButton
:copied="copiedPkgVersion"
:copy-text="$t('package.versions.copy_version')"
class="inline-flex items-center min-w-0"
@click="copyPkgVersion()"
>
<!-- Version selector -->
<VersionSelector
v-if="resolvedVersion && pkg?.versions && pkg?.['dist-tags']"
:package-name="packageName"
:current-version="resolvedVersion"
:versions="pkg.versions"
:dist-tags="pkg['dist-tags']"
:url-pattern="versionUrlPattern"
position-class="max-md:inset-is-0 md:inset-ie-0"
/>
</CopyToClipboardButton>
</div>
</div>
<!-- Docs + Code — inline on desktop, floating bottom bar on mobile -->
Expand Down
3 changes: 2 additions & 1 deletion i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,8 @@
},
"page_title": "Version History",
"current_tags": "Current Tags",
"no_match_filter": "No versions match {filter}"
"no_match_filter": "No versions match {filter}",
"copy_version": "Copy version number"
},
"timeline": {
"load_more": "Load more",
Expand Down
Loading