From be20130716ecc3608a2209d438475f40f00a64bf Mon Sep 17 00:00:00 2001 From: Daniel Bulant Date: Sun, 25 Sep 2022 16:26:50 +0200 Subject: [PATCH] implement darkmode --- src/components/artDialog.svelte | 7 +++-- src/components/chapter.svelte | 14 ++++++++- src/pages/[manga]/index.svelte | 9 ++++++ src/pages/_layout.svelte | 55 +++++++++++++++++++++++++++++++-- 4 files changed, 80 insertions(+), 5 deletions(-) diff --git a/src/components/artDialog.svelte b/src/components/artDialog.svelte index b4c023f..2e413b8 100644 --- a/src/components/artDialog.svelte +++ b/src/components/artDialog.svelte @@ -4,7 +4,7 @@ {#if selectedImage} - selectedImage = null} transition:fade={{ duration: 200 }}> + selectedImage = null} transition:fade={{ duration: 200 }}> @@ -18,7 +18,7 @@ width: 100vw; height: 100vh; background: rgba(255, 255, 255, 0.6); - backdrop-filter: blur(15px); + backdrop-filter: blur(15px) saturate(150%); z-index: 100; border: none; margin: 0; @@ -27,6 +27,9 @@ justify-content: center; align-items: center; } + :global(.dark dialog[open].open.open) { + background: rgba(0, 0, 0, 0.6); + } dialog img { border-radius: 5px; max-height: 100%; diff --git a/src/components/chapter.svelte b/src/components/chapter.svelte index e6f4c81..58f2a67 100644 --- a/src/components/chapter.svelte +++ b/src/components/chapter.svelte @@ -26,7 +26,7 @@ } - + {chapter.attributes.volume ? "Vol " + chapter.attributes.volume : ""} {chapter.attributes.chapter ? "Chapter " + chapter.attributes.chapter : ""} @@ -55,12 +55,21 @@ tr.selected { background: rgba(0,0,0,0.15); } + :global(.dark tr.chapter.item.selected) { + background: rgba(255,255,255,0.15); + } tr:hover { background: rgba(0,0,0,0.2); } + :global(.dark tr.chapter.item:hover) { + background: rgba(255,255,255,0.2); + } tr.selected:hover { background: rgba(0,0,0,0.25); } + :global(.dark tr.chapter.item.selected:hover) { + background: rgba(255,255,255,0.25); + } .no-wrap { white-space: nowrap; } @@ -78,6 +87,9 @@ text-align: right; padding-right: 10px; } + :global(.dark td.action.no-wrap) { + color: white; + } td.action:hover { text-decoration: underline; diff --git a/src/pages/[manga]/index.svelte b/src/pages/[manga]/index.svelte index 4a5aca5..3ca5397 100644 --- a/src/pages/[manga]/index.svelte +++ b/src/pages/[manga]/index.svelte @@ -560,6 +560,9 @@ background: rgb(214, 214, 214); border-radius: 5px 0 5px 5px; } + :global(.dark main > .copyright.copyright.copyright) { + background: rgb(64, 64, 64); + } .copyright-header { background: rgb(214, 214, 214); padding: 10px; @@ -567,6 +570,9 @@ user-select: none; cursor: pointer; } + :global(.dark main > .flex .copyright-header) { + background: rgb(64, 64, 64); + } .copyright-header-active { border-radius: 5px 5px 0 0; } @@ -605,6 +611,9 @@ position: relative; transition: all .3s; } + :global(.dark .state) { + color: black; + } .state.idle { background: rgb(140, 209, 255); diff --git a/src/pages/_layout.svelte b/src/pages/_layout.svelte index c390b23..c920a7a 100644 --- a/src/pages/_layout.svelte +++ b/src/pages/_layout.svelte @@ -13,11 +13,32 @@ }); else console.warn("Page change; GoatCounter not loaded (yet?)", window.location.pathname); last = window.location.pathname; - }) + }); + + let defaultDarkmode = window && window.matchMedia('(prefers-color-scheme: dark)').matches; + window && window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => { + if(defaultDarkmode == darkmode) { + darkmode = event.matches; + defaultDarkmode = event.matches; + } + }); + let darkmode = localStorage && localStorage.getItem("darkmode") || defaultDarkmode; + + $: if(localStorage && darkmode !== defaultDarkmode) localStorage.setItem("darkmode", darkmode); + + $: if(darkmode) { + document.body.classList.add("dark"); + } else { + document.body.classList.remove("dark"); + } + + - +
+ +
{#if $logs.length}
@@ -28,6 +49,36 @@ {/if}