diff --git a/dribbblish-dynamic.js b/dribbblish-dynamic.js index 4709e84..4103e79 100644 --- a/dribbblish-dynamic.js +++ b/dribbblish-dynamic.js @@ -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 diff --git a/dribbblish.js b/dribbblish.js index daa538b..caa7bb5 100644 --- a/dribbblish.js +++ b/dribbblish.js @@ -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) */ /**