add ability to use a static color

This commit is contained in:
Send_Nukez 2021-10-25 09:48:54 +02:00
parent 2f825e5eb9
commit 569c3690f8
2 changed files with 38 additions and 2 deletions

View file

@ -254,6 +254,28 @@ function checkDarkLightMode() {
// Run every Minute to check time and set dark / light mode
setInterval(checkDarkLightMode, 60000);
DribbblishShared.config.register({
area: "Theme",
type: "checkbox",
key: "dynamicColors",
name: "Dynamic",
description: "If the Theme's Color should be extracted from Albumart",
defaultValue: true,
onChange: (val) => updateColors(),
showChildren: (val) => !val,
children: [
{
type: "color",
key: "colorOverride",
name: "Color",
description: "The Color of the Theme",
defaultValue: "#1ed760",
fireInitialChange: false,
onChange: (val) => updateColors()
}
]
});
DribbblishShared.config.register({
area: "Theme",
type: "select",
@ -302,9 +324,23 @@ DribbblishShared.config.register({
var currentColor;
var currentSideColor;
var colorFadeInterval = false;
function updateColors(textColHex, sideColHex) {
if (textColHex && sideColHex) {
currentColor = textColHex;
currentSideColor = sideColHex;
} else {
if (!(currentColor && currentSideColor)) return; // If `updateColors()` is called early these vars are undefined and would break
textColHex = currentColor;
sideColHex = currentSideColor;
}
if (!DribbblishShared.config.get("dynamicColors")) {
const col = DribbblishShared.config.get("colorOverride");
textColHex = col;
sideColHex = col;
}
let isLightBg = isLight(textColorBg);
if (isLightBg) textColHex = LightenDarkenColor(textColHex, -15); // vibrant color is always too bright for white bg mode

View file

@ -18,7 +18,7 @@ class ConfigMenu {
* @property {onAppended} [onAppended]
* @property {onChange} [onChange]
* @property {DribbblishConfigItem[]} [children=[]]
* @property {String} [childOf=null] key of parent
* @property {String} [childOf=null] key of parent (set automatically)
*/
/**