Skip to content

Commit 90c699a

Browse files
committed
Improve Active Filters: remove max-height/scroll, add X icon for close button, make box size dynamically based on content length. Also make X icon immediately sync filter changes in FilterList component
1 parent 7c5e268 commit 90c699a

3 files changed

Lines changed: 55 additions & 21 deletions

File tree

app/components/FilterList.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ const FilterList = ({
1111
}) => {
1212
const [openSections, setOpenSections] = useState({})
1313
const [pendingList, setPendingList] = useState(filterList)
14+
15+
// Sync pendingList when filterList changes (ex. when a filter is removed via X)
16+
useEffect(() => {
17+
setPendingList(filterList)
18+
}, [filterList])
1419
// Calculate available filters from the actual data
1520
const availableFilters = useMemo(() => {
1621
const filters = {}

app/matches/[slug]/page.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,16 +352,26 @@ const MatchPage = ({ params }) => {
352352
</div>
353353
<div className={styles.sidebar}>
354354
<div className={filterListStyles.activeFilterListContainer}>
355-
Active Filters:
355+
<div style={{ width: '100%', marginBottom: '0.5vw' }}>
356+
Active Filters:
357+
</div>
356358
<ul className={filterListStyles.activeFilterList}>
357359
{sortedFilterList.map(([key, value]) => (
358360
<li
359361
className={filterListStyles.activeFilterItem}
360362
key={`${key}-${value}`}
361-
style={{ cursor: 'pointer' }}
362-
onClick={() => removeFilter(key, value)}
363363
>
364-
{findDisplayName(key)}: {value}
364+
<span>{findDisplayName(key)}: {value}</span>
365+
<button
366+
className={filterListStyles.closeButton}
367+
onClick={(e) => {
368+
e.stopPropagation()
369+
removeFilter(key, value)
370+
}}
371+
aria-label="Remove filter"
372+
>
373+
×
374+
</button>
365375
</li>
366376
))}
367377
</ul>

app/styles/FilterList.module.css

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
.activeFilterListContainer {
22
display: flex;
3-
flex-wrap: wrap;
4-
justify-content: space-between;
5-
align-items: center;
3+
flex-direction: column;
4+
align-items: flex-start;
65
box-sizing: border-box;
76
padding: 0.5vw;
87
margin-bottom: 1vw;
98
background-color: #ffffff;
109
border: 1px solid #eaeaea;
1110
border-radius: 10px;
1211
font-size: 1.2vw;
12+
width: 100%;
1313
}
1414

1515
.activeFilterList {
1616
padding: 0;
1717
list-style-type: none;
1818
margin: 0;
1919
border-radius: 0.3vw;
20-
overflow-y: scroll;
21-
max-height: 5vw;
2220
display: flex;
23-
flex-direction: column;
21+
flex-wrap: wrap;
22+
gap: 0.5vw;
2423
width: 100%;
2524
}
2625

2726
.activeFilterItem {
28-
background-color: #fafafa; /* Slightly lighter to distinguish from hover state */
27+
background-color: #fafafa;
2928
color: #333;
30-
border: 1px solid #eaeaea; /* Subtle border color */
29+
border: 1px solid #eaeaea;
3130
border-radius: 0.25vw;
32-
padding: 0.625vw 2.5vw;
33-
margin: 0.5vw;
31+
padding: 0.4vw 1.5vw;
3432
cursor: pointer;
3533
font-size: 1vw;
36-
padding: 0.4vw 1.5vw; /* reduced padding to match smaller text */
37-
margin: 0.3vw;
38-
transition: all 0.2s ease-in-out; /* Smooth transition for all properties */
34+
transition: all 0.2s ease-in-out;
35+
display: inline-flex;
36+
align-items: center;
37+
gap: 0.5vw;
38+
white-space: nowrap;
3939
}
4040

4141
.activeFilterItem:hover {
@@ -44,10 +44,29 @@
4444
}
4545

4646
.activeFilterItem.active {
47-
background-color: #d1eaff; /* A light blue to indicate active status */
48-
color: #0056b3; /* A darker blue to match */
49-
border-color: #0056b3; /* Same dark blue for the border */
50-
box-shadow: 0 0.8vw 1.6vw rgba(0, 0, 0, 0.1); /* Consistent with hover state */
47+
background-color: #d1eaff;
48+
color: #0056b3;
49+
border-color: #0056b3;
50+
box-shadow: 0 0.8vw 1.6vw rgba(0, 0, 0, 0.1);
51+
}
52+
53+
.closeButton {
54+
background: none;
55+
border: none;
56+
cursor: pointer;
57+
font-size: 1.2vw;
58+
color: #666;
59+
padding: 0;
60+
margin: 0;
61+
display: flex;
62+
align-items: center;
63+
justify-content: center;
64+
transition: color 0.2s ease;
65+
font-weight: bold;
66+
}
67+
68+
.closeButton:hover {
69+
color: #333;
5170
}
5271

5372
.availableFilterList {

0 commit comments

Comments
 (0)