Skip to content

Commit 55e355f

Browse files
committed
add clear all filters button
1 parent 8354c08 commit 55e355f

File tree

4 files changed

+48
-1
lines changed

4 files changed

+48
-1
lines changed

scaladoc/resources/dotty_res/scripts/components/FilterGroup.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ class FilterGroup extends Component {
44

55
this.filterToggleRef = findRef(".filterToggleButton");
66
this.filtersContainerRef = findRef(".filtersContainer");
7+
this.documentableFilterRef = findRef(".documentableFilter");
78

89
withEvent(
910
this.filterToggleRef,
@@ -36,6 +37,11 @@ class FilterGroup extends Component {
3637
e.preventDefault();
3738
};
3839

40+
onClearFilters = () => {
41+
Object.entries(this.props.filter.filters)
42+
.forEach(([key, _values]) => this.props.onGroupSelectChange(key, false))
43+
};
44+
3945
attachFiltersClicks() {
4046
const refs = findRefs(
4147
"li.filterButtonItem",
@@ -49,13 +55,20 @@ class FilterGroup extends Component {
4955
"button.selectAll",
5056
this.filtersContainerRef
5157
);
58+
5259
const deselectAllRefs = findRefs(
5360
"span.deselectAll",
5461
this.filtersContainerRef
5562
);
5663

64+
const deselectAllRefsWithClearButton = findRefs(
65+
"button.clearButton",
66+
this.documentableFilterRef
67+
);
68+
5769
attachListeners(selectAllRefs, "click", this.onSelectAllClick);
5870
attachListeners(deselectAllRefs, "click", this.onDeselectAllClick);
71+
attachListeners(deselectAllRefsWithClearButton, "click", this.onClearFilters);
5972
}
6073

6174
isActive(isActive) {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.label-only-button {
2+
background-color: var(--action-primary-background-default-ghost);
3+
color: var(--action-primary-content-default);
4+
border: 1px solid var(--border-default);
5+
padding: calc(1.25 * var(--base-spacing)) calc(1.5 * var(--base-spacing));
6+
border-radius: 4px;
7+
}
8+
9+
.label-only-button:hover {
10+
background-color: var(--action-primary-background-hover);
11+
color: var(--action-primary-content-hover);
12+
}
13+
14+
.label-only-button:active {
15+
background-color: var(--action-primary-background-hover);
16+
color: var(--action-primary-content-hover);
17+
}
18+
19+
.label-only-button.selected {
20+
background-color: var(--action-primary-background-hover);
21+
color: var(--action-primary-content-selected);
22+
}
23+
24+
.label-only-button:focus-visible {
25+
border: none;
26+
outline: none;
27+
box-shadow: 0px 0px 0px 2px var(--focus-default);
28+
}
29+
30+
.label-only-button:disabled {
31+
opacity: 0.5;
32+
pointer-events: none;
33+
}

scaladoc/src/dotty/tools/scaladoc/renderers/MemberRenderer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ class MemberRenderer(signatureRenderer: SignatureRenderer)(using DocContext) ext
388388
private def buildDocumentableFilter = div(cls := "documentableFilter")(
389389
div(cls := "filtersContainer")(),
390390
input(cls := "filterableInput", placeholder := "Filter by any phrase", testId := "filterBarInput", `type` := "search"),
391-
button(cls := "clearButton", testId := "filterBarClearButton")("Clear all"),
391+
button(cls := "clearButton label-only-button", testId := "filterBarClearButton")("Clear all"),
392392
)
393393

394394
def fullMember(m: Member): PageContent =

scaladoc/src/dotty/tools/scaladoc/renderers/Resources.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ trait Resources(using ctx: DocContext) extends Locations, Writer:
118118
"styles/theme/components/navigation-item.css",
119119
"styles/theme/components/button/icon-button.css",
120120
"styles/theme/components/button/text-button.css",
121+
"styles/theme/components/button/label-only-button.css",
121122
"styles/theme/components/dropdown-menu.css",
122123
"styles/theme/components/divider.css",
123124
"styles/theme/components/table-of-content.css",

0 commit comments

Comments
 (0)