Skip to content

Commit d165021

Browse files
committed
Apply requested changes
1 parent 35aefbe commit d165021

File tree

4 files changed

+33
-31
lines changed

4 files changed

+33
-31
lines changed

scaladoc-js/src/versions-dropdown/DropdownHandler.scala

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ class DropdownHandler:
2727
child.href = v
2828
child.text = k
2929
ddc.appendChild(child)
30+
val arrow = document.createElement("span").asInstanceOf[html.Span]
31+
arrow.classList.add("ar")
32+
document.getElementById("dropdown-button").appendChild(arrow)
3033

3134
private def disableButton() =
3235
val btn = document.getElementById("dropdown-button").asInstanceOf[html.Button]
@@ -56,11 +59,11 @@ class DropdownHandler:
5659
case json =>
5760
addVersionsList(json)
5861

59-
60-
document.onclick = (e: Event) => {
62+
document.addEventListener("click", (e: Event) => {
6163
if e.target.asInstanceOf[html.Element].id != "dropdown-button" then
6264
document.getElementById("dropdown-content").classList.remove("show")
63-
}
65+
document.getElementById("dropdown-button").classList.remove("expanded")
66+
})
6467

6568
document.getElementById("version").asInstanceOf[html.Span].onclick = (e: Event) => {
6669
e.stopPropagation
@@ -72,17 +75,20 @@ def dropdownHandler() =
7275
if document.getElementById("dropdown-content").getElementsByTagName("a").size > 0 &&
7376
window.getSelection.toString.length == 0 then
7477
document.getElementById("dropdown-content").classList.toggle("show")
78+
document.getElementById("dropdown-button").classList.toggle("expanded")
7579

7680
@JSExportTopLevel("filterFunction")
7781
def filterFunction() =
7882
val input = document.getElementById("dropdown-input").asInstanceOf[html.Input]
7983
val filter = input.value.toUpperCase
8084
val div = document.getElementById("dropdown-content")
81-
val a = div.getElementsByTagName("a")
82-
for i <- 0 until a.length do
83-
val txtValue = a(i).innerText
84-
val disp = if txtValue.toUpperCase.indexOf(filter) > -1 then
85-
""
85+
val as = div.getElementsByTagName("a")
86+
87+
as.foreach { a =>
88+
val txtValue = a.innerText
89+
val cl = a.asInstanceOf[html.Anchor].classList
90+
if txtValue.toUpperCase.indexOf(filter) > -1 then
91+
cl.remove("filtered")
8692
else
87-
"none"
88-
a(i).asInstanceOf[html.Anchor].style.display = disp
93+
cl.add("filtered")
94+
}

scaladoc/resources/dotty_res/styles/scalastyle.css

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ th {
147147
#logo .projectVersion {
148148
color: var(--leftbar-fg);
149149
font-size: 12px;
150+
display: flex;
151+
padding-left: calc(0.05 * var(--side-width));
152+
padding-right: calc(0.08 * var(--side-width));
150153
}
151154

152155
.scaladoc_logo {
@@ -225,7 +228,7 @@ th {
225228
}
226229

227230
/* spans represent a expand button */
228-
#sideMenu2 span.ar {
231+
span.ar {
229232
align-items: center;
230233
cursor: pointer;
231234
position: absolute;
@@ -234,7 +237,7 @@ th {
234237
padding: 4px;
235238
}
236239

237-
#sideMenu2 span.ar::before {
240+
span.ar::before {
238241
content: "\e903"; /* arrow down */
239242
font-family: "dotty-icons" !important;
240243
font-size: 20px;
@@ -245,11 +248,11 @@ th {
245248
align-items: center;
246249
justify-content: center;
247250
}
248-
#sideMenu2 .expanded>span.ar::before {
251+
.expanded>span.ar::before {
249252
content: "\e905"; /* arrow up */
250253
}
251254

252-
#sideMenu2 .div:hover>span.ar::before {
255+
.div:hover>span.ar::before {
253256
color: var(--leftbar-current-bg);
254257
}
255258

@@ -788,7 +791,6 @@ footer {
788791
/* The container <div> - needed to position the dropdown content */
789792
.versions-dropdown {
790793
position: relative;
791-
display: inline-block;
792794
}
793795

794796
/* Dropdown Button */
@@ -842,17 +844,12 @@ footer {
842844
/* Change color of dropdown links on hover */
843845
.dropdown-content a:hover {background-color: #f1f1f1}
844846

845-
.arrow-down {
846-
content: "\e903"; /* arrow down */
847-
font-family: "dotty-icons" !important;
848-
font-size: 20px;
849-
line-height: var(--leftbar-font-size);
850-
color: var(--leftbar-fg);
851-
display: flex;
852-
flex-direction: row;
853-
align-items: center;
854-
justify-content: center;
847+
/* Show the dropdown menu (use JS to add this class to the .dropdown-content container when the user clicks on the dropdown button) */
848+
.show {
849+
display:block;
855850
}
856851

857-
/* Show the dropdown menu (use JS to add this class to the .dropdown-content container when the user clicks on the dropdown button) */
858-
.show {display:block;}
852+
/* Filtered entries in dropdown menu */
853+
.dropdown-content a.filtered {
854+
display: none;
855+
}

scaladoc/src/dotty/tools/scaladoc/SourceLinks.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ object SourceLinks:
125125
| €{FILE_PATH}, and €{FILE_LINE} patterns
126126
|
127127
|
128-
|Template can defined only by subset of sources defined by path prefix represented by `<sub-path>`.
128+
|Template can be defined only by subset of sources defined by path prefix represented by `<sub-path>`.
129129
|In such case paths used in templates will be relativized against `<sub-path>`""".stripMargin
130130

131131
def load(config: Seq[String], revision: Option[String], projectRoot: Path = Paths.get("").toAbsolutePath)(using CompilerContext): SourceLinks =

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,10 @@ class HtmlRenderer(rootPackage: Member, val members: Map[DRI, Member])(using ctx
223223
span(
224224
div(cls:="projectName")(args.name)
225225
),
226-
span(id := "version")(
226+
div(id := "version")(
227227
div(cls := "versions-dropdown")(
228228
div(onclick := "dropdownHandler()", id := "dropdown-button", cls := "dropdownbtn dropdownbtnactive")(
229-
args.projectVersion.map(v => div(cls:="projectVersion")(v)).getOrElse(""),
230-
div(cls := "arrow-down")
229+
args.projectVersion.map(v => div(cls:="projectVersion")(v)).getOrElse("")
231230
),
232231
div(id := "dropdown-content", cls := "dropdown-content")(
233232
input(`type` := "text", placeholder := "Search...", id := "dropdown-input", onkeyup := "filterFunction()"),

0 commit comments

Comments
 (0)