Skip to content

Commit e445f6c

Browse files
Filip Łukasikpikinier20
authored andcommitted
handle header layout
1 parent e77c75d commit e445f6c

File tree

3 files changed

+45
-9
lines changed

3 files changed

+45
-9
lines changed

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

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class DropdownHandler:
2525
val ver = JSON.parse(json).asInstanceOf[Versions]
2626
val ddc = document.getElementById("version-dropdown")
2727
for (k, v) <- ver.versions do
28-
val child = span(cls := "text-button", href := v)(k)
28+
val child = a(cls := "text-button", href := v)(k)
2929
ddc.appendChild(child)
3030
val arrow = span(cls := "ar")()
3131
document.getElementById("dropdown-button").appendChild(arrow)
@@ -59,7 +59,7 @@ class DropdownHandler:
5959
addVersionsList(json)
6060

6161
document.addEventListener("click", (e: Event) => {
62-
document.getElementById("dropdown-content").classList.remove("show")
62+
document.getElementById("version-dropdown").classList.remove("show")
6363
document.getElementById("dropdown-button").classList.remove("expanded")
6464
})
6565

@@ -68,7 +68,24 @@ end DropdownHandler
6868

6969
@JSExportTopLevel("dropdownHandler")
7070
def dropdownHandler() =
71-
// if document.getElementById("dropdown-content").getElementsByTagName("a").size > 0 &&
72-
// window.getSelection.toString.length == 0 then
73-
document.getElementById("version-dropdown").classList.toggle("expanded")
74-
// document.getElementById("dropdown-button").classList.toggle("expanded")
71+
if document.getElementById("version-dropdown").getElementsByTagName("a").size > 0 &&
72+
window.getSelection.toString.length == 0 then
73+
document.getElementById("version-dropdown").classList.toggle("show")
74+
document.getElementById("dropdown-button").classList.toggle("expanded")
75+
document.getElementById("dropdown-input").asInstanceOf[html.Input].focus()
76+
77+
@JSExportTopLevel("filterFunction")
78+
def filterFunction() =
79+
val input = document.getElementById("dropdown-input").asInstanceOf[html.Input]
80+
val filter = input.value.toUpperCase
81+
val div = document.getElementById("version-dropdown")
82+
val as = div.getElementsByTagName("a")
83+
84+
as.foreach { a =>
85+
val txtValue = a.innerText
86+
val cl = a.asInstanceOf[html.Anchor].classList
87+
if txtValue.toUpperCase.indexOf(filter) > -1 then
88+
cl.remove("filtered")
89+
else
90+
cl.add("filtered")
91+
}

scaladoc/resources/dotty_res/styles/theme/components/button/icon-button.css

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
}
1818

1919
/* theme-toggle button */
20-
#theme-toggle {
21-
margin-right: calc(2 * var(--base-spacing));
22-
}
2320

2421
#theme-toggle.icon-button::after {
2522
content: url("../../../../images/icon-buttons/moon/light/default.svg");

scaladoc/resources/dotty_res/styles/theme/layout/header.css

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,25 @@
1414
background: var(--background-default);
1515
border-bottom: 1px solid var(--border-default);
1616
}
17+
18+
.header-container-left {
19+
display: flex;
20+
align-items: center;
21+
}
22+
23+
.header-container-left span {
24+
margin-right: calc(2 * var(--base-spacing));
25+
}
26+
27+
.header-container-right {
28+
display: flex;
29+
align-items: center;
30+
}
31+
32+
.header-container-right .text-button {
33+
margin-left: calc(3 * var(--base-spacing));
34+
}
35+
36+
.header-container-right #theme-toggle {
37+
margin-left: calc(3 * var(--base-spacing));
38+
}

0 commit comments

Comments
 (0)