Skip to content

Commit 8354c08

Browse files
committed
add filter input
1 parent a6d97bc commit 8354c08

File tree

5 files changed

+72
-6
lines changed

5 files changed

+72
-6
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ class FilterBar extends Component {
4242
}));
4343
};
4444

45+
onClearFilters = () => {
46+
this.setState(() => ({
47+
filter: ""
48+
}))
49+
}
50+
4551
onFilterVisibilityChange = () => {
4652
this.setState((prevState) => ({ isVisible: !prevState.isVisible }));
4753
};

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,16 @@ class FilterGroup extends Component {
121121
.map(
122122
([key, data]) =>
123123
`<li
124-
class="filterButtonItem"
124+
class="filterButtonItem ${this.isVisible(
125+
data.visible
126+
)}"
125127
data-selected="${data.selected}"
126128
data-test-id="filterGroupButton"
127129
data-key="${filterKey}"
128130
data-selected="${data.selected}"
129131
data-value="${key}"
130132
${this.isActive(
131133
data.selected
132-
)} ${this.isVisible(
133-
data.visible
134134
)}"
135135
>
136136
${key}
@@ -147,7 +147,7 @@ class FilterGroup extends Component {
147147
this.filtersContainerRef,
148148
Object.entries(filter.filters)
149149
.filter(([_key, values]) => Object.values(values).some((v) => v.visible))
150-
.map(([key, values]) => this.getFilterGroup(key, values))
150+
.map(([key, values]) => this.getFilterGroup(key, values)),
151151
);
152152

153153
this.attachFiltersClicks();

scaladoc/resources/dotty_res/styles/theme/components/api-filters.css

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,54 @@
22
display: flex;
33
position: fixed;
44
top: calc(10 * var(--base-spacing));
5+
flex-wrap: wrap;
6+
z-index: 2;
57
}
68

79
.filtersContainer {
810
display: flex;
11+
flex-wrap: wrap;
12+
}
13+
14+
.filterableInput {
15+
background-color: var(--background-default);
16+
color: var(--action-primary-content-active);
17+
background-image: url("../../../images/icon-buttons/search/dark/default.svg");
18+
background-repeat: no-repeat;
19+
padding: calc(2 * var(--base-spacing)) calc(2 * var(--base-spacing))
20+
calc(2 * var(--base-spacing)) calc(5 * var(--base-spacing));
21+
border-radius: 4px;
22+
background-size: 16px;
23+
background-position: 10px 15px;
24+
border: none;
25+
}
26+
27+
.filterableInput:focus-visible {
28+
border: none;
29+
outline: none;
30+
}
31+
32+
.filterableInput::-webkit-search-cancel-button {
33+
-webkit-appearance: none;
34+
height: 1em;
35+
width: 1em;
36+
background: url("../../../images/icon-buttons/close/light/default.svg")
37+
no-repeat 50% 50%;
38+
background-size: contain;
39+
opacity: 0;
40+
pointer-events: none;
41+
}
42+
43+
.theme-dark .filterableInput::-webkit-search-cancel-button {
44+
background: url("../../../images/icon-buttons/close/dark/default.svg")
45+
no-repeat 50% 50%;
46+
}
47+
48+
.filterableInput:focus::-webkit-search-cancel-button {
49+
opacity: 1;
50+
pointer-events: all;
51+
}
52+
53+
.filterableInput.dark::-webkit-search-cancel-button {
54+
filter: invert(1);
955
}

scaladoc/resources/dotty_res/styles/theme/components/pill.css

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,14 @@
4040
}
4141

4242
.pill > .close {
43+
display: none;
4344
margin-left: calc(1.5 * var(--base-spacing));
4445
}
4546

47+
.pill.has-value > .close {
48+
display: block;
49+
}
50+
4651
.pill-container ul {
4752
display: none;
4853
background-color: var(--action-primary-background-default-solid);
@@ -58,11 +63,19 @@
5863
.pill-container ul li {
5964
padding: calc(1 * var(--base-spacing)) calc(4 * var(--base-spacing));
6065
cursor: pointer;
66+
display: none;
67+
}
68+
69+
.pill-container ul li.visible {
6170
display: flex;
6271
}
6372

6473
.pill-container ul li:hover {
65-
background-color: var(--action-primary-background-selected);
74+
background-color: var(--action-primary-background-hover);
75+
}
76+
77+
.pill-container ul li[data-selected="true"]:hover {
78+
background-color: var(--action-primary-background-hover);
6679
}
6780

6881
.pill-container ul li[data-selected="true"] {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,8 @@ class MemberRenderer(signatureRenderer: SignatureRenderer)(using DocContext) ext
387387

388388
private def buildDocumentableFilter = div(cls := "documentableFilter")(
389389
div(cls := "filtersContainer")(),
390-
input(cls := "filterableInput", placeholder := "Filter by any phrase", testId := "filterBarInput"),
390+
input(cls := "filterableInput", placeholder := "Filter by any phrase", testId := "filterBarInput", `type` := "search"),
391+
button(cls := "clearButton", testId := "filterBarClearButton")("Clear all"),
391392
)
392393

393394
def fullMember(m: Member): PageContent =

0 commit comments

Comments
 (0)