Skip to content

Commit be8fbba

Browse files
committed
Make dark-mode footer actually dark. Improve contrast/accessibility.
Used the "poor man's dark mode" approach to deal with the images in the footer in dark mode, i.e. invert and hue rotate (without the hue rotate, the red scala3doc logo becomes blue) Also fix an issue where if you click "back to top" and then refresh the page, the "container" element gains the "expand" class, which causes the main signature (i.e. `class List[A] ...`) to become 'inline' instead of a block, and it also triggers the 6.5em left-margin that's intended for method signatures when they get expanded. Also consolidated the `footer` styles, since they were spread all over.
1 parent 1c61129 commit be8fbba

File tree

2 files changed

+28
-23
lines changed

2 files changed

+28
-23
lines changed

scaladoc/resources/dotty_res/scripts/ux.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,14 @@ window.addEventListener("DOMContentLoaded", () => {
3939
})
4040

4141
if (location.hash) {
42-
var selected = document.getElementById(location.hash.substring(1));
43-
if (selected){
44-
selected.classList.toggle("expand");
42+
var target = location.hash.substring(1);
43+
// setting the 'expand' class on the top-level container causes undesireable styles
44+
// to apply to the top-level docs, so we avoid this logic for that element.
45+
if (target != 'container') {
46+
var selected = document.getElementById(location.hash.substring(1));
47+
if (selected) {
48+
selected.classList.toggle("expand");
49+
}
4550
}
4651
}
4752

scaladoc/resources/dotty_res/styles/scalastyle.css

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
--link-fg: #00607D;
2626
--link-hover-fg: #00A0D0;
2727

28-
--link-sig-fd: #2da0d1;
29-
--link-sig-hover-fd: #7c99a5;
28+
--link-sig-fg: var(--link-fg);
3029

3130
--leftbar-bg: hsl(200, 65%, 75%);
3231
--leftbar-fg: #333;
@@ -35,6 +34,8 @@
3534
--leftbar-hover-bg: hsl(200, 65%, 65%);
3635
--leftbar-hover-fg: #333;
3736

37+
--footer-bg: #FFF;
38+
3839
--icon-color: #00485E;
3940
--selected-fg: #00303E;
4041
--selected-bg: #BFE7F3;
@@ -73,16 +74,18 @@
7374
--link-fg: hsl(200, 100%, 70%);
7475
--link-hover-fg: #00A0D0;
7576

76-
--link-sig-fd: #2da0d1;
77-
--link-sig-hover-fd: #7c99a5;
77+
--link-sig-fg: #2da0d1;
7878

7979
--leftbar-bg: hsl(200, 100%, 14%);
8080
--leftbar-fg: #CCC;
8181
--leftbar-current-bg: hsl(200, 100%, 35%);
82-
--leftbar-current-fg: #CCC;
82+
--leftbar-current-fg: #FFF;
8383
--leftbar-hover-bg: hsl(200, 80%, 25%);
8484
--leftbar-hover-fg: #CCC;
8585

86+
--footer-bg: var(--body-bg);
87+
--footer-fg: var(--body-fg);
88+
8689
--icon-color: #00485E;
8790
--selected-fg: #00303E;
8891
--selected-bg: #BFE7F3;
@@ -321,6 +324,7 @@ th {
321324

322325
#sideMenu2 a.selected {
323326
background: var(--leftbar-current-bg);
327+
color: var(--leftbar-current-fg);
324328
font-weight: bold;
325329
}
326330

@@ -536,6 +540,8 @@ Same solution is already used in Dokka.
536540

537541
/* Footer */
538542
footer {
543+
background: var(--footer-bg);
544+
color: var(--footer-fg);
539545
display: flex;
540546
bottom: 0px;
541547
align-items: center;
@@ -546,8 +552,12 @@ footer {
546552
min-height: var(--footer-height);
547553
border-top: 1px solid var(--border-light);
548554
}
549-
footer span.go-to-top-icon {
550-
background-color: white;
555+
.theme-dark footer img {
556+
/* "Poor man's dark mode" for images.
557+
* This works great with black images,
558+
* and just-okay with colored images.
559+
*/
560+
filter: invert(100%) hue-rotate(180deg);
551561
}
552562
footer > span:first-child {
553563
margin-left: 24px;
@@ -612,9 +622,7 @@ footer .pull-right {
612622
-webkit-transition: 0.4s;
613623
transition: 0.4s;
614624
box-shadow: 0 0px 15px #2020203d;
615-
616-
background-repeat: no-repeat;
617-
background-position: center;
625+
background: #555;
618626
}
619627
.switch input:checked + .slider {
620628
background-color: hsl(200, 80%, 65%); /* --active-bg, but not affected by the theme */
@@ -656,7 +664,7 @@ footer .pull-right {
656664
}
657665

658666
.other-modifiers a, .other-modifiers a:visited, .other-modifiers span[data-unresolved-link] {
659-
color: var(--link-sig-fd);
667+
color: var(--link-sig-fg);
660668
}
661669

662670
.documentableElement.expand .modifiers {
@@ -671,7 +679,7 @@ footer .pull-right {
671679
}
672680

673681
.signature a, .signature a:visited, .signature span[data-unresolved-link] {
674-
color: var(--link-sig-fd);
682+
color: var(--link-sig-fg);
675683
}
676684

677685
.expand .signature {
@@ -869,10 +877,6 @@ footer .pull-right {
869877
margin-right: 5%;
870878
}
871879

872-
footer {
873-
color: grey;
874-
}
875-
876880
footer .socials {
877881
margin-left: 10px;
878882
margin-right: 10px;
@@ -977,10 +981,6 @@ footer .socials {
977981
}
978982
}
979983

980-
footer {
981-
background-color: white;
982-
}
983-
984984
/* The container <div> - needed to position the dropdown content */
985985
.versions-dropdown {
986986
position: relative;

0 commit comments

Comments
 (0)