Skip to content

Commit 754c64c

Browse files
feat: increase max package compares to 10 (#2294)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 3d42fbf commit 754c64c

File tree

5 files changed

+21
-20
lines changed

5 files changed

+21
-20
lines changed

app/components/Compare/PackageSelector.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const props = defineProps<{
88
max?: number
99
}>()
1010
11-
const maxPackages = computed(() => props.max ?? 4)
11+
const maxPackages = computed(() => props.max ?? MAX_PACKAGE_SELECTION)
1212
1313
// Input state
1414
const inputValue = shallowRef('')

app/components/Package/TrendsChart.vue

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,11 +1896,13 @@ const isSparklineLayout = computed({
18961896
role="region"
18971897
aria-labelledby="trends-chart-title"
18981898
:class="
1899-
isMobile === false && width > 0
1900-
? showCorrectionControls
1901-
? 'h-[491px]'
1902-
: 'h-[567px]'
1903-
: 'min-h-[260px]'
1899+
isSparklineLayout || !inModal
1900+
? undefined
1901+
: isMobile === false && width > 0
1902+
? showCorrectionControls
1903+
? 'h-[491px]'
1904+
: 'h-[567px]'
1905+
: 'min-h-[260px]'
19041906
"
19051907
>
19061908
<ClientOnly v-if="chartData.dataset">

app/composables/usePackageSelection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const MAX_PACKAGE_SELECTION = 4
1+
export const MAX_PACKAGE_SELECTION = 10
22

33
export function usePackageSelection() {
44
const selectedPackagesParam = useRouteQuery<string>('selection', '', { mode: 'replace' })

app/pages/compare.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ definePageMeta({
1010
1111
const { locale } = useI18n()
1212
const { copied, copy } = useClipboard({ copiedDuring: 2000 })
13-
const maxPackages = 4
1413
1514
// Sync packages with URL query param (stable ref - doesn't change on other query changes)
1615
const packagesParam = useRouteQuery<string>('packages', '', { mode: 'replace' })
@@ -23,7 +22,7 @@ const packages = computed({
2322
.split(',')
2423
.map(p => p.trim())
2524
.filter(p => p.length > 0)
26-
.slice(0, maxPackages)
25+
.slice(0, MAX_PACKAGE_SELECTION)
2726
},
2827
set(value) {
2928
packagesParam.value = value.length > 0 ? value.join(',') : ''
@@ -61,12 +60,12 @@ const gridColumns = computed(() =>
6160
6261
// Whether we can add the no-dep column (not already added and have room)
6362
const canAddNoDep = computed(
64-
() => packages.value.length < maxPackages && !packages.value.includes(NO_DEPENDENCY_ID),
63+
() => packages.value.length < MAX_PACKAGE_SELECTION && !packages.value.includes(NO_DEPENDENCY_ID),
6564
)
6665
6766
// Add "no dependency" column to comparison
6867
function addNoDep() {
69-
if (packages.value.length >= maxPackages) return
68+
if (packages.value.length >= MAX_PACKAGE_SELECTION) return
7069
if (packages.value.includes(NO_DEPENDENCY_ID)) return
7170
packages.value = [...packages.value, NO_DEPENDENCY_ID]
7271
}
@@ -183,7 +182,7 @@ useSeoMeta({
183182
<h2 id="packages-heading" class="text-xs text-fg-subtle uppercase tracking-wider mb-3">
184183
{{ $t('compare.packages.section_packages') }}
185184
</h2>
186-
<ComparePackageSelector v-model="packages" :max="maxPackages" />
185+
<ComparePackageSelector v-model="packages" :max="MAX_PACKAGE_SELECTION" />
187186

188187
<!-- "No dep" replacement suggestions (native, simple) -->
189188
<div v-if="noDepSuggestions.length > 0" class="mt-3 space-y-2">

test/nuxt/components/compare/PackageSelector.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ describe('PackageSelector', () => {
185185
it('respects max packages limit', async () => {
186186
const component = await mountSuspended(PackageSelector, {
187187
props: {
188-
modelValue: ['a', 'b', 'c', 'd'],
189-
max: 4,
188+
modelValue: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],
189+
max: 10,
190190
},
191191
})
192192

@@ -200,19 +200,19 @@ describe('PackageSelector', () => {
200200
const component = await mountSuspended(PackageSelector, {
201201
props: {
202202
modelValue: ['lodash', 'underscore'],
203-
max: 4,
203+
max: 10,
204204
},
205205
})
206206

207207
expect(component.text()).toContain('2')
208-
expect(component.text()).toContain('4')
208+
expect(component.text()).toContain('10')
209209
})
210210

211211
it('shows add hint when less than 2 packages', async () => {
212212
const component = await mountSuspended(PackageSelector, {
213213
props: {
214214
modelValue: ['lodash'],
215-
max: 4,
215+
max: 10,
216216
},
217217
})
218218

@@ -222,15 +222,15 @@ describe('PackageSelector', () => {
222222
})
223223

224224
describe('max prop', () => {
225-
it('defaults to 4 when not provided', async () => {
225+
it('defaults to 10 when not provided', async () => {
226226
const component = await mountSuspended(PackageSelector, {
227227
props: {
228228
modelValue: [],
229229
},
230230
})
231231

232-
// Should show max of 4 in hint
233-
expect(component.text()).toContain('4')
232+
// Should show max of 10 in hint
233+
expect(component.text()).toContain('10')
234234
})
235235

236236
it('uses provided max value', async () => {

0 commit comments

Comments
 (0)