mirror of
https://github.com/danbulant/dribbblish-dynamic-theme
synced 2026-05-25 13:02:10 +00:00
add ability to use a static color
This commit is contained in:
parent
2f825e5eb9
commit
569c3690f8
2 changed files with 38 additions and 2 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue