Skip to content

Commit 10dd2fb

Browse files
committed
Use button group for filters
1 parent fbfa6b4 commit 10dd2fb

File tree

4 files changed

+99
-40
lines changed

4 files changed

+99
-40
lines changed

_includes/feature-table.html

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,15 @@
1010
x-cloak
1111
>
1212
<div id="table-actions">
13-
<fieldset
14-
x-id="['filter-legend']"
15-
x-bind:aria-labelledby="$id('filter-legend')"
16-
x-show="categories.length"
17-
>
13+
<fieldset x-show="categories.length">
14+
<legend>Currently showing:</legend>
1815
<div id="platform-filters">
19-
<span class="legend" x-bind:id="$id('filter-legend')">Currently showing:</span>
20-
<div id="platform-filter-options">
21-
<template x-for="category in categories" x-bind:key="category">
22-
<div x-id="['platform-filter']" class="platform-filter">
23-
<input type="checkbox" x-bind:id="$id('platform-filter')" x-bind:value="category" x-model="selectedCategories" />
24-
<label x-bind:for="$id('platform-filter')" x-text="category"></label>
25-
</div>
26-
</template>
27-
</div>
16+
<template x-for="category in categories" x-bind:key="category">
17+
<label class="platform-filter" x-id="['platform-filter']">
18+
<input type="checkbox" x-bind:id="$id('platform-filter')" x-bind:value="category" x-model="selectedCategories" />
19+
<div class="checkbox-button" x-bind:for="$id('platform-filter')" x-text="category"></div>
20+
</label>
21+
</template>
2822
</div>
2923
</fieldset>
3024
<div>

css/dark.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33

44
--color-fg: #e5e5e5;
55
--color-bg: #1e1e1e;
6-
--color-highlight-bg: rgb(255 255 255 / 4%);
6+
--color-bg-highlight: rgb(255 255 255 / 4%);
7+
--color-bg-secondary: #202020;
78
--color-link: #7cb1e2;
89
--color-link-visited: #ab8fee;
910
--color-border: #404549;
11+
--color-border-primary: #2a4872;
1012

1113
color: var(--color-fg);
1214
background-color: var(--color-bg);

css/feature-table.css

Lines changed: 85 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,41 +40,27 @@
4040
display: flex;
4141
flex-wrap: wrap;
4242
justify-content: space-between;
43-
align-items: center;
43+
align-items: end;
4444
gap: 1.5rem;
4545
row-gap: 0.75rem;
4646
}
4747

48-
#platform-filters {
49-
display: flex; /* Flexbox does not work with <fieldset> due to a bug */
50-
flex-wrap: wrap;
51-
gap: 0.8rem;
52-
row-gap: 0.2rem;
53-
}
54-
55-
#platform-filters .legend {
48+
#table-actions legend {
5649
font-weight: 600;
5750
}
5851

59-
#platform-filter-options {
60-
display: flex;
61-
flex-wrap: wrap;
62-
gap: 1rem;
63-
row-gap: 0.2rem;
64-
}
65-
66-
/* Threshold should be revised when categories change. */
67-
@media (max-width: 24em) {
68-
#platform-filter-options {
69-
flex-direction: column;
70-
}
52+
#platform-filters {
53+
display: flex; /* Flexbox does not work with <fieldset> due to a bug */
54+
flex-direction: column;
55+
gap: 0.2rem;
56+
margin-top: 0.2rem;
7157
}
7258

7359
.platform-filter {
7460
flex: 1 1 auto;
7561
display: flex;
7662
align-items: center;
77-
gap: 4px;
63+
gap: 6px;
7864
user-select: none;
7965
}
8066

@@ -86,12 +72,87 @@
8672
margin-top: 2px; /* Align checkbox with label */
8773
}
8874

75+
/* Style as button groups on desktop. Threshold should be revised when categories change. */
76+
@media (min-width: 50rem) {
77+
#table-actions {
78+
align-items: center;
79+
}
80+
81+
#table-actions legend {
82+
/* Visually hidden */
83+
position: absolute;
84+
width: 1px;
85+
height: 1px;
86+
padding: 0;
87+
margin: -1px;
88+
border: none;
89+
white-space: nowrap;
90+
overflow: hidden;
91+
clip: rect(0, 0, 0, 0);
92+
}
93+
94+
#platform-filters {
95+
flex-direction: row;
96+
gap: 0;
97+
max-width: 95vw;
98+
overflow: auto visible;
99+
background-color: var(--color-bg-secondary);
100+
}
101+
102+
.platform-filter {
103+
font-size: 0.95rem;
104+
padding: 0.3rem 0.75rem;
105+
padding-inline-start: 0.6rem;
106+
gap: 0.6rem;
107+
min-width: max-content;
108+
109+
--border: 1px solid var(--color-border);
110+
border: var(--border);
111+
}
112+
113+
.platform-filter:first-of-type {
114+
border-top-left-radius: 4px;
115+
border-bottom-left-radius: 4px;
116+
}
117+
118+
.platform-filter:last-of-type {
119+
border-top-right-radius: 4px;
120+
border-bottom-right-radius: 4px;
121+
}
122+
123+
.platform-filter > input {
124+
transform: scale(1.05);
125+
}
126+
127+
.platform-filter:has(input:checked) {
128+
--color-border: var(--color-border-primary);
129+
}
130+
131+
/* Combo 1: checked|R| + |L|checked => hide |L| border */
132+
/* Combo 2: any|R| + |L|unchecked => hide |L| border */
133+
.platform-filter:has(input:checked) + .platform-filter:has(input:checked),
134+
.platform-filter + .platform-filter:has(input:not(:checked)) {
135+
border-left: none;
136+
}
137+
138+
/* Combo 3: unchecked|R| + |L|checked => hide |R| border */
139+
.platform-filter:has(input:not(:checked)):has(
140+
+ .platform-filter > input:checked
141+
) {
142+
border-right: none;
143+
}
144+
145+
.platform-filter:has(input:focus-visible) {
146+
box-shadow: inset 0 0 0 0.25rem rgb(57 177 255 / 50%);
147+
}
148+
}
149+
89150
#feature-scroll {
90151
width: max-content;
91152
min-width: 100%;
92153
max-width: 95vw;
93154
margin: 0 50%;
94-
margin-top: 0.75rem;
155+
margin-top: 0.85rem;
95156
transform: translateX(-50%);
96157
overflow-x: auto;
97158
}
@@ -197,7 +258,7 @@ button.cell {
197258
}
198259

199260
button.cell:hover {
200-
background: var(--color-highlight-bg);
261+
background: var(--color-bg-highlight);
201262
}
202263

203264
button.cell[aria-expanded='true'] {

css/light.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33

44
--color-fg: #151515;
55
--color-bg: #fefefe;
6-
--color-highlight-bg: rgb(0 0 0 / 5%);
6+
--color-bg-highlight: rgb(0 0 0 / 5%);
7+
--color-bg-secondary: rgb(0 0 0 / 1.25%);
78
--color-link: #1751a7;
89
--color-link-visited: #5817a7;
910
--color-border: rgb(0 0 0 / 15%);
11+
--color-border-primary: #7facec;
1012

1113
color: var(--color-fg);
1214
background-color: var(--color-bg);

0 commit comments

Comments
 (0)