From eb38440ee4d78f2616311b3cfcda9eb3f7ac74b0 Mon Sep 17 00:00:00 2001 From: Marcus Noble Date: Sat, 17 Oct 2020 19:50:13 +0100 Subject: [PATCH] Improve darkmode --- views/index.html | 22 +++++++++++++--------- views/static/feed-item.js | 31 +++++++++++++++++++++++-------- views/static/style.css | 6 +++++- 3 files changed, 41 insertions(+), 18 deletions(-) diff --git a/views/index.html b/views/index.html index 23a8a1b..9958959 100644 --- a/views/index.html +++ b/views/index.html @@ -6,12 +6,12 @@ Gopherss - - + + @@ -35,14 +35,12 @@
-
- All - ({{items.length}}) +
+ All ({{items.length}})
-
- {{feed.Title}} - ({{unreadCount(feed)}}) +
+ {{feed.Title}} ({{unreadCount(feed)}})
@@ -112,6 +110,7 @@ newSiteURL: '', opml: '', isBusy: false, + isDark: false, }, computed: { shownItems() { @@ -128,6 +127,7 @@ document.body.style.cursor = isBusy ? "wait" : ""; }, toggleDarkMode() { + this.isDark = !this.isDark; document.body.classList.toggle('dark'); document.body.classList.toggle('dark-grey'); }, @@ -290,6 +290,10 @@ }; document.addEventListener('keydown', this._keyListener.bind(this)); + + if (window.matchMedia('(prefers-color-scheme: dark)').matches) { + this.toggleDarkMode(); + } }, beforeDestroy() { document.removeEventListener('keydown', this._keyListener); diff --git a/views/static/feed-item.js b/views/static/feed-item.js index db880e6..ab1bbbe 100644 --- a/views/static/feed-item.js +++ b/views/static/feed-item.js @@ -9,21 +9,36 @@ class FeedItem extends HTMLElement { const template = document.createElement('template'); template.innerHTML = ` `; diff --git a/views/static/style.css b/views/static/style.css index 9be86b6..233f9fb 100644 --- a/views/static/style.css +++ b/views/static/style.css @@ -9,7 +9,7 @@ .dark .strong { font-weight: bold; - color: #eee; + color: #fefefe; } .loading { @@ -114,3 +114,7 @@ max-width: 100em; } } + +.dark { + background: #333; +}