Skip to content

Commit b5def4d

Browse files
authored
Merge pull request #12461 from lampepfl/scaladoc/site-css-fix
Scaladoc: CSS fixes
2 parents a8bbc0e + 9a20975 commit b5def4d

File tree

6 files changed

+84
-36
lines changed

6 files changed

+84
-36
lines changed

docs/css/dottydoc.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,20 @@ aside.success {
248248
}
249249
}
250250

251+
.gitter-open-chat-button {
252+
writing-mode: vertical-lr;
253+
text-orientation: upright;
254+
right: 0px;
255+
bottom: 100px;
256+
padding: 0.5em 0.25em 0.5em 0.25em;
257+
border-bottom-left-radius: .5em;
258+
border-top-right-radius: 0em;
259+
}
260+
261+
.gitter-open-chat-button.is-collapsed {
262+
transform: translateX(120%);
263+
}
264+
251265
header {
252266
position: static !important;
253267
width: 100% !important;

scaladoc-js/resources/scaladoc-searchbar.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
box-shadow: none;
2323
margin-top: 2px;
2424
}
25+
2526
.search span:hover {
2627
fill: var(--link-hover-fg);
2728
}
@@ -43,9 +44,9 @@
4344
#scaladoc-searchbar {
4445
position: fixed;
4546
top: 50px;
46-
right: 40px;
47+
left: calc(5% + var(--side-width));
4748
z-index: 5;
48-
width: calc(100% - 360px);
49+
width: calc(90% - var(--side-width));
4950
box-shadow: 0 2px 16px 0 rgba(0, 42, 76, 0.15);
5051
font-size: 13px;
5152
font-family: system-ui, -apple-system, Segoe UI, Roboto, Noto Sans, Ubuntu, Cantarell, Helvetica Neue, Arial, sans-serif;

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: 38 additions & 29 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;
@@ -543,6 +547,8 @@ footer {
543547
background: var(--footer-bg);
544548
color: var(--footer-fg);
545549
display: flex;
550+
flex-wrap: wrap;
551+
justify-content: space-around;
546552
bottom: 0px;
547553
align-items: center;
548554
position: fixed;
@@ -559,17 +565,7 @@ footer {
559565
*/
560566
filter: invert(100%) hue-rotate(180deg);
561567
}
562-
footer > span:first-child {
563-
margin-left: 24px;
564-
padding-left: 0;
565-
}
566-
footer > span:last-child {
567-
margin-right: 24px;
568-
padding-right: 0;
569-
}
570-
footer > span {
571-
padding: 0 16px;
572-
}
568+
573569
footer .padded-icon {
574570
padding-left: 0.5em;
575571
}
@@ -878,8 +874,6 @@ footer .pull-right {
878874
}
879875

880876
footer .socials {
881-
margin-left: 10px;
882-
margin-right: 10px;
883877
display: flex;
884878
align-items: center;
885879
}
@@ -895,7 +889,6 @@ footer .socials {
895889
}
896890

897891
#generated-by {
898-
margin-right: 20px;
899892
display: flex;
900893
align-items: center;
901894
}
@@ -930,11 +923,19 @@ footer .socials {
930923
footer > span:last-child {
931924
margin-right: 12px;
932925
}
926+
927+
footer {
928+
position: unset;
929+
}
930+
931+
.footer-text {
932+
display: none;
933+
}
933934
}
934935
/* Portrait phones */
935936
@media(max-width: 576px) {
936937
:root {
937-
--side-width: 0;
938+
--side-width: 0px;
938939
--content-padding: 48px 12px;
939940
}
940941

@@ -960,8 +961,10 @@ footer .socials {
960961
font-size: 30px;
961962
}
962963
#leftColumn.open ~ #main #leftToggler {
964+
position: fixed;
963965
left: unset;
964-
right: 5vw;
966+
right: 16vw;
967+
color: var(--leftbar-fg);
965968
}
966969
.icon-toggler::before {
967970
content: "\e90a"; /* menu icon */
@@ -1046,3 +1049,9 @@ footer .socials {
10461049
.dropdown-content a.filtered {
10471050
display: none;
10481051
}
1052+
1053+
@media(max-height:640px) {
1054+
footer {
1055+
position: unset;
1056+
}
1057+
}

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

Lines changed: 5 additions & 5 deletions
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())
@@ -216,7 +216,7 @@ class HtmlRenderer(rootPackage: Member, val members: Map[DRI, Member])(using ctx
216216

217217
def textFooter: String | AppliedTag =
218218
args.projectFooter.fold("") { f =>
219-
div(id := "footer-text")(
219+
span(id := "footer-text")(
220220
raw(f)
221221
)
222222
}
@@ -262,19 +262,19 @@ class HtmlRenderer(rootPackage: Member, val members: Map[DRI, Member])(using ctx
262262
span(cls := "go-to-top-icon")(
263263
a(href := "#container")(
264264
span(cls:="icon-vertical_align_top"),
265-
raw("&nbsp;Back to top")
265+
span(cls :="footer-text")(raw("Back to top"))
266266
)
267267
),
268268
label(id := "theme-toggle", cls := "switch")(
269269
input(`type` := "checkbox"),
270270
span(cls := "slider")
271271
),
272272
div(cls := "socials")(
273-
if hasSocialLinks then Seq(raw("Social links&nbsp;")) else Nil,
273+
span(cls := "footer-text")(if hasSocialLinks then Seq(raw("Social links")) else Nil),
274274
socialLinks(whiteIcon = false)
275275
),
276276
div(id := "generated-by")(
277-
raw("Generated by&nbsp;"),
277+
span(cls := "footer-text")(raw("Generated by")),
278278
a(href := "https://github.com/lampepfl/dotty/tree/master/scaladoc")(
279279
img(
280280
src := resolveRoot(link.dri, "images/scaladoc_logo.svg"),

0 commit comments

Comments
 (0)