Skip to content

Commit 3b9dbbb

Browse files
committed
Fix CSS to repair overflow of sidebar items
1 parent ca280fb commit 3b9dbbb

File tree

4 files changed

+42
-14
lines changed

4 files changed

+42
-14
lines changed

scaladoc-js/src/Main.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ object Main extends App {
55
SocialLinks()
66
CodeSnippets()
77
DropdownHandler()
8+
Ux()
89
}

scaladoc-js/src/ux/Ux.scala

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package dotty.tools.scaladoc
2+
3+
import org.scalajs.dom._
4+
import org.scalajs.dom.ext._
5+
6+
import scala.util.matching.Regex._
7+
import scala.util.matching._
8+
9+
class Ux():
10+
def sideMenuItemsWordBreaking(): Unit =
11+
val matchingRegex = raw"([.A-Z])".r
12+
13+
def modifySpan = (span: html.Span) => {
14+
val textNodes = span.childNodes.filter(_.nodeType == 3)
15+
val texts = textNodes.map(_.nodeValue).mkString
16+
span.innerHTML = matchingRegex.replaceAllIn(texts, m => s"<wbr>${m.group(0)}")
17+
}
18+
19+
val nodes = document.querySelectorAll("#sideMenu2 a span").collect {
20+
case e: html.Span => e
21+
}.foreach(modifySpan)
22+
23+
sideMenuItemsWordBreaking()

scaladoc/resources/dotty_res/styles/scalastyle.css

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,10 @@ th {
265265
#sideMenu2 {
266266
overflow: auto;
267267
overflow-x: hidden;
268-
overflow-y: scroll;
269268
scrollbar-width: thin;
270269
height: 100%;
271270
font-size: var(--leftbar-font-size);
271+
margin-top: 5%;
272272
}
273273

274274
/* divs in sidebar represent entry and its children */
@@ -307,19 +307,25 @@ th {
307307
display: flex;
308308
align-items: center;
309309
flex: 1;
310-
overflow-x: hidden;
311310
overflow-wrap: anywhere;
312311
color: var(--leftbar-fg);
313312
margin-right: .5rem;
314-
padding-top: 3px;
315-
padding-bottom: 3px;
316-
margin-top: 1px;
317-
margin-bottom: 1px;
318-
width: 100%;
319-
/* This trick adds selected background stretching to the left side of screen */
320-
margin-left: calc(0px - var(--side-width));
321-
padding-left: var(--side-width);
322-
width: calc(2 * var(--side-width));
313+
padding-top: 2%;
314+
padding-bottom: 2%;
315+
width: calc(var(--side-width));
316+
padding-left: calc(0.05 * var(--side-width));
317+
padding-right: calc(0.3 * var(--side-width));
318+
box-sizing: border-box;
319+
}
320+
321+
#sideMenu2 a span:not(.micon) {
322+
margin-right: 0.75ex;
323+
text-indent: -1.5em;
324+
padding-left: 1.5em;
325+
}
326+
327+
#sideMenu2 a.selected span:not(.micon) {
328+
margin-right: 0.5ex;
323329
}
324330

325331
#sideMenu2 a.selected {
@@ -340,14 +346,12 @@ span.ar {
340346
position: absolute;
341347
right: 1em;
342348
top: 0px;
343-
padding: 4px;
344349
}
345350

346351
span.ar::before {
347352
content: "\e903"; /* arrow down */
348353
font-family: "dotty-icons" !important;
349354
font-size: 20px;
350-
line-height: var(--leftbar-font-size);
351355
color: var(--leftbar-fg);
352356
display: flex;
353357
flex-direction: row;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ class HtmlRenderer(rootPackage: Member, val members: Map[DRI, Member])(using ctx
166166
case m: Member => navigationIcon(m)
167167
case _ => Nil
168168
}
169-
Seq(a(href := pathToPage(pageLink.dri, nav.link.dri), attrs)(icon, nav.link.name))
169+
Seq(a(href := pathToPage(pageLink.dri, nav.link.dri), attrs)(icon, span(nav.link.name)))
170170

171171
nav.children match
172172
case Nil => isSelected -> div(linkHtml())

0 commit comments

Comments
 (0)