Skip to content

Commit 1c9c046

Browse files
committed
Add filter chips
1 parent 00037bf commit 1c9c046

2 files changed

Lines changed: 103 additions & 8 deletions

File tree

static/css/layout.css

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,10 +485,27 @@ nav {
485485
gap: 1rem;
486486
}
487487

488+
.arenas-grid a {
489+
transition: opacity 0.25s ease;
490+
}
491+
488492
.arenas-grid a:hover {
489493
border-bottom-color: transparent;
490494
}
491495

496+
/* Filter/preview: dim non-matching arenas on chip hover (transient) or when a
497+
filter is toggled on via .filter-* on the container (persistent). Both paths
498+
share this rule, so hovering and clicking produce the identical effect. The
499+
dimmed cards are also disabled — pointer-events: none removes the click and
500+
suppresses the hover float animation in one stroke. */
501+
.arenas-container.filter-test .arenas-grid a:not([data-test]),
502+
.arenas-container:has(.filter-chip[data-filter="test"]:hover) .arenas-grid a:not([data-test]),
503+
.arenas-container.filter-ladder .arenas-grid a:not([data-ladder]),
504+
.arenas-container:has(.filter-chip[data-filter="ladder"]:hover) .arenas-grid a:not([data-ladder]) {
505+
opacity: 0.3;
506+
pointer-events: none;
507+
}
508+
492509
.arena-card {
493510
display: flex;
494511
flex-direction: column;
@@ -529,12 +546,48 @@ nav {
529546
}
530547

531548
.arenas-legend {
532-
margin: 1.25rem 0 0 0;
549+
margin: -0.75rem 0 1.5rem 0;
550+
display: flex;
551+
flex-wrap: wrap;
552+
align-items: center;
553+
justify-content: center;
554+
gap: 0.5rem;
533555
text-align: center;
534556
color: var(--muted);
535557
font-size: var(--text-sm);
536558
}
537559

560+
.filter-chip {
561+
cursor: pointer;
562+
display: inline-flex;
563+
align-items: center;
564+
gap: 0.4em;
565+
border: 1px solid var(--border);
566+
border-radius: 999px;
567+
padding: 0.2em 0.7em;
568+
background-color: var(--bg);
569+
user-select: none;
570+
transition: color 0.2s, background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
571+
}
572+
573+
.filter-chip:hover {
574+
color: var(--fg);
575+
border-color: var(--accent);
576+
box-shadow: 0 1px 4px var(--box-shadow);
577+
}
578+
579+
.filter-chip:focus-visible {
580+
outline: 2px solid var(--accent);
581+
outline-offset: 2px;
582+
}
583+
584+
.filter-chip[aria-pressed="true"] {
585+
color: var(--fg);
586+
border-color: var(--accent);
587+
background-color: color-mix(in srgb, var(--accent) 18%, transparent);
588+
font-weight: var(--weight-semibold);
589+
}
590+
538591
.arenas-legend a {
539592
color: inherit;
540593
text-decoration: underline;

templates/arenas.html

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,27 @@ <h1>Arenas</h1>
88
</div>
99

1010
<div class="arenas-container">
11+
<p class="arenas-legend">
12+
<span
13+
class="filter-chip"
14+
data-filter="test"
15+
role="button"
16+
tabindex="0"
17+
aria-pressed="false"
18+
title="Click to highlight test set arenas"
19+
><span class="eval-badge"></span> Test set arena</span>
20+
<span
21+
class="filter-chip"
22+
data-filter="ladder"
23+
role="button"
24+
tabindex="0"
25+
aria-pressed="false"
26+
title="Click to highlight arenas with a CC:Ladder"
27+
><span class="ladder-badge">🪜</span> Has a <a href="/insights/20260115_human_ai_ladder/">CC:Ladder</a></span>
28+
</p>
1129
<div class="arenas-grid">
1230
{%- for page in pages | sort(attribute='title') %}
13-
<a href="{{ url_for("page", path=page.path) }}">
31+
<a href="{{ url_for("page", path=page.path) }}"{% if page.split == 'test' %} data-test{% endif %}{% if page.ladder %} data-ladder{% endif %}>
1432
<div class="arena-card">
1533
<p class="arena-title">
1634
<img
@@ -25,11 +43,35 @@ <h1>Arenas</h1>
2543
</a>
2644
{%- endfor %}
2745
</div>
28-
<p class="arenas-legend">
29-
<span class="eval-badge"></span> = Test set arena
30-
&nbsp;&bull;&nbsp;
31-
<span class="ladder-badge">🪜</span> = Has a <a href="/insights/20260115_human_ai_ladder/">CC:Ladder</a>
32-
</p>
3346
</div>
34-
3547
{% endblock content %}
48+
49+
{% block scripts %}
50+
<script>
51+
// Arena filter chips: click a legend marker to highlight matching arenas.
52+
// Hovering a chip previews the same dimming (see .filter-chip:hover in CSS).
53+
(function () {
54+
var container = document.querySelector('.arenas-container');
55+
if (!container) return;
56+
57+
document.querySelectorAll('.arenas-legend .filter-chip').forEach(function (chip) {
58+
function toggle() {
59+
var name = chip.getAttribute('data-filter');
60+
var active = container.classList.toggle('filter-' + name);
61+
chip.setAttribute('aria-pressed', active ? 'true' : 'false');
62+
}
63+
chip.addEventListener('click', toggle);
64+
chip.addEventListener('keydown', function (e) {
65+
if (e.key === 'Enter' || e.key === ' ') {
66+
e.preventDefault();
67+
toggle();
68+
}
69+
});
70+
// Let the nested CC:Ladder link navigate without toggling the filter.
71+
chip.querySelectorAll('a').forEach(function (link) {
72+
link.addEventListener('click', function (e) { e.stopPropagation(); });
73+
});
74+
});
75+
})();
76+
</script>
77+
{% endblock scripts %}

0 commit comments

Comments
 (0)