mirror of
https://github.com/danbulant/dribbblish-dynamic-theme
synced 2026-06-08 09:12:22 +00:00
add "Based on Color" theme option
This commit is contained in:
parent
569c3690f8
commit
b94797c04a
1 changed files with 26 additions and 14 deletions
|
|
@ -235,21 +235,26 @@ function toggleDark(setDark) {
|
||||||
setRootColor("subtext", setDark ? "#EAEAEA" : "#3D3D3D");
|
setRootColor("subtext", setDark ? "#EAEAEA" : "#3D3D3D");
|
||||||
setRootColor("notification", setDark ? "#303030" : "#DDDDDD");
|
setRootColor("notification", setDark ? "#303030" : "#DDDDDD");
|
||||||
|
|
||||||
updateColors(textColor, sidebarColor);
|
updateColors(textColor, sidebarColor, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkDarkLightMode() {
|
function checkDarkLightMode(colors) {
|
||||||
if (DribbblishShared.config.get("theme") != 2) return;
|
const theme = DribbblishShared.config.get("theme");
|
||||||
|
if (theme == 2) {
|
||||||
|
// Based on Time
|
||||||
|
const start = 60 * parseInt(DribbblishShared.config.get("darkModeOnTime").split(":")[0]) + parseInt(DribbblishShared.config.get("darkModeOnTime").split(":")[1]);
|
||||||
|
const end = 60 * parseInt(DribbblishShared.config.get("darkModeOffTime").split(":")[0]) + parseInt(DribbblishShared.config.get("darkModeOffTime").split(":")[1]);
|
||||||
|
|
||||||
const start = 60 * parseInt(DribbblishShared.config.get("darkModeOnTime").split(":")[0]) + parseInt(DribbblishShared.config.get("darkModeOnTime").split(":")[1]);
|
const now = new Date();
|
||||||
const end = 60 * parseInt(DribbblishShared.config.get("darkModeOffTime").split(":")[0]) + parseInt(DribbblishShared.config.get("darkModeOffTime").split(":")[1]);
|
const time = 60 * now.getHours() + now.getMinutes();
|
||||||
|
|
||||||
const now = new Date();
|
if (end < start) dark = start <= time || time < end;
|
||||||
const time = 60 * now.getHours() + now.getMinutes();
|
else dark = start <= time && time < end;
|
||||||
|
toggleDark(dark);
|
||||||
if (end < start) dark = start <= time || time < end;
|
} else if (theme == 3) {
|
||||||
else dark = start <= time && time < end;
|
// Based on Color
|
||||||
toggleDark(dark);
|
if (colors && colors.length > 0) toggleDark(isLight(colors[0]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Run every Minute to check time and set dark / light mode
|
// Run every Minute to check time and set dark / light mode
|
||||||
setInterval(checkDarkLightMode, 60000);
|
setInterval(checkDarkLightMode, 60000);
|
||||||
|
|
@ -279,13 +284,15 @@ DribbblishShared.config.register({
|
||||||
DribbblishShared.config.register({
|
DribbblishShared.config.register({
|
||||||
area: "Theme",
|
area: "Theme",
|
||||||
type: "select",
|
type: "select",
|
||||||
data: ["Dark", "Light", "Based on Time"],
|
data: ["Dark", "Light", "Based on Time", "Based on Color"],
|
||||||
key: "theme",
|
key: "theme",
|
||||||
name: "Theme",
|
name: "Theme",
|
||||||
description: "Select Dark / Bright mode",
|
description: "Select Dark / Bright mode",
|
||||||
defaultValue: 0,
|
defaultValue: 0,
|
||||||
showChildren: (val) => {
|
showChildren: (val) => {
|
||||||
return val == 2;
|
if (val == 2) return ["darkModeOnTime", "darkModeOffTime"];
|
||||||
|
//if (val == 3) return [""];
|
||||||
|
return false;
|
||||||
},
|
},
|
||||||
onChange: (val) => {
|
onChange: (val) => {
|
||||||
switch (val) {
|
switch (val) {
|
||||||
|
|
@ -298,6 +305,9 @@ DribbblishShared.config.register({
|
||||||
case 2:
|
case 2:
|
||||||
checkDarkLightMode();
|
checkDarkLightMode();
|
||||||
break;
|
break;
|
||||||
|
case 3:
|
||||||
|
checkDarkLightMode();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
|
|
@ -325,7 +335,7 @@ DribbblishShared.config.register({
|
||||||
var currentColor;
|
var currentColor;
|
||||||
var currentSideColor;
|
var currentSideColor;
|
||||||
|
|
||||||
function updateColors(textColHex, sideColHex) {
|
function updateColors(textColHex, sideColHex, checkDarkMode = true) {
|
||||||
if (textColHex && sideColHex) {
|
if (textColHex && sideColHex) {
|
||||||
currentColor = textColHex;
|
currentColor = textColHex;
|
||||||
currentSideColor = sideColHex;
|
currentSideColor = sideColHex;
|
||||||
|
|
@ -354,6 +364,8 @@ function updateColors(textColHex, sideColHex) {
|
||||||
setRootColor("tab-active", buttonBgColHex);
|
setRootColor("tab-active", buttonBgColHex);
|
||||||
setRootColor("button-disabled", buttonBgColHex);
|
setRootColor("button-disabled", buttonBgColHex);
|
||||||
setRootColor("sidebar", sideColHex);
|
setRootColor("sidebar", sideColHex);
|
||||||
|
|
||||||
|
if (checkDarkMode) checkDarkLightMode([textColHex, sideColHex]);
|
||||||
}
|
}
|
||||||
|
|
||||||
let nearArtistSpanText = "";
|
let nearArtistSpanText = "";
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue