Skip to content

Commit b38a6bd

Browse files
committed
basic dark theme for reader view
1 parent 84a8767 commit b38a6bd

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

reader/reader.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1-
//http://stackoverflow.com/a/2091331
1+
var hours = new Date().getHours();
2+
3+
var isDarkTheme = false;
24

5+
if (hours > 21 || hours < 6) {
6+
isDarkTheme = true;
7+
8+
document.body.classList.add("dark-theme")
9+
}
10+
11+
//http://stackoverflow.com/a/2091331
312

413
function getQueryVariable(variable) {
514
var query = window.location.search.substring(1);
@@ -15,8 +24,6 @@ function getQueryVariable(variable) {
1524

1625
var backbutton = document.getElementById("backtoarticle");
1726

18-
var emptyHTMLdocument = "<!DOCTYPE html><html><head></head><body></body></html>"
19-
2027
function startReaderView(article) {
2128

2229
document.body.removeChild(parserframe);
@@ -46,6 +53,10 @@ function startReaderView(article) {
4653

4754
rframe.onload = function () {
4855

56+
if (isDarkTheme) {
57+
rframe.contentDocument.body.classList.add("dark-theme");
58+
}
59+
4960
requestAnimationFrame(function () {
5061
rframe.height = rframe.contentDocument.body.querySelector(".reader-main").scrollHeight + "px";
5162
requestAnimationFrame(function () {

reader/readerView.css

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,11 @@ a {
108108
color: inherit;
109109
font-size: 1em;
110110
text-decoration: none;
111-
color: #777;
111+
opacity: 0.6;
112112
}
113113
a:hover {
114114
color: #2196F3;
115+
opacity: 1.0;
115116
}
116117
figure {
117118
max-width: 50%;
@@ -147,6 +148,13 @@ blockquote {
147148
margin: 1.5em 0;
148149
}
149150

151+
/* dark theme */
152+
153+
body.dark-theme {
154+
background-color: #000;
155+
color: #fff;
156+
}
157+
150158
/* site-specific styles */
151159

152160

0 commit comments

Comments
 (0)