Skip to content

Commit f02a4d6

Browse files
Filip Łukasikpikinier20
authored andcommitted
handle dropdownHandler function properly
1 parent d651c16 commit f02a4d6

File tree

6 files changed

+35
-21
lines changed

6 files changed

+35
-21
lines changed

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,9 @@ class DropdownHandler:
2727
for (k, v) <- ver.versions do
2828
val child = a(cls := "text-button", href := v)(k)
2929
ddc.appendChild(child)
30-
val arrow = span(cls := "ar")()
31-
document.getElementById("dropdown-button").appendChild(arrow)
3230

3331
private def disableButton() =
34-
val btn = document.getElementById("dropdown-button").asInstanceOf[html.Button]
32+
val btn = document.getElementById("version-dropdown").asInstanceOf[html.Button]
3533
btn.disabled = true
3634
btn.classList.remove("dropdownbtnactive")
3735

@@ -59,21 +57,18 @@ class DropdownHandler:
5957
addVersionsList(json)
6058

6159
document.addEventListener("click", (e: Event) => {
62-
document.getElementById("version-dropdown").classList.remove("show")
63-
document.getElementById("dropdown-button").classList.remove("expanded")
60+
document.getElementById("version-dropdown").classList.remove("expanded")
6461
})
6562

66-
document.getElementById("version").asInstanceOf[html.Span].addEventListener("click", (e: Event) => e.stopPropagation())
63+
document.getElementById("version-dropdown").asInstanceOf[html.Span].addEventListener("click", (e: Event) => e.stopPropagation())
6764
end DropdownHandler
6865

6966
@JSExportTopLevel("dropdownHandler")
70-
def dropdownHandler() =
71-
console.log("ddc", document.getElementById("version-dropdown"))
67+
def dropdownHandler(e: Event) =
68+
e.stopPropagation()
7269
if document.getElementById("version-dropdown").getElementsByTagName("a").size > 0 &&
7370
window.getSelection.toString.length == 0 then
74-
document.getElementById("version-dropdown").classList.toggle("show")
75-
document.getElementById("dropdown-button").classList.toggle("expanded")
76-
document.getElementById("dropdown-input").asInstanceOf[html.Input].focus()
71+
document.getElementById("version-dropdown").classList.toggle("expanded")
7772

7873
@JSExportTopLevel("filterFunction")
7974
def filterFunction() =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
height: calc(2 * var(--base-spacing));
1212
}
1313

14-
.icon-button:focus {
14+
.icon-button:focus-visible {
1515
box-shadow: 0px 0px 0px 2px var(--focus-default);
1616
border-radius: 4px;
1717
}

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
.text-button {
2+
display: flex;
3+
}
4+
15
.text-button a {
26
color: var(--action-primary-content-default);
37
text-decoration: none;
@@ -16,10 +20,23 @@
1620
color: var(--action-primary-content-selected);
1721
}
1822

19-
.text-button:focus a {
23+
.text-button:focus-visible a {
2024
box-shadow: 0px 0px 0px 2px var(--focus-default);
2125
}
2226

2327
.text-button:disabled a {
2428
opacity: 0.5;
2529
}
30+
31+
.text-button::after {
32+
margin-left: calc(1 * var(--base-spacing));
33+
}
34+
35+
/* button with arrow */
36+
.text-button.with-arrow::after {
37+
content: url("../../../../images/icon-buttons/hamburger/dark/default.svg");
38+
display: flex;
39+
flex-direction: row;
40+
align-items: center;
41+
justify-content: center;
42+
}

scaladoc/resources/dotty_res/styles/theme/components/dropdown-menu.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
position: absolute;
1111
padding: calc(3 * var(--base-spacing));
1212
z-index: 2;
13+
top: calc(6 * var(--base-spacing));
1314
}
1415

15-
.dropdown-menu > *:not(:last-child) {
16+
/* .dropdown-menu > *:not(:last-child) {
1617
margin-bottom: calc(2 * var(--base-spacing));
17-
}
18+
} */
1819

1920
.dropdown-menu.expanded {
2021
display: flex;

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ body {
77
#container {
88
--header-height: calc(8 * var(--base-spacing));
99
}
10+
11+
::-webkit-scrollbar {
12+
width: 0;
13+
background: transparent;
14+
}

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,16 +207,12 @@ class HtmlRenderer(rootPackage: Member, members: Map[DRI, Member])(using ctx: Do
207207
div(id := "header")(
208208
div(cls := "header-container-left")(
209209
projectLogo,
210-
span(onclick := "dropdownHandler()", cls := "text-button")(
210+
span(onclick := "dropdownHandler(event)", cls := "text-button with-arrow")(
211211
a()(
212212
args.projectVersion.map(v => div(cls:="projectVersion")(v)).getOrElse("")
213213
),
214214
div(id := "version-dropdown", cls := "dropdown-menu") (
215-
span(cls := "text-button")(
216-
a() (
217-
"Download",
218-
)
219-
),
215+
span(cls := "text-button")()
220216
)
221217
),
222218
),

0 commit comments

Comments
 (0)