Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion app/components/Compare/PackageSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const props = defineProps<{
max?: number
}>()

const maxPackages = computed(() => props.max ?? 4)
const maxPackages = computed(() => props.max ?? MAX_PACKAGE_SELECTION)

// Input state
const inputValue = shallowRef('')
Expand Down
12 changes: 7 additions & 5 deletions app/components/Package/TrendsChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1896,11 +1896,13 @@ const isSparklineLayout = computed({
role="region"
aria-labelledby="trends-chart-title"
:class="
isMobile === false && width > 0
? showCorrectionControls
? 'h-[491px]'
: 'h-[567px]'
: 'min-h-[260px]'
isSparklineLayout || !inModal
? undefined
: isMobile === false && width > 0
? showCorrectionControls
? 'h-[491px]'
: 'h-[567px]'
: 'min-h-[260px]'
"
>
<ClientOnly v-if="chartData.dataset">
Expand Down
2 changes: 1 addition & 1 deletion app/composables/usePackageSelection.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const MAX_PACKAGE_SELECTION = 4
export const MAX_PACKAGE_SELECTION = 10

export function usePackageSelection() {
const selectedPackagesParam = useRouteQuery<string>('selection', '', { mode: 'replace' })
Expand Down
9 changes: 4 additions & 5 deletions app/pages/compare.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ definePageMeta({

const { locale } = useI18n()
const { copied, copy } = useClipboard({ copiedDuring: 2000 })
const maxPackages = 4

// Sync packages with URL query param (stable ref - doesn't change on other query changes)
const packagesParam = useRouteQuery<string>('packages', '', { mode: 'replace' })
Expand All @@ -23,7 +22,7 @@ const packages = computed({
.split(',')
.map(p => p.trim())
.filter(p => p.length > 0)
.slice(0, maxPackages)
.slice(0, MAX_PACKAGE_SELECTION)
},
set(value) {
packagesParam.value = value.length > 0 ? value.join(',') : ''
Expand Down Expand Up @@ -61,12 +60,12 @@ const gridColumns = computed(() =>

// Whether we can add the no-dep column (not already added and have room)
const canAddNoDep = computed(
() => packages.value.length < maxPackages && !packages.value.includes(NO_DEPENDENCY_ID),
() => packages.value.length < MAX_PACKAGE_SELECTION && !packages.value.includes(NO_DEPENDENCY_ID),
)

// Add "no dependency" column to comparison
function addNoDep() {
if (packages.value.length >= maxPackages) return
if (packages.value.length >= MAX_PACKAGE_SELECTION) return
if (packages.value.includes(NO_DEPENDENCY_ID)) return
packages.value = [...packages.value, NO_DEPENDENCY_ID]
}
Expand Down Expand Up @@ -183,7 +182,7 @@ useSeoMeta({
<h2 id="packages-heading" class="text-xs text-fg-subtle uppercase tracking-wider mb-3">
{{ $t('compare.packages.section_packages') }}
</h2>
<ComparePackageSelector v-model="packages" :max="maxPackages" />
<ComparePackageSelector v-model="packages" :max="MAX_PACKAGE_SELECTION" />

<!-- "No dep" replacement suggestions (native, simple) -->
<div v-if="noDepSuggestions.length > 0" class="mt-3 space-y-2">
Expand Down
4 changes: 2 additions & 2 deletions test/nuxt/components/compare/PackageSelector.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,15 @@ describe('PackageSelector', () => {
})

describe('max prop', () => {
it('defaults to 4 when not provided', async () => {
it('defaults to 10 when not provided', async () => {
const component = await mountSuspended(PackageSelector, {
props: {
modelValue: [],
},
})

// Should show max of 4 in hint
expect(component.text()).toContain('4')
expect(component.text()).toContain('1O')
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
})

it('uses provided max value', async () => {
Expand Down
Loading