Simplified how the auto theme works
This commit is contained in:
parent
320af99b76
commit
118f200500
@ -29,7 +29,8 @@ iframe#yomichan-float {
|
|||||||
box-sizing: border-box;
|
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;
|
background-color: #1e1e1e;
|
||||||
border: 1px solid #666;
|
border: 1px solid #666;
|
||||||
box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
|
box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
|
||||||
|
@ -271,19 +271,16 @@ class Popup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateTheme() {
|
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) {
|
getSiteColor() {
|
||||||
if (themeName === 'auto') {
|
|
||||||
const color = [255, 255, 255];
|
const color = [255, 255, 255];
|
||||||
Popup.addColor(color, Popup.getColorInfo(window.getComputedStyle(document.documentElement).backgroundColor));
|
Popup.addColor(color, Popup.getColorInfo(window.getComputedStyle(document.documentElement).backgroundColor));
|
||||||
Popup.addColor(color, Popup.getColorInfo(window.getComputedStyle(document.body).backgroundColor));
|
Popup.addColor(color, Popup.getColorInfo(window.getComputedStyle(document.body).backgroundColor));
|
||||||
const dark = (color[0] < 128 && color[1] < 128 && color[2] < 128);
|
const dark = (color[0] < 128 && color[1] < 128 && color[2] < 128);
|
||||||
themeName = dark ? 'dark' : 'default';
|
return dark ? 'dark' : 'light';
|
||||||
}
|
|
||||||
|
|
||||||
return themeName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static addColor(target, color) {
|
static addColor(target, color) {
|
||||||
|
Loading…
Reference in New Issue
Block a user