From 118f200500b3a27afc873a896b8304387456e2e7 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 13 Oct 2019 10:50:56 -0400 Subject: Simplified how the auto theme works --- ext/fg/css/client.css | 3 ++- ext/fg/js/popup.js | 19 ++++++++----------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/ext/fg/css/client.css b/ext/fg/css/client.css index 84098653..4b824da3 100644 --- a/ext/fg/css/client.css +++ b/ext/fg/css/client.css @@ -29,7 +29,8 @@ iframe#yomichan-float { box-sizing: border-box; } -iframe#yomichan-float[data-yomichan-theme=dark] { +iframe#yomichan-float[data-yomichan-theme=dark], +iframe#yomichan-float[data-yomichan-theme=auto][data-yomichan-site-color=dark] { background-color: #1e1e1e; border: 1px solid #666; box-shadow: 0 0 10px rgba(255, 255, 255, 0.5); diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js index ef4cdb67..880e3efe 100644 --- a/ext/fg/js/popup.js +++ b/ext/fg/js/popup.js @@ -271,19 +271,16 @@ class Popup { } updateTheme() { - this.container.dataset.yomichanTheme = this.getTheme(this.options.general.popupOuterTheme); + this.container.dataset.yomichanTheme = this.options.general.popupOuterTheme; + this.container.dataset.yomichanSiteColor = this.getSiteColor(); } - getTheme(themeName) { - if (themeName === 'auto') { - const color = [255, 255, 255]; - Popup.addColor(color, Popup.getColorInfo(window.getComputedStyle(document.documentElement).backgroundColor)); - Popup.addColor(color, Popup.getColorInfo(window.getComputedStyle(document.body).backgroundColor)); - const dark = (color[0] < 128 && color[1] < 128 && color[2] < 128); - themeName = dark ? 'dark' : 'default'; - } - - return themeName; + getSiteColor() { + const color = [255, 255, 255]; + Popup.addColor(color, Popup.getColorInfo(window.getComputedStyle(document.documentElement).backgroundColor)); + Popup.addColor(color, Popup.getColorInfo(window.getComputedStyle(document.body).backgroundColor)); + const dark = (color[0] < 128 && color[1] < 128 && color[2] < 128); + return dark ? 'dark' : 'light'; } static addColor(target, color) { -- cgit v1.2.3 From 32729482844d7af9e9f307a69c96ea34f1e66011 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 13 Oct 2019 11:05:21 -0400 Subject: Adds setting for controlling the outer style of the popup --- ext/bg/css/settings.css | 3 ++- ext/bg/js/options.js | 3 ++- ext/bg/js/settings.js | 2 ++ ext/bg/settings.html | 12 ++++++++++-- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/ext/bg/css/settings.css b/ext/bg/css/settings.css index 09d60b26..21cbe256 100644 --- a/ext/bg/css/settings.css +++ b/ext/bg/css/settings.css @@ -128,7 +128,8 @@ content: counter(audio-source-id); } -#custom-popup-css { +#custom-popup-css, +#custom-popup-outer-css { width: 100%; min-height: 34px; height: 96px; diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js index cadc4443..fac17d68 100644 --- a/ext/bg/js/options.js +++ b/ext/bg/js/options.js @@ -278,7 +278,8 @@ function profileOptionsCreateDefaults() { mainDictionary: '', popupTheme: 'default', popupOuterTheme: 'default', - customPopupCss: '' + customPopupCss: '', + customPopupOuterCss: '' }, audio: { diff --git a/ext/bg/js/settings.js b/ext/bg/js/settings.js index 900b89bb..7eee7bce 100644 --- a/ext/bg/js/settings.js +++ b/ext/bg/js/settings.js @@ -42,6 +42,7 @@ async function formRead(options) { options.general.popupTheme = $('#popup-theme').val(); options.general.popupOuterTheme = $('#popup-outer-theme').val(); options.general.customPopupCss = $('#custom-popup-css').val(); + options.general.customPopupOuterCss = $('#custom-popup-outer-css').val(); options.audio.enabled = $('#audio-playback-enabled').prop('checked'); options.audio.autoPlay = $('#auto-play-audio').prop('checked'); @@ -112,6 +113,7 @@ async function formWrite(options) { $('#popup-theme').val(options.general.popupTheme); $('#popup-outer-theme').val(options.general.popupOuterTheme); $('#custom-popup-css').val(options.general.customPopupCss); + $('#custom-popup-outer-css').val(options.general.customPopupOuterCss); $('#audio-playback-enabled').prop('checked', options.audio.enabled); $('#auto-play-audio').prop('checked', options.audio.autoPlay); diff --git a/ext/bg/settings.html b/ext/bg/settings.html index 08e56a09..cb223e72 100644 --- a/ext/bg/settings.html +++ b/ext/bg/settings.html @@ -252,8 +252,16 @@
- -
+
+
+ +
+
+
+ +
+
+