Skip to content

Commit b952ed4

Browse files
authored
Merge pull request #12595 from lampepfl/scaladoc/searchbar-improvement
Scaladoc: Icons for searchbar results
2 parents cbb1e07 + 96736f5 commit b952ed4

File tree

16 files changed

+471
-762
lines changed

16 files changed

+471
-762
lines changed

scaladoc-js/resources/scaladoc-searchbar.css

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,15 @@
7373

7474
.scaladoc-searchbar-result {
7575
background: white;
76-
line-height: 32px;
77-
padding-left: 10px;
78-
padding-right: 10px;
76+
line-height: 24px;
77+
display: flex;
78+
padding: 4px 10px 4px 10px;
79+
}
80+
81+
.scaladoc-searchbar-result .micon {
82+
height: 16px;
83+
width: 16px;
84+
margin: 4px 8px 0px 0px;
7985
}
8086

8187
.scaladoc-searchbar-result:first-of-type {
@@ -88,6 +94,8 @@
8894

8995
.scaladoc-searchbar-result a {
9096
color: #1f2326;
97+
text-indent: -20px;
98+
padding-left: 20px;
9199
}
92100

93101
.scaladoc-searchbar-result .scaladoc-searchbar-location {

scaladoc-js/src/searchbar/PageEntry.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ trait PageEntryJS extends js.Object {
88
val t: String = js.native
99
val d: String = js.native
1010
val l: String = js.native
11+
val k: String = js.native
1112
}
1213

1314
case class PageEntry(
1415
fullName: String,
1516
description: String,
1617
location: String,
1718
shortName: String,
19+
kind: String,
1820
tokens: List[String]
1921
)
2022

@@ -24,6 +26,7 @@ object PageEntry {
2426
jsObj.d,
2527
jsObj.l,
2628
jsObj.n.toLowerCase,
29+
jsObj.k,
2730
StringUtils.createCamelCaseTokens(jsObj.n)
2831
)
2932
}

scaladoc-js/src/searchbar/SearchbarComponent.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ class SearchbarComponent(val callback: (String) => List[PageEntry]):
1111
wrapper.classList.add("scaladoc-searchbar-result")
1212
wrapper.classList.add("monospace")
1313

14+
val icon = document.createElement("span").asInstanceOf[html.Span]
15+
icon.classList.add("micon")
16+
icon.classList.add(p.kind.take(2))
17+
1418
val resultA = document.createElement("a").asInstanceOf[html.Anchor]
1519
resultA.href = Globals.pathToRoot + p.location
1620
resultA.text = s"${p.fullName}"
@@ -20,6 +24,7 @@ class SearchbarComponent(val callback: (String) => List[PageEntry]):
2024
location.classList.add("scaladoc-searchbar-location")
2125
location.textContent = p.description
2226

27+
wrapper.appendChild(icon)
2328
wrapper.appendChild(resultA)
2429
wrapper.appendChild(location)
2530
wrapper.addEventListener("mouseover", {

scaladoc-js/test/dotty/dokka/MatchersTest.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class MatchersTest:
3535
"",
3636
"",
3737
s"$name",
38+
kind,
3839
StringUtils.createCamelCaseTokens(name)
3940
)
4041

Lines changed: 46 additions & 240 deletions
Loading

0 commit comments

Comments
 (0)