Skip to content

Commit 346a744

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 90317e7 commit 346a744

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
@@ -23,8 +23,7 @@
2323
--link-fg: #00607D;
2424
--link-hover-fg: #00A0D0;
2525

26-
--link-sig-fd: #2da0d1;
27-
--link-sig-hover-fd: #7c99a5;
26+
--link-sig-fg: var(--link-fg);
2827

2928
--leftbar-bg: hsl(200, 65%, 75%);
3029
--leftbar-fg: #333;
@@ -33,6 +32,8 @@
3332
--leftbar-hover-bg: hsl(200, 65%, 65%);
3433
--leftbar-hover-fg: #333;
3534

35+
--footer-bg: #FFF;
36+
3637
--icon-color: #00485E;
3738
--selected-fg: #00303E;
3839
--selected-bg: #BFE7F3;
@@ -71,16 +72,18 @@
7172
--link-fg: hsl(200, 100%, 70%);
7273
--link-hover-fg: #00A0D0;
7374

74-
--link-sig-fd: #2da0d1;
75-
--link-sig-hover-fd: #7c99a5;
75+
--link-sig-fg: #2da0d1;
7676

7777
--leftbar-bg: hsl(200, 100%, 14%);
7878
--leftbar-fg: #CCC;
7979
--leftbar-current-bg: hsl(200, 100%, 35%);
80-
--leftbar-current-fg: #CCC;
80+
--leftbar-current-fg: #FFF;
8181
--leftbar-hover-bg: hsl(200, 80%, 25%);
8282
--leftbar-hover-fg: #CCC;
8383

84+
--footer-bg: var(--body-bg);
85+
--footer-fg: var(--body-fg);
86+
8487
--icon-color: #00485E;
8588
--selected-fg: #00303E;
8689
--selected-bg: #BFE7F3;
@@ -267,6 +270,7 @@ th {
267270

268271
#sideMenu2 a.selected {
269272
background: var(--leftbar-current-bg);
273+
color: var(--leftbar-current-fg);
270274
font-weight: bold;
271275
}
272276

@@ -482,6 +486,8 @@ Same solution is already used in Dokka.
482486

483487
/* Footer */
484488
footer {
489+
background: var(--footer-bg);
490+
color: var(--footer-fg);
485491
display: flex;
486492
bottom: 0px;
487493
align-items: center;
@@ -492,8 +498,12 @@ footer {
492498
min-height: var(--footer-height);
493499
border-top: 1px solid var(--border-light);
494500
}
495-
footer span.go-to-top-icon {
496-
background-color: white;
501+
.theme-dark footer img {
502+
/* "Poor man's dark mode" for images.
503+
* This works great with black images,
504+
* and just-okay with colored images.
505+
*/
506+
filter: invert(100%) hue-rotate(180deg);
497507
}
498508
footer > span:first-child {
499509
margin-left: 24px;
@@ -558,9 +568,7 @@ footer .pull-right {
558568
-webkit-transition: 0.4s;
559569
transition: 0.4s;
560570
box-shadow: 0 0px 15px #2020203d;
561-
562-
background-repeat: no-repeat;
563-
background-position: center;
571+
background: #555;
564572
}
565573
.switch input:checked + .slider {
566574
background-color: hsl(200, 80%, 65%); /* --active-bg, but not affected by the theme */
@@ -596,7 +604,7 @@ footer .pull-right {
596604
}
597605

598606
.other-modifiers a, .other-modifiers a:visited, .other-modifiers span[data-unresolved-link] {
599-
color: var(--link-sig-fd);
607+
color: var(--link-sig-fg);
600608
}
601609

602610
.documentableElement.expand .modifiers {
@@ -611,7 +619,7 @@ footer .pull-right {
611619
}
612620

613621
.signature a, .signature a:visited, .signature span[data-unresolved-link] {
614-
color: var(--link-sig-fd);
622+
color: var(--link-sig-fg);
615623
}
616624

617625
.expand .signature {
@@ -790,10 +798,6 @@ footer .pull-right {
790798
margin-right: 5%;
791799
}
792800

793-
footer {
794-
color: grey;
795-
}
796-
797801
footer .socials {
798802
margin-left: 10px;
799803
margin-right: 10px;
@@ -897,7 +901,3 @@ footer .socials {
897901
display: none;
898902
}
899903
}
900-
901-
footer {
902-
background-color: white;
903-
}

0 commit comments

Comments
 (0)