|
2 | 2 | import { getContext } from "svelte"; |
3 | 3 | import Icon from "$components/helpers/Icon.svelte"; |
4 | 4 | import leaderboardData from "$data/leaderboard.json"; |
| 5 | + import { LEVEL_DISPLAY_LABELS, LEVEL_ORDER } from "$utils/constants.js"; |
| 6 | + import { formatAdvantage, getCellClass } from "$utils/formatting.js"; |
5 | 7 |
|
6 | 8 | const copy = getContext("copy") || {}; |
7 | 9 | const headerCopy = copy.paperHeader || {}; |
|
55 | 57 | ? abstractConfig.paragraphs |
56 | 58 | : defaultAbstractParagraphs; |
57 | 59 |
|
58 | | - // Hardcoded leaderboard data matching main Leaderboard.svelte structure |
| 60 | + // Leaderboard data |
59 | 61 | const leaderboardTitle = headerCopy.leaderboard.title; |
60 | 62 | const leaderboardDescription = headerCopy.leaderboard.description; |
61 | 63 |
|
62 | | - // Level display labels - matching main Leaderboard |
63 | | - const LEVEL_DISPLAY_LABELS = { |
64 | | - "no-aggregation": "L0: No Aggregation", |
65 | | - "param-level": "L1: Parameter", |
66 | | - "func-level": "L2: Function", |
67 | | - "class-level": "L3: Class", |
68 | | - "module-level": "L4: Module", |
69 | | - }; |
70 | | -
|
71 | | - // Hardcoded levels in order |
72 | | - const levels = ["param-level", "func-level", "class-level", "module-level"]; |
| 64 | + // Use centralized level order |
| 65 | + const levels = LEVEL_ORDER; |
73 | 66 |
|
74 | 67 | // Hardcoded table data - example data, replace with actual values |
75 | 68 | const tableData = Array.isArray(leaderboardData?.tableData) ? leaderboardData.tableData : []; |
|
83 | 76 | hero?.body || |
84 | 77 | (hero?.cta && hero.cta.label) |
85 | 78 | ); |
86 | | -
|
87 | | - // Helper functions matching main Leaderboard.svelte |
88 | | - function formatAdvantage(value) { |
89 | | - if (value === null || value === undefined) return "—"; |
90 | | - return value.toFixed(4); |
91 | | - } |
92 | | -
|
93 | | - function getCellClass(value) { |
94 | | - if (value === null || value === undefined) return ""; |
95 | | - if (value >= 0.1) return "high"; |
96 | | - if (value >= 0) return "medium"; |
97 | | - return "low"; |
98 | | - } |
99 | 79 | </script> |
100 | 80 |
|
101 | 81 | <section class="paper-header"> |
|
431 | 411 | } |
432 | 412 |
|
433 | 413 | .header-leaderboard tbody tr:hover { |
434 | | - background: rgba(207, 202, 191, 0.05); |
| 414 | + background: var(--wine-tan-transparent); |
435 | 415 | } |
436 | 416 |
|
437 | 417 | .header-leaderboard td { |
|
455 | 435 | .header-leaderboard .overall-cell { |
456 | 436 | font-weight: 700; |
457 | 437 | font-size: var(--16px); |
458 | | - background: rgba(207, 202, 191, 0.05); |
| 438 | + background: var(--wine-tan-transparent); |
459 | 439 | } |
460 | 440 |
|
461 | | - /* Color coding for scores - matching main Leaderboard.svelte */ |
| 441 | + /* Color coding for scores */ |
462 | 442 | .header-leaderboard .score-cell.high { |
463 | | - color: #0f9d58; |
| 443 | + color: var(--score-good); |
464 | 444 | } |
465 | 445 |
|
466 | 446 | .header-leaderboard .score-cell.medium { |
467 | 447 | color: #d8d8d8; |
468 | 448 | } |
469 | 449 |
|
470 | 450 | .header-leaderboard .score-cell.low { |
471 | | - color: #e84545; |
| 451 | + color: var(--score-bad); |
472 | 452 | } |
473 | 453 |
|
474 | 454 | .paper-hero { |
|
0 commit comments