File size: 8,778 Bytes
982b341
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
"""
Custom CSS, HTML, and JavaScript for the CodeReview Leaderboard
"""

# Dark theme CSS
DARK_THEME_CSS = """
/* Dark Theme Styling */
:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --text-primary: #e6edf3;
    --text-secondary: #7d8590;
    --border-color: #30363d;
    --accent-color: #238636;
    --accent-hover: #2ea043;
    --danger-color: #da3633;
    --warning-color: #d29922;
    --info-color: #1f6feb;
}

/* Global dark theme */
.gradio-container {
    background: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

/* Headers and text */
.gradio-container h1, .gradio-container h2, .gradio-container h3 {
    color: var(--text-primary) !important;
}

.gradio-container p, .gradio-container span {
    color: var(--text-secondary) !important;
}

/* Tabs */
.gradio-container .tab-nav {
    background: var(--bg-secondary) !important;
    border-bottom: 1px solid var(--border-color) !important;
}

.gradio-container .tab-nav button {
    background: transparent !important;
    color: var(--text-secondary) !important;
    border: none !important;
    padding: 12px 24px !important;
    transition: all 0.2s ease !important;
}

.gradio-container .tab-nav button:hover {
    color: var(--text-primary) !important;
    background: var(--bg-tertiary) !important;
}

.gradio-container .tab-nav button.selected {
    color: var(--text-primary) !important;
    background: var(--bg-tertiary) !important;
    border-bottom: 2px solid var(--accent-color) !important;
}

/* Tables */
.gradio-container .dataframe {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 8px !important;
    overflow: hidden !important;
}

.gradio-container .dataframe table {
    background: var(--bg-secondary) !important;
}

.gradio-container .dataframe th {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border-bottom: 2px solid var(--border-color) !important;
    padding: 12px !important;
    font-weight: 600 !important;
}

.gradio-container .dataframe td {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-bottom: 1px solid var(--border-color) !important;
    padding: 10px 12px !important;
}

.gradio-container .dataframe tr:hover td {
    background: var(--bg-tertiary) !important;
}

/* Form inputs */
.gradio-container input, .gradio-container select, .gradio-container textarea {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 6px !important;
    padding: 8px 12px !important;
}

.gradio-container input:focus, .gradio-container select:focus, .gradio-container textarea:focus {
    border-color: var(--accent-color) !important;
    box-shadow: 0 0 0 2px rgba(35, 134, 54, 0.2) !important;
}

/* Buttons */
.gradio-container button {
    background: var(--accent-color) !important;
    color: white !important;
    border: none !important;
    border-radius: 6px !important;
    padding: 8px 16px !important;
    font-weight: 500 !important;
    transition: all 0.2s ease !important;
}

.gradio-container button:hover {
    background: var(--accent-hover) !important;
    transform: translateY(-1px) !important;
}

.gradio-container button:active {
    transform: translateY(0) !important;
}

/* Dropdowns */
.gradio-container .dropdown {
    background: var(--bg-tertiary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 6px !important;
}

.gradio-container .dropdown-menu {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 6px !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3) !important;
}

.gradio-container .dropdown-menu .dropdown-item {
    color: var(--text-primary) !important;
    padding: 8px 12px !important;
}

.gradio-container .dropdown-menu .dropdown-item:hover {
    background: var(--bg-tertiary) !important;
}

/* Sliders */
.gradio-container .slider {
    background: var(--bg-tertiary) !important;
}

.gradio-container .slider input[type="range"] {
    background: var(--bg-tertiary) !important;
}

.gradio-container .slider input[type="range"]::-webkit-slider-thumb {
    background: var(--accent-color) !important;
    border: 2px solid var(--bg-secondary) !important;
    border-radius: 50% !important;
    width: 18px !important;
    height: 18px !important;
}

.gradio-container .slider input[type="range"]::-webkit-slider-track {
    background: var(--border-color) !important;
    border-radius: 4px !important;
    height: 6px !important;
}

/* Accordions */
.gradio-container .accordion {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 8px !important;
    margin: 16px 0 !important;
}

.gradio-container .accordion-header {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    padding: 16px !important;
    border-bottom: 1px solid var(--border-color) !important;
    cursor: pointer !important;
    font-weight: 500 !important;
}

.gradio-container .accordion-header:hover {
    background: var(--bg-primary) !important;
}

/* Status messages */
.gradio-container .success {
    background: rgba(35, 134, 54, 0.1) !important;
    color: var(--accent-color) !important;
    border: 1px solid var(--accent-color) !important;
    border-radius: 6px !important;
    padding: 12px 16px !important;
    margin: 8px 0 !important;
}

.gradio-container .error {
    background: rgba(218, 54, 51, 0.1) !important;
    color: var(--danger-color) !important;
    border: 1px solid var(--danger-color) !important;
    border-radius: 6px !important;
    padding: 12px 16px !important;
    margin: 8px 0 !important;
}

/* Responsive design */
@media (max-width: 768px) {
    .gradio-container {
        padding: 16px !important;
    }
    
    .gradio-container .tab-nav button {
        padding: 8px 16px !important;
        font-size: 14px !important;
    }
    
    .gradio-container .dataframe {
        font-size: 14px !important;
    }
}
"""

