Skip to content

Commit e77c75d

Browse files
Filip Łukasikpikinier20
authored andcommitted
prepare base header structure
1 parent 28de89f commit e77c75d

File tree

5 files changed

+52
-74
lines changed

5 files changed

+52
-74
lines changed

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

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ class DropdownHandler:
2323

2424
private def addVersionsList(json: String) =
2525
val ver = JSON.parse(json).asInstanceOf[Versions]
26-
val ddc = document.getElementById("dropdown-content")
26+
val ddc = document.getElementById("version-dropdown")
2727
for (k, v) <- ver.versions do
28-
var child = a(href := v)(k)
28+
val child = span(cls := "text-button", href := v)(k)
2929
ddc.appendChild(child)
3030
val arrow = span(cls := "ar")()
3131
document.getElementById("dropdown-button").appendChild(arrow)
@@ -68,24 +68,7 @@ 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("dropdown-content").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("dropdown-content")
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-
}
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")

scaladoc/resources/dotty_res/scripts/ux.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ window.addEventListener("DOMContentLoaded", () => {
1717
}
1818
}
1919

20-
$(".icon-button.hamburger").on('click', function () {
21-
$("#hamburger-dropdown").toggleClass("expanded")
22-
$(this).toggleClass("selected")
23-
});
24-
2520
$(".side-menu span").on('click', function () {
2621
$(this).parent().toggleClass("expanded")
2722
});

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.text-button a {
22
color: var(--action-primary-content-default);
33
text-decoration: none;
4+
cursor: pointer;
45
}
56

67
.text-button:hover a {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
display: none;
1010
position: absolute;
1111
padding: calc(3 * var(--base-spacing));
12-
top: calc(6 * var(--base-spacing));
13-
right: calc(2 * var(--base-spacing));
12+
z-index: 2;
1413
}
1514

1615
.dropdown-menu > *:not(:last-child) {

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

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -207,47 +207,57 @@ 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")(
211+
a()(
212+
args.projectVersion.map(v => div(cls:="projectVersion")(v)).getOrElse("")
213+
),
214+
div(id := "version-dropdown", cls := "dropdown-menu") (
215+
span(cls := "text-button")(
216+
a() (
217+
"Download",
218+
)
219+
),
220+
)
221+
),
210222
),
211223

212224
div(cls:="header-container-center")(
213225
input(`type` := "text", placeholder := "Search...", id := "dropdown-input", onkeyup := "filterFunction()"),
214226
),
215227

216228
div(cls:="header-container-right")(
229+
span(cls := "text-button")(
230+
a(href := "https://www.scala-lang.org/download/") (
231+
"Download",
232+
)
233+
),
234+
span(cls := "text-button")(
235+
a(href := "https://docs.scala-lang.org/") (
236+
"Documentation",
237+
)
238+
),
239+
span(cls := "text-button")(
240+
a(href := "https://index.scala-lang.org") (
241+
"Libraries",
242+
)
243+
),
244+
span(cls := "text-button")(
245+
a(href := "https://www.scala-lang.org/contribute/") (
246+
"Contribute",
247+
)
248+
),
249+
span(cls := "text-button")(
250+
a(href := "https://www.scala-lang.org/contribute/") (
251+
"Blog",
252+
)
253+
),
254+
span(cls := "text-button")(
255+
a(href := "https://www.scala-lang.org/blog/") (
256+
"Community",
257+
)
258+
),
217259
button(id := "theme-toggle", cls := "icon-button"),
218-
button(cls := "icon-button hamburger"),
219-
div(id := "hamburger-dropdown", cls := "dropdown-menu body-small")(
220-
span(cls := "text-button")(
221-
a(href := "https://www.scala-lang.org/download/") (
222-
"Download",
223-
)
224-
),
225-
span(cls := "text-button")(
226-
a(href := "https://docs.scala-lang.org/") (
227-
"Documentation",
228-
)
229-
),
230-
span(cls := "text-button")(
231-
a(href := "https://index.scala-lang.org") (
232-
"Libraries",
233-
)
234-
),
235-
span(cls := "text-button")(
236-
a(href := "https://www.scala-lang.org/contribute/") (
237-
"Contribute",
238-
)
239-
),
240-
span(cls := "text-button")(
241-
a(href := "https://www.scala-lang.org/contribute/") (
242-
"Blog",
243-
)
244-
),
245-
span(cls := "text-button")(
246-
a(href := "https://www.scala-lang.org/blog/") (
247-
"Community",
248-
)
249-
),
250-
)
260+
251261
),
252262

253263

@@ -285,16 +295,6 @@ class HtmlRenderer(rootPackage: Member, members: Map[DRI, Member])(using ctx: Do
285295
// span(
286296
// div(cls:="projectName")(args.name)
287297
// ),
288-
// div(id := "version")(
289-
// div(cls := "versions-dropdown")(
290-
// div(onclick := "dropdownHandler()", id := "dropdown-button", cls := "dropdownbtn dropdownbtnactive")(
291-
// args.projectVersion.map(v => div(cls:="projectVersion")(v)).getOrElse(""),
292-
// div(id := "dropdown-content", cls := "dropdown-content")(
293-
// input(`type` := "text", placeholder := "Search...", id := "dropdown-input", onkeyup := "filterFunction()"),
294-
// ),
295-
// ),
296-
// )
297-
// ),
298298
// div(cls := "socials")(
299299
// socialLinks()
300300
// )
@@ -324,7 +324,7 @@ class HtmlRenderer(rootPackage: Member, members: Map[DRI, Member])(using ctx: Do
324324
div (id := "leftToggler")(
325325
span(cls := "icon-toggler")
326326
),
327-
div(id := "scaladoc-searchBar"),
327+
// div(id := "scaladoc-searchBar"),
328328
// main(id := "main-content")(
329329
// parentsHtml,
330330
// div(id := "content")(content),

0 commit comments

Comments
 (0)