Skip to content

Commit 8c42a39

Browse files
committed
Added clear filter button
1 parent c4ea84a commit 8c42a39

File tree

3 files changed

+103
-0
lines changed

3 files changed

+103
-0
lines changed

css/removeFilterBtn.css

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/* Clear Filters Button Styles to match filter-select dimensions */
2+
.filter-clear-btn {
3+
padding: 0.5rem 0.50rem;
4+
border: 1px solid #d1d5db;
5+
border-radius: 8px;
6+
font-size: 0.875rem;
7+
background: white;
8+
color: #6b7280;
9+
cursor: pointer;
10+
display: flex;
11+
align-items: center;
12+
justify-content: center;
13+
gap: 0.5rem;
14+
transition: all 0.2s ease;
15+
width: auto;
16+
min-width: 40px;
17+
}
18+
19+
.filter-clear-btn i {
20+
font-size: 1.1rem;
21+
}
22+
23+
.filter-clear-btn:hover {
24+
background: #f9fafb;
25+
border-color: #2563eb;
26+
}
27+
28+
.filter-clear-btn:focus {
29+
outline: none;
30+
border-color: #2563eb;
31+
box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
32+
}
33+
34+
body.dark-mode .filter-clear-btn {
35+
background: #1f2937;
36+
border-color: #4b5563;
37+
color: #9ca3af;
38+
}
39+
40+
body.dark-mode .filter-clear-btn:hover {
41+
background: #374151;
42+
border-color: #3b82f6;
43+
}
44+
45+
body.dark-mode .filter-clear-btn:focus {
46+
border-color: #3b82f6;
47+
box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
48+
}
49+
50+
.tooltip-container {
51+
position: relative;
52+
display: inline-block;
53+
}
54+
55+
.icon-btn {
56+
background: none;
57+
border: none;
58+
cursor: pointer;
59+
font-size: 18px;
60+
color: #6b7280;
61+
}
62+
63+
.tooltip-text {
64+
visibility: hidden;
65+
opacity: 0;
66+
position: absolute;
67+
left: 120%;
68+
top: 50%;
69+
transform: translateY(-50%);
70+
background-color: #333;
71+
color: #fff;
72+
padding: 4px 8px;
73+
border-radius: 4px;
74+
white-space: nowrap;
75+
font-size: 12px;
76+
}
77+
78+
.tooltip-container:hover .tooltip-text {
79+
display: block;
80+
}
81+

home.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<link rel="icon" type="image/png" sizes="48x48" href="/favicon/favicon-48x48.png" />
2222
<link rel="icon" type="image/png" sizes="32x32" href="/favicon/favicon-32x32.png" />
2323
<link rel="icon" type="image/png" sizes="16x16" href="/favicon/favicon-16x16.png" />
24+
<link rel="stylesheet" href="./css/removeFilterBtn.css">
2425
<link rel="manifest" href="/site.webmanifest" />
2526
<style>
2627
/* Ensure dark mode styles work */
@@ -764,9 +765,18 @@ <h1 class="header-title">
764765
<option value="year-asc">Oldest First</option>
765766
</select>
766767
</div>
768+
<!-- Clear Filters button added #issue-602 -->
769+
<div class="filter-container">
770+
<button id="clearFiltersBtn" class="filter-clear-btn" title="Clear all filters">
771+
<i class="fas fa-eraser" style="color: #6b7280"></i>
772+
</button>
773+
<!-- hover text for clear filter button -->
774+
<span class="tooltip-text">Clear all filters</span>
775+
</div>
767776
</div>
768777
</div>
769778
</div>
779+
<!-- Filter section ends here -->
770780
<div class="main-grid">
771781
<!-- Papers List -->
772782
<div class="papers-section">
@@ -1395,6 +1405,8 @@ <h4>Connect</h4>
13951405
});
13961406
});
13971407
</script>
1408+
1409+
<script src="./js/filterBtn.js"></script>
13981410
</body>
13991411

14001412
</html>

js/filterBtn.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
document.getElementById("clearFiltersBtn").addEventListener("click", function () {
2+
document.getElementById("searchInput").value = "";
3+
document.getElementById("topicFilter").selectedIndex = 0;
4+
document.getElementById("minYear").selectedIndex = 0;
5+
document.getElementById("favoriteFilter").selectedIndex = 0;
6+
document.getElementById("ratingFilter").selectedIndex = 0;
7+
document.getElementById("sortFilter").selectedIndex = 0;
8+
9+
filterPapers();
10+
});

0 commit comments

Comments
 (0)