[refactor] improve initial page colour when switching to automatic theme style

This commit is contained in:
zombieFox 2020-08-05 09:52:14 +01:00
parent 2e099f8eb8
commit de7f90bd35
5 changed files with 26 additions and 8 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "nightTab",
"version": "5.79.0",
"version": "5.80.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "nightTab",
"version": "5.79.0",
"version": "5.80.0",
"description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.",
"main": "index.js",
"scripts": {

View File

@ -124,8 +124,24 @@ var theme = (function() {
};
mod.style = {
save: function() {
data.mod.set("nightTabStyle", state.get.current().theme.style);
initial: function() {
switch (state.get.current().theme.style) {
case "dark":
data.mod.set("nightTabStyle", state.get.current().theme.style);
break;
case "light":
data.mod.set("nightTabStyle", state.get.current().theme.style);
break;
case "system":
if (window.matchMedia("(prefers-color-scheme:dark)").matches) {
data.mod.set("nightTabStyle", "dark");
} else if (window.matchMedia("(prefers-color-scheme:light)").matches) {
data.mod.set("nightTabStyle", "light");
};
break;
};
},
light: function() {
helper.setObject({
@ -133,7 +149,6 @@ var theme = (function() {
path: "theme.style",
newValue: "light"
});
mod.style.save();
},
dark: function() {
helper.setObject({
@ -141,7 +156,6 @@ var theme = (function() {
path: "theme.style",
newValue: "dark"
});
mod.style.save();
},
system: function() {
helper.setObject({
@ -3019,14 +3033,17 @@ var theme = (function() {
var style = {
dark: function() {
mod.style.dark();
mod.style.initial();
render.style.dark();
},
light: function() {
mod.style.light();
mod.style.initial();
render.style.light();
},
system: function() {
mod.style.system();
mod.style.initial();
render.style.system();
},
check: function() {
@ -3066,6 +3083,7 @@ var theme = (function() {
};
var init = function() {
mod.style.initial();
mod.color.generated();
mod.accent.random();
mod.custom.close();

View File

@ -1,6 +1,6 @@
var version = (function() {
var current = "5.79.0";
var current = "5.80.0";
var name = "Jaded Raven";

View File

@ -2,7 +2,7 @@
"name": "nightTab",
"short_name": "nightTab",
"description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.",
"version": "5.79.0",
"version": "5.80.0",
"manifest_version": 2,
"chrome_url_overrides": {
"newtab": "index.html"