|
| 1 | +<script setup lang="ts"> |
| 2 | +defineProps<{ |
| 3 | + /** Type of suggestion: 'user' or 'org' */ |
| 4 | + type: 'user' | 'org' |
| 5 | + /** The name (username or org name) */ |
| 6 | + name: string |
| 7 | + /** Whether this suggestion is currently selected (keyboard nav) */ |
| 8 | + selected?: boolean |
| 9 | + /** Whether this is an exact match for the query */ |
| 10 | + isExactMatch?: boolean |
| 11 | + /** Index for keyboard navigation */ |
| 12 | + index?: number |
| 13 | +}>() |
| 14 | +
|
| 15 | +const emit = defineEmits<{ |
| 16 | + focus: [index: number] |
| 17 | +}>() |
| 18 | +</script> |
| 19 | + |
| 20 | +<template> |
| 21 | + <article |
| 22 | + class="group card-interactive relative focus-within:outline-none focus-within:ring-2 focus-within:ring-offset-bg focus-within:ring-offset-2 focus-within:ring-fg/50" |
| 23 | + :class="{ |
| 24 | + 'bg-bg-muted border-border-hover': selected, |
| 25 | + 'border-accent/30 bg-accent/5': isExactMatch, |
| 26 | + }" |
| 27 | + > |
| 28 | + <!-- Glow effect for exact matches --> |
| 29 | + <div |
| 30 | + v-if="isExactMatch" |
| 31 | + class="absolute -inset-px rounded-lg bg-gradient-to-r from-accent/0 via-accent/20 to-accent/0 opacity-100 blur-sm -z-1 pointer-events-none motion-reduce:opacity-50" |
| 32 | + aria-hidden="true" |
| 33 | + /> |
| 34 | + <NuxtLink |
| 35 | + :to="type === 'user' ? `/~${name}` : `/@${name}`" |
| 36 | + :data-suggestion-index="index" |
| 37 | + class="flex items-center gap-4 focus-visible:outline-none after:content-[''] after:absolute after:inset-0" |
| 38 | + @focus="index != null && emit('focus', index)" |
| 39 | + @mouseenter="index != null && emit('focus', index)" |
| 40 | + > |
| 41 | + <!-- Avatar placeholder --> |
| 42 | + <div |
| 43 | + class="w-10 h-10 shrink-0 flex items-center justify-center border border-border" |
| 44 | + :class="type === 'org' ? 'rounded-lg bg-bg-muted' : 'rounded-full bg-bg-muted'" |
| 45 | + aria-hidden="true" |
| 46 | + > |
| 47 | + <span class="text-lg text-fg-subtle font-mono">{{ name.charAt(0).toUpperCase() }}</span> |
| 48 | + </div> |
| 49 | + |
| 50 | + <div class="min-w-0 flex-1"> |
| 51 | + <div class="flex items-center gap-2"> |
| 52 | + <span |
| 53 | + class="font-mono text-sm sm:text-base font-medium text-fg group-hover:text-fg transition-colors" |
| 54 | + > |
| 55 | + {{ type === 'user' ? '~' : '@' }}{{ name }} |
| 56 | + </span> |
| 57 | + <span |
| 58 | + class="text-xs px-1.5 py-0.5 rounded bg-bg-muted border border-border text-fg-muted font-mono" |
| 59 | + > |
| 60 | + {{ type === 'user' ? $t('search.suggestion.user') : $t('search.suggestion.org') }} |
| 61 | + </span> |
| 62 | + <!-- Exact match badge --> |
| 63 | + <span |
| 64 | + v-if="isExactMatch" |
| 65 | + class="text-xs px-1.5 py-0.5 rounded bg-accent/20 border border-accent/30 text-accent font-mono" |
| 66 | + > |
| 67 | + {{ $t('search.exact_match') }} |
| 68 | + </span> |
| 69 | + </div> |
| 70 | + <p class="text-xs sm:text-sm text-fg-muted mt-0.5"> |
| 71 | + {{ |
| 72 | + type === 'user' |
| 73 | + ? $t('search.suggestion.view_user_packages') |
| 74 | + : $t('search.suggestion.view_org_packages') |
| 75 | + }} |
| 76 | + </p> |
| 77 | + </div> |
| 78 | + |
| 79 | + <span |
| 80 | + class="i-carbon-arrow-right w-4 h-4 text-fg-subtle group-hover:text-fg transition-colors shrink-0" |
| 81 | + aria-hidden="true" |
| 82 | + /> |
| 83 | + </NuxtLink> |
| 84 | + </article> |
| 85 | +</template> |
0 commit comments