county commited on
Commit ·
96eb17e
1
Parent(s): 43f029b
Polish cross-judge toggle UX and accessibility
Browse files- script.js +24 -21
- styles.css +19 -12
script.js
CHANGED
|
@@ -371,6 +371,19 @@ function getDeltaClass(delta) {
|
|
| 371 |
return delta > 0 ? "positive" : "negative";
|
| 372 |
}
|
| 373 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 374 |
function renderControls() {
|
| 375 |
if (!taskToggleRoot || !judgeToggleRoot || !metricToggleRoot) {
|
| 376 |
return;
|
|
@@ -383,13 +396,13 @@ function renderControls() {
|
|
| 383 |
];
|
| 384 |
taskToggleRoot.innerHTML = "";
|
| 385 |
taskItems.forEach((item) => {
|
| 386 |
-
const button =
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
taskToggleRoot.appendChild(button);
|
| 394 |
});
|
| 395 |
|
|
@@ -407,11 +420,7 @@ function renderControls() {
|
|
| 407 |
{ key: "gemini", label: "Gemini-2.5-Flash" }
|
| 408 |
];
|
| 409 |
judgeItems.forEach((item) => {
|
| 410 |
-
const button =
|
| 411 |
-
button.type = "button";
|
| 412 |
-
button.className = `toggle-btn${item.key === crossJudgeState.activeJudge ? " active" : ""}`;
|
| 413 |
-
button.textContent = item.label;
|
| 414 |
-
button.addEventListener("click", () => {
|
| 415 |
renderResultsPanel(crossJudgeState.activeTask, item.key, crossJudgeState.activeMetric);
|
| 416 |
});
|
| 417 |
judgeToggleRoot.appendChild(button);
|
|
@@ -422,11 +431,7 @@ function renderControls() {
|
|
| 422 |
{ key: "oeScr", label: "OE_scr" }
|
| 423 |
];
|
| 424 |
metricItems.forEach((item) => {
|
| 425 |
-
const button =
|
| 426 |
-
button.type = "button";
|
| 427 |
-
button.className = `toggle-btn${item.key === crossJudgeState.activeMetric ? " active" : ""}`;
|
| 428 |
-
button.textContent = item.label;
|
| 429 |
-
button.addEventListener("click", () => {
|
| 430 |
renderResultsPanel(crossJudgeState.activeTask, crossJudgeState.activeJudge, item.key);
|
| 431 |
});
|
| 432 |
metricToggleRoot.appendChild(button);
|
|
@@ -438,10 +443,8 @@ function renderControls() {
|
|
| 438 |
if (judgeToggleRow) {
|
| 439 |
judgeToggleRow.classList.add("is-hidden");
|
| 440 |
}
|
| 441 |
-
const mcButton =
|
| 442 |
-
mcButton.
|
| 443 |
-
mcButton.className = "toggle-btn active";
|
| 444 |
-
mcButton.textContent = "MC_acc";
|
| 445 |
metricToggleRoot.appendChild(mcButton);
|
| 446 |
}
|
| 447 |
|
|
|
|
| 371 |
return delta > 0 ? "positive" : "negative";
|
| 372 |
}
|
| 373 |
|
| 374 |
+
function createToggleButton(label, isActive, onClick) {
|
| 375 |
+
const button = document.createElement("button");
|
| 376 |
+
button.type = "button";
|
| 377 |
+
button.className = `toggle-btn${isActive ? " active" : ""}`;
|
| 378 |
+
button.textContent = label;
|
| 379 |
+
button.setAttribute("aria-pressed", String(isActive));
|
| 380 |
+
if (isActive) {
|
| 381 |
+
button.setAttribute("aria-current", "true");
|
| 382 |
+
}
|
| 383 |
+
button.addEventListener("click", onClick);
|
| 384 |
+
return button;
|
| 385 |
+
}
|
| 386 |
+
|
| 387 |
function renderControls() {
|
| 388 |
if (!taskToggleRoot || !judgeToggleRoot || !metricToggleRoot) {
|
| 389 |
return;
|
|
|
|
| 396 |
];
|
| 397 |
taskToggleRoot.innerHTML = "";
|
| 398 |
taskItems.forEach((item) => {
|
| 399 |
+
const button = createToggleButton(
|
| 400 |
+
item.label === "MC" ? "MC (main benchmark)" : "OE (cross-judge)",
|
| 401 |
+
item.key === crossJudgeState.activeTask,
|
| 402 |
+
() => {
|
| 403 |
+
renderResultsPanel(item.key, crossJudgeState.activeJudge, crossJudgeState.activeMetric);
|
| 404 |
+
}
|
| 405 |
+
);
|
| 406 |
taskToggleRoot.appendChild(button);
|
| 407 |
});
|
| 408 |
|
|
|
|
| 420 |
{ key: "gemini", label: "Gemini-2.5-Flash" }
|
| 421 |
];
|
| 422 |
judgeItems.forEach((item) => {
|
| 423 |
+
const button = createToggleButton(item.label, item.key === crossJudgeState.activeJudge, () => {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 424 |
renderResultsPanel(crossJudgeState.activeTask, item.key, crossJudgeState.activeMetric);
|
| 425 |
});
|
| 426 |
judgeToggleRoot.appendChild(button);
|
|
|
|
| 431 |
{ key: "oeScr", label: "OE_scr" }
|
| 432 |
];
|
| 433 |
metricItems.forEach((item) => {
|
| 434 |
+
const button = createToggleButton(item.label, item.key === crossJudgeState.activeMetric, () => {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 435 |
renderResultsPanel(crossJudgeState.activeTask, crossJudgeState.activeJudge, item.key);
|
| 436 |
});
|
| 437 |
metricToggleRoot.appendChild(button);
|
|
|
|
| 443 |
if (judgeToggleRow) {
|
| 444 |
judgeToggleRow.classList.add("is-hidden");
|
| 445 |
}
|
| 446 |
+
const mcButton = createToggleButton("MC_acc", true, () => {});
|
| 447 |
+
mcButton.disabled = true;
|
|
|
|
|
|
|
| 448 |
metricToggleRoot.appendChild(mcButton);
|
| 449 |
}
|
| 450 |
|
styles.css
CHANGED
|
@@ -502,12 +502,12 @@ code {
|
|
| 502 |
|
| 503 |
.cross-toolbar {
|
| 504 |
display: grid;
|
| 505 |
-
gap:
|
| 506 |
margin-bottom: 8px;
|
| 507 |
-
padding:
|
| 508 |
-
border: 1px solid #
|
| 509 |
-
border-radius:
|
| 510 |
-
background: #
|
| 511 |
}
|
| 512 |
|
| 513 |
.toolbar-row {
|
|
@@ -535,24 +535,26 @@ code {
|
|
| 535 |
.toggle-group {
|
| 536 |
display: flex;
|
| 537 |
flex-wrap: wrap;
|
| 538 |
-
gap:
|
|
|
|
| 539 |
}
|
| 540 |
|
| 541 |
.toggle-btn {
|
| 542 |
-
border: 1px solid #
|
| 543 |
border-radius: 999px;
|
| 544 |
-
padding:
|
| 545 |
background: #f8f5ee;
|
| 546 |
-
color: #
|
| 547 |
font: inherit;
|
| 548 |
font-size: 0.83rem;
|
| 549 |
font-weight: 600;
|
| 550 |
cursor: pointer;
|
| 551 |
-
|
|
|
|
| 552 |
}
|
| 553 |
|
| 554 |
.toggle-btn:hover {
|
| 555 |
-
border-color: #
|
| 556 |
background: #f1ede4;
|
| 557 |
}
|
| 558 |
|
|
@@ -560,7 +562,12 @@ code {
|
|
| 560 |
border-color: #171717;
|
| 561 |
background: #151515;
|
| 562 |
color: #ffffff;
|
| 563 |
-
box-shadow: 0 2px 8px rgb(17 17 17 /
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 564 |
}
|
| 565 |
|
| 566 |
.is-hidden {
|
|
|
|
| 502 |
|
| 503 |
.cross-toolbar {
|
| 504 |
display: grid;
|
| 505 |
+
gap: 8px;
|
| 506 |
margin-bottom: 8px;
|
| 507 |
+
padding: 10px;
|
| 508 |
+
border: 1px solid #e2ddcf;
|
| 509 |
+
border-radius: 12px;
|
| 510 |
+
background: linear-gradient(180deg, #faf8f2 0%, #f5f2e9 100%);
|
| 511 |
}
|
| 512 |
|
| 513 |
.toolbar-row {
|
|
|
|
| 535 |
.toggle-group {
|
| 536 |
display: flex;
|
| 537 |
flex-wrap: wrap;
|
| 538 |
+
gap: 6px;
|
| 539 |
+
align-items: center;
|
| 540 |
}
|
| 541 |
|
| 542 |
.toggle-btn {
|
| 543 |
+
border: 1px solid #c9c2b4;
|
| 544 |
border-radius: 999px;
|
| 545 |
+
padding: 6px 12px;
|
| 546 |
background: #f8f5ee;
|
| 547 |
+
color: #454038;
|
| 548 |
font: inherit;
|
| 549 |
font-size: 0.83rem;
|
| 550 |
font-weight: 600;
|
| 551 |
cursor: pointer;
|
| 552 |
+
min-height: 34px;
|
| 553 |
+
transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
|
| 554 |
}
|
| 555 |
|
| 556 |
.toggle-btn:hover {
|
| 557 |
+
border-color: #b6ae9f;
|
| 558 |
background: #f1ede4;
|
| 559 |
}
|
| 560 |
|
|
|
|
| 562 |
border-color: #171717;
|
| 563 |
background: #151515;
|
| 564 |
color: #ffffff;
|
| 565 |
+
box-shadow: 0 2px 8px rgb(17 17 17 / 16%);
|
| 566 |
+
}
|
| 567 |
+
|
| 568 |
+
.toggle-btn:disabled {
|
| 569 |
+
opacity: 1;
|
| 570 |
+
cursor: default;
|
| 571 |
}
|
| 572 |
|
| 573 |
.is-hidden {
|