Skip to content

Commit f966acf

Browse files
committed
refactor: remove unused release comparison code
1 parent 270cfbe commit f966acf

4 files changed

Lines changed: 2 additions & 146 deletions

File tree

app/components/compare/FacetRow.vue

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import type { FacetValue, FacetDiffResult } from '#shared/types'
2+
import type { FacetValue } from '#shared/types'
33
44
const props = defineProps<{
55
/** Facet label */
@@ -8,8 +8,6 @@ const props = defineProps<{
88
description?: string
99
/** Values for each column */
1010
values: (FacetValue | null | undefined)[]
11-
/** Diff results between adjacent columns (for release comparison) */
12-
diffs?: (FacetDiffResult | null | undefined)[]
1311
/** Whether this row is loading */
1412
loading?: boolean
1513
/** Whether to show the proportional bar (defaults to true for numeric values) */
@@ -52,27 +50,6 @@ function getStatusClass(status?: FacetValue['status']): string {
5250
return 'text-fg'
5351
}
5452
}
55-
56-
function getDiffClass(diff?: FacetDiffResult | null): string {
57-
if (!diff) return ''
58-
if (diff.favorable === true) return 'text-emerald-400'
59-
if (diff.favorable === false) return 'text-red-400'
60-
return 'text-fg-muted'
61-
}
62-
63-
function getDiffIcon(diff?: FacetDiffResult | null): string {
64-
if (!diff) return ''
65-
switch (diff.direction) {
66-
case 'increase':
67-
return 'i-carbon:arrow-up'
68-
case 'decrease':
69-
return 'i-carbon:arrow-down'
70-
case 'changed':
71-
return 'i-carbon:arrows-horizontal'
72-
default:
73-
return ''
74-
}
75-
}
7653
</script>
7754

7855
<template>
@@ -94,7 +71,7 @@ function getDiffIcon(diff?: FacetDiffResult | null): string {
9471
<div
9572
v-for="(value, index) in values"
9673
:key="index"
97-
class="comparison-cell relative flex flex-col items-end justify-center gap-1 px-4 py-3 border-b border-border"
74+
class="comparison-cell relative flex items-end justify-center px-4 py-3 border-b border-border"
9875
>
9976
<!-- Background bar for numeric values -->
10077
<div
@@ -124,21 +101,6 @@ function getDiffIcon(diff?: FacetDiffResult | null): string {
124101
<DateTime v-if="value.type === 'date'" :datetime="value.display" date-style="medium" />
125102
<template v-else>{{ value.display }}</template>
126103
</span>
127-
128-
<!-- Diff indicator (if provided) -->
129-
<div
130-
v-if="diffs && diffs[index] && diffs[index]?.direction !== 'same'"
131-
class="relative flex items-center gap-1 text-xs tabular-nums"
132-
:class="getDiffClass(diffs[index])"
133-
>
134-
<span
135-
v-if="getDiffIcon(diffs[index])"
136-
class="w-3 h-3"
137-
:class="getDiffIcon(diffs[index])"
138-
aria-hidden="true"
139-
/>
140-
<span>{{ diffs[index]?.display }}</span>
141-
</div>
142104
</template>
143105
</div>
144106
</div>

shared/types/comparison.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -129,20 +129,6 @@ export interface FacetValue<T = unknown> {
129129
type?: 'date'
130130
}
131131

132-
/** Result of comparing two facet values */
133-
export interface FacetDiffResult<_T = unknown> {
134-
/** Absolute difference (for numeric values) */
135-
absoluteDiff?: number
136-
/** Percentage difference (for numeric values) */
137-
percentDiff?: number
138-
/** Human-readable difference string */
139-
display: string
140-
/** Direction of change */
141-
direction: 'increase' | 'decrease' | 'same' | 'changed'
142-
/** Whether the change is favorable (depends on facet semantics) */
143-
favorable?: boolean
144-
}
145-
146132
/** Package data for comparison */
147133
export interface ComparisonPackage {
148134
name: string

test/nuxt/components.spec.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,22 +1349,6 @@ describe('component accessibility audits', () => {
13491349
expect(results.violations).toEqual([])
13501350
})
13511351

1352-
it('should have no accessibility violations with diffs', async () => {
1353-
const component = await mountSuspended(CompareFacetRow, {
1354-
props: {
1355-
label: 'Package Size',
1356-
description: 'Size of the package',
1357-
values: [
1358-
{ raw: 100, display: '100 KB' },
1359-
{ raw: 150, display: '150 KB' },
1360-
],
1361-
diffs: [null, { display: '+50%', direction: 'increase' as const, favorable: false }],
1362-
},
1363-
})
1364-
const results = await runAxe(component)
1365-
expect(results.violations).toEqual([])
1366-
})
1367-
13681352
it('should have no accessibility violations when loading', async () => {
13691353
const component = await mountSuspended(CompareFacetRow, {
13701354
props: {

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

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -169,82 +169,6 @@ describe('FacetRow', () => {
169169
})
170170
})
171171

172-
describe('diff indicators', () => {
173-
it('renders diff with increase direction', async () => {
174-
const component = await mountSuspended(FacetRow, {
175-
props: {
176-
...baseProps,
177-
values: [
178-
{ raw: 100, display: '100', status: 'neutral' },
179-
{ raw: 200, display: '200', status: 'neutral' },
180-
],
181-
diffs: [null, { direction: 'increase', display: '+100%', favorable: true }],
182-
},
183-
})
184-
expect(component.find('.i-carbon\\:arrow-up').exists()).toBe(true)
185-
expect(component.text()).toContain('+100%')
186-
})
187-
188-
it('renders diff with decrease direction', async () => {
189-
const component = await mountSuspended(FacetRow, {
190-
props: {
191-
...baseProps,
192-
values: [
193-
{ raw: 200, display: '200', status: 'neutral' },
194-
{ raw: 100, display: '100', status: 'neutral' },
195-
],
196-
diffs: [null, { direction: 'decrease', display: '-50%', favorable: false }],
197-
},
198-
})
199-
expect(component.find('.i-carbon\\:arrow-down').exists()).toBe(true)
200-
})
201-
202-
it('applies favorable diff styling (green)', async () => {
203-
const component = await mountSuspended(FacetRow, {
204-
props: {
205-
...baseProps,
206-
values: [
207-
{ raw: 100, display: '100', status: 'neutral' },
208-
{ raw: 50, display: '50', status: 'neutral' },
209-
],
210-
diffs: [null, { direction: 'decrease', display: '-50%', favorable: true }],
211-
},
212-
})
213-
expect(component.find('.text-emerald-400').exists()).toBe(true)
214-
})
215-
216-
it('applies unfavorable diff styling (red)', async () => {
217-
const component = await mountSuspended(FacetRow, {
218-
props: {
219-
...baseProps,
220-
values: [
221-
{ raw: 100, display: '100', status: 'neutral' },
222-
{ raw: 200, display: '200', status: 'neutral' },
223-
],
224-
diffs: [null, { direction: 'increase', display: '+100%', favorable: false }],
225-
},
226-
})
227-
// Find the diff section with red styling
228-
const diffElements = component.findAll('.text-red-400')
229-
expect(diffElements.length).toBeGreaterThan(0)
230-
})
231-
232-
it('does not render diff indicator for same direction', async () => {
233-
const component = await mountSuspended(FacetRow, {
234-
props: {
235-
...baseProps,
236-
values: [
237-
{ raw: 100, display: '100', status: 'neutral' },
238-
{ raw: 100, display: '100', status: 'neutral' },
239-
],
240-
diffs: [null, { direction: 'same', display: '0%', favorable: undefined }],
241-
},
242-
})
243-
expect(component.find('.i-carbon\\:arrow-up').exists()).toBe(false)
244-
expect(component.find('.i-carbon\\:arrow-down').exists()).toBe(false)
245-
})
246-
})
247-
248172
describe('date values', () => {
249173
it('renders DateTime component for date type values', async () => {
250174
const component = await mountSuspended(FacetRow, {

0 commit comments

Comments
 (0)