|
1 | 1 | 'use client' |
2 | 2 |
|
3 | | -import { useEffect, useRef, useState } from 'react' |
| 3 | +import { useEffect, useMemo, useRef, useState } from 'react' |
| 4 | +import { DeprecatedBadge } from '@/components/controls/DeprecatedBadge' |
4 | 5 | import { Link } from '@/i18n/navigation' |
| 6 | +import { sortDeprecatedLast } from '@/lib/deprecated' |
5 | 7 |
|
6 | 8 | export interface ComparisonColumn { |
7 | 9 | key: string |
@@ -41,6 +43,7 @@ export default function ComparisonTable({ |
41 | 43 | const [scrollLeft, setScrollLeft] = useState<number>(0) |
42 | 44 | const [calculatedOffset, setCalculatedOffset] = useState<number>(0) |
43 | 45 | const columnWidthsMeasured = useRef(false) |
| 46 | + const sortedItems = useMemo(() => sortDeprecatedLast(items), [items]) |
44 | 47 |
|
45 | 48 | useEffect(() => { |
46 | 49 | // Calculate sticky offset based on header and breadcrumb heights |
@@ -231,20 +234,23 @@ export default function ComparisonTable({ |
231 | 234 | </tr> |
232 | 235 | </thead> |
233 | 236 | <tbody> |
234 | | - {items.map((item, index) => ( |
| 237 | + {sortedItems.map((item, index) => ( |
235 | 238 | <tr |
236 | 239 | key={item[itemIdKey] as string} |
237 | 240 | className={`border-b border-[var(--color-border)] hover:bg-[var(--color-hover)] transition-colors ${ |
238 | 241 | index % 2 === 0 ? 'bg-[var(--color-bg)]' : 'bg-[var(--color-hover)]' |
239 | 242 | }`} |
240 | 243 | > |
241 | 244 | <td className="sticky left-0 z-10 bg-inherit px-[var(--spacing-md)] py-[var(--spacing-sm)] font-medium border-r border-[var(--color-border)] whitespace-nowrap"> |
242 | | - <Link |
243 | | - href={`${itemLinkPrefix}/${item[itemIdKey] as string}`} |
244 | | - className="text-[var(--color-text)] hover:text-[var(--color-text-secondary)] hover:underline transition-colors" |
245 | | - > |
246 | | - {item[itemNameKey] as string} |
247 | | - </Link> |
| 245 | + <div className="inline-flex items-center gap-[var(--spacing-xs)]"> |
| 246 | + <Link |
| 247 | + href={`${itemLinkPrefix}/${item[itemIdKey] as string}`} |
| 248 | + className="text-[var(--color-text)] hover:text-[var(--color-text-secondary)] hover:underline transition-colors" |
| 249 | + > |
| 250 | + {item[itemNameKey] as string} |
| 251 | + </Link> |
| 252 | + {item.deprecated === true && <DeprecatedBadge />} |
| 253 | + </div> |
248 | 254 | </td> |
249 | 255 | {columns.map(column => ( |
250 | 256 | <td |
|
0 commit comments