Skip to content
Draft
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
34 changes: 34 additions & 0 deletions app/components/Compare/PackageSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@

const isSearching = computed(() => status.value === 'pending')

const suggestedPackagesCandidates = ['vue', 'svelte', 'solid-js', 'react']

const suggestedPackages = computed(() => {
return suggestedPackagesCandidates.includes(packages.value[0])

Check failure on line 23 in app/components/Compare/PackageSelector.vue

View workflow job for this annotation

GitHub Actions / test

Argument of type 'string | undefined' is not assignable to parameter of type 'string'.
? suggestedPackagesCandidates
.filter(name => !packages.value.includes(name))
.slice(0, Math.max(0, 4 - packages.value.length))
: []
})

// Filter out already selected packages
const filteredResults = computed(() => {
if (!searchData.value?.objects) return []
Expand Down Expand Up @@ -78,6 +88,30 @@
<span class="i-carbon:close w-3.5 h-3.5" aria-hidden="true" />
</button>
</div>

<p class="flex-1"></p>

<!-- suggested packages -->
<div
v-for="pkg in suggestedPackages"
:key="pkg"
class="inline-flex items-center gap-2 px-3 py-1.5 border-border rounded-md"
>
<NuxtLink
:to="`/${pkg}`"
class="font-mono text-sm text-fg hover:text-accent transition-colors"
>
{{ pkg }}
</NuxtLink>
<button
type="button"
class="text-fg-subtle hover:text-fg transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 rounded"
:aria-label="$t('compare.selector.add_package', { package: pkg })"
@click="addPackage(pkg)"
>
<span class="i-carbon:add w-3.5 h-3.5" aria-hidden="true" />
</button>
</div>
</div>

<!-- Add package input -->
Expand Down
Loading