Skip to content

Commit 85574c7

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 77ab6a8 commit 85574c7

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;
@@ -318,6 +321,7 @@ th {
318321

319322
#sideMenu2 a.selected {
320323
background: var(--leftbar-current-bg);
324+
color: var(--leftbar-current-fg);
321325
font-weight: bold;
322326
}
323327

@@ -533,6 +537,8 @@ Same solution is already used in Dokka.
533537

534538
/* Footer */
535539
footer {
540+
background: var(--footer-bg);
541+
color: var(--footer-fg);
536542
display: flex;
537543
bottom: 0px;
538544
align-items: center;
@@ -543,8 +549,12 @@ footer {
543549
min-height: var(--footer-height);
544550
border-top: 1px solid var(--border-light);
545551
}
546-
footer span.go-to-top-icon {
547-
background-color: white;
552+
.theme-dark footer img {
553+
/* "Poor man's dark mode" for images.
554+
* This works great with black images,
555+
* and just-okay with colored images.
556+
*/
557+
filter: invert(100%) hue-rotate(180deg);
548558
}
549559
footer > span:first-child {
550560
margin-left: 24px;
@@ -609,9 +619,7 @@ footer .pull-right {
609619
-webkit-transition: 0.4s;
610620
transition: 0.4s;
611621
box-shadow: 0 0px 15px #2020203d;
612-
613-
background-repeat: no-repeat;
614-
background-position: center;
622+
background: #555;
615623
}
616624
.switch input:checked + .slider {
617625
background-color: hsl(200, 80%, 65%); /* --active-bg, but not affected by the theme */
@@ -653,7 +661,7 @@ footer .pull-right {
653661
}
654662

655663
.other-modifiers a, .other-modifiers a:visited, .other-modifiers span[data-unresolved-link] {
656-
color: var(--link-sig-fd);
664+
color: var(--link-sig-fg);
657665
}
658666

659667
.documentableElement.expand .modifiers {
@@ -668,7 +676,7 @@ footer .pull-right {
668676
}
669677

670678
.signature a, .signature a:visited, .signature span[data-unresolved-link] {
671-
color: var(--link-sig-fd);
679+
color: var(--link-sig-fg);
672680
}
673681

674682
.expand .signature {
@@ -866,10 +874,6 @@ footer .pull-right {
866874
margin-right: 5%;
867875
}
868876

869-
footer {
870-
color: grey;
871-
}
872-
873877
footer .socials {
874878
margin-left: 10px;
875879
margin-right: 10px;
@@ -973,7 +977,3 @@ footer .socials {
973977
display: none;
974978
}
975979
}
976-
977-
footer {
978-
background-color: white;
979-
}

0 commit comments

Comments
 (0)