# Custom JavaScript for enhanced functionality
CUSTOM_JS = """
// Enhanced table sorting and filtering
function enhanceTable() {
    const tables = document.querySelectorAll('.dataframe table');
    tables.forEach(table => {
        // Add sorting functionality
        const headers = table.querySelectorAll('th');
        headers.forEach((header, index) => {
            header.style.cursor = 'pointer';
            header.addEventListener('click', () => sortTable(table, index));
        });
    });
}

function sortTable(table, columnIndex) {
    const tbody = table.querySelector('tbody');
    const rows = Array.from(tbody.querySelectorAll('tr'));
    
    rows.sort((a, b) => {
        const aText = a.cells[columnIndex].textContent.trim();
        const bText = b.cells[columnIndex].textContent.trim();
        
        // Try to parse as numbers first
        const aNum = parseFloat(aText);
        const bNum = parseFloat(bText);
        
        if (!isNaN(aNum) && !isNaN(bNum)) {
            return bNum - aNum; // Descending for numbers
        }
        
        return aText.localeCompare(bText); // Ascending for text
    });
    
    rows.forEach(row => tbody.appendChild(row));
}

// Auto-refresh functionality
function autoRefresh() {
    setInterval(() => {
        const refreshBtn = document.querySelector('button[aria-label="Refresh"]');
        if (refreshBtn) {
            refreshBtn.click();
        }
    }, 30000); // Refresh every 30 seconds
}

// Initialize enhancements
document.addEventListener('DOMContentLoaded', function() {
    enhanceTable();
    autoRefresh();
});
"""

# HTML components
HEADER_HTML = """
<div style="text-align: center; padding: 20px; background: var(--bg-secondary); border-radius: 12px; margin-bottom: 20px;">
    <h1 style="color: var(--text-primary); margin: 0; font-size: 2.5em; font-weight: 700;">
        🏆 CodeReview Leaderboard
    </h1>
    <p style="color: var(--text-secondary); margin: 10px 0 0 0; font-size: 1.2em;">
        Benchmarking code review generation models across languages and categories
    </p>
</div>
"""

FOOTER_HTML = """
<div style="text-align: center; padding: 20px; background: var(--bg-secondary); border-radius: 12px; margin-top: 20px;">
    <p style="color: var(--text-secondary); margin: 0; font-size: 0.9em;">
        Built with ❤️ for the code review community | 
        <a href="https://github.com/your-repo" style="color: var(--accent-color); text-decoration: none;">
            GitHub
        </a>
    </p>
</div>
"""