Skip to content

Commit 8f370e3

Browse files
committed
Improve filter visibility and add clear filters option
1 parent 356b8f1 commit 8f370e3

3 files changed

Lines changed: 82 additions & 21 deletions

File tree

src/pages/showcase/_components/ShowcaseTagSelect/styles.module.css

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
box-shadow: 0 0 2px 1px var(--ifm-color-secondary-darkest);
1111
}
1212

13-
input[type="checkbox"] + .checkboxLabel {
13+
input[type="checkbox"]+.checkboxLabel {
1414
display: flex;
1515
align-items: center;
1616
cursor: pointer;
@@ -22,30 +22,38 @@ input[type="checkbox"] + .checkboxLabel {
2222
border: 2px solid var(--ifm-color-secondary-darkest);
2323
}
2424

25-
input:focus-visible + .checkboxLabel {
25+
input:focus-visible+.checkboxLabel {
2626
outline: 2px solid currentColor;
2727
}
2828

29-
input:checked + .checkboxLabel {
30-
opacity: 0.9;
31-
background-color: var(--site-color-checkbox-checked-bg);
29+
input:checked+.checkboxLabel {
30+
opacity: 1;
31+
background-color: var(--ifm-color-primary);
32+
color: white;
3233
border: 2px solid var(--ifm-color-primary-darkest);
34+
font-weight: 600;
35+
box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
36+
}
37+
38+
[data-theme="dark"] input:checked+.checkboxLabel {
39+
color: white;
3340
}
3441

35-
input:checked + .checkboxLabel:hover {
42+
input:checked+.checkboxLabel:hover {
3643
opacity: 0.75;
3744
box-shadow: 0 0 2px 1px var(--ifm-color-primary-dark);
3845
}
39-
input[type="checkbox"] + .checkboxLabel {
46+
47+
input[type="checkbox"]+.checkboxLabel {
4048
color: var(--ifm-color-content);
4149
}
4250

43-
[data-theme="dark"] input[type="checkbox"] + .checkboxLabel {
51+
[data-theme="dark"] input[type="checkbox"]+.checkboxLabel {
4452
color: #ffffff;
4553
border-color: #555555;
4654
}
4755

48-
[data-theme="light"] input[type="checkbox"] + .checkboxLabel {
56+
[data-theme="light"] input[type="checkbox"]+.checkboxLabel {
4957
color: #000000;
5058
border-color: var(--ifm-color-secondary-darkest);
5159
}

src/pages/showcase/index.tsx

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,25 @@ function useSiteCountPlural() {
188188
function ShowcaseFilters({ isDark = false }: { isDark?: boolean }) {
189189
const filteredUsers = useFilteredUsers();
190190
const siteCountPlural = useSiteCountPlural();
191+
const history = useHistory();
192+
const location = useLocation();
193+
194+
const clearFilters = () => {
195+
const params = new URLSearchParams(location.search);
196+
197+
params.delete("tags");
198+
params.delete("name");
199+
params.delete("operator");
200+
201+
history.push({
202+
...location,
203+
search: params.toString(),
204+
state: prepareUserState(),
205+
});
206+
};
207+
191208
return (
192-
<section className="margin-top--l margin-bottom--lg container">
209+
<section className="margin-top--l margin-bottom--lg container">
193210
<div className={clsx("margin-bottom--sm", styles.filterCheckbox)}>
194211
<div>
195212
<motion.h2
@@ -219,7 +236,16 @@ function ShowcaseFilters({ isDark = false }: { isDark?: boolean }) {
219236
<span>{siteCountPlural(filteredUsers.length)}</span>
220237
</motion.div>
221238
</div>
222-
<ShowcaseFilterToggle />
239+
<div style={{ display: "flex", gap: "10px", alignItems: "center" }}>
240+
<ShowcaseFilterToggle />
241+
242+
<button
243+
className={styles.clearFilterButton}
244+
onClick={clearFilters}
245+
>
246+
Clear Filters
247+
</button>
248+
</div>
223249
</div>
224250
<motion.ul
225251
initial={{ opacity: 0 }}

src/pages/showcase/styles.module.css

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
align-items: center;
99
}
1010

11-
.filterCheckbox > div:first-child {
11+
.filterCheckbox>div:first-child {
1212
display: flex;
1313
flex: 1 1 auto;
1414
align-items: center;
1515
}
1616

17-
.filterCheckbox > div > * {
17+
.filterCheckbox>div>* {
1818
margin-bottom: 0;
1919
margin-right: 8px;
2020
}
@@ -81,11 +81,11 @@
8181
align-items: center;
8282
}
8383

84-
.showcaseFavoriteHeader > h2 {
84+
.showcaseFavoriteHeader>h2 {
8585
margin-bottom: 0;
8686
}
8787

88-
.showcaseFavoriteHeader > svg {
88+
.showcaseFavoriteHeader>svg {
8989
width: 30px;
9090
height: 30px;
9191
}
@@ -105,15 +105,14 @@
105105
}
106106

107107
.TitleText {
108-
background: linear-gradient(
109-
90deg,
110-
rgb(152 0 255) 0%,
111-
rgb(246 41 41) 50%,
112-
rgb(255 169 8) 100%
113-
);
108+
background: linear-gradient(90deg,
109+
rgb(152 0 255) 0%,
110+
rgb(246 41 41) 50%,
111+
rgb(255 169 8) 100%);
114112
background-clip: text;
115113
-webkit-text-fill-color: transparent;
116114
}
115+
117116
[data-theme="dark"] .filterCheckbox {
118117
background-color: transparent !important;
119118
color: #ffffff !important;
@@ -135,6 +134,7 @@
135134
[data-theme="dark"] .showcaseFavorite {
136135
background-color: #1a1a1a !important;
137136
}
137+
138138
[data-theme="dark"] .filterCheckbox {
139139
background-color: transparent !important;
140140
color: #ffffff !important;
@@ -155,4 +155,31 @@
155155

156156
[data-theme="dark"] .showcaseFavorite {
157157
background-color: #1a1a1a !important;
158+
}
159+
160+
161+
.clearFilterButton {
162+
padding: 4px 10px;
163+
font-size: 12px;
164+
border-radius: 4px;
165+
border: 2px solid var(--ifm-color-primary);
166+
background: transparent;
167+
color: var(--ifm-color-primary);
168+
cursor: pointer;
169+
transition: all 0.2s ease;
170+
}
171+
172+
.clearFilterButton:hover {
173+
background: var(--ifm-color-primary);
174+
color: white;
175+
}
176+
177+
[data-theme="dark"] .clearFilterButton {
178+
color: var(--ifm-color-primary-lighter);
179+
border-color: var(--ifm-color-primary-lighter);
180+
}
181+
182+
[data-theme="dark"] .clearFilterButton:hover {
183+
background: var(--ifm-color-primary);
184+
color: #fff;
158185
}

0 commit comments

Comments
 (0)