mirror of
https://github.com/danbulant/dribbblish-dynamic-theme
synced 2026-06-05 15:51:04 +00:00
parse initial vars because "--spice-sidebar" is rgb() instead of hex
This commit is contained in:
parent
43ffd943d9
commit
03644d02c5
2 changed files with 19 additions and 4 deletions
|
|
@ -200,9 +200,21 @@ function setLightness(hex, lightness) {
|
||||||
return rgbToHex(hslToRgb(hsl));
|
return rgbToHex(hslToRgb(hsl));
|
||||||
}
|
}
|
||||||
|
|
||||||
let textColor = getComputedStyle(document.documentElement).getPropertyValue("--spice-text");
|
function parseComputedStyleColor(col) {
|
||||||
let textColorBg = getComputedStyle(document.documentElement).getPropertyValue("--spice-main");
|
if (col.startsWith("#")) return col;
|
||||||
let sidebarColor = getComputedStyle(document.documentElement).getPropertyValue("--spice-sidebar");
|
if (col.startsWith("rgb("))
|
||||||
|
return rgbToHex(
|
||||||
|
col
|
||||||
|
.replace(/rgb|(|)/g, "")
|
||||||
|
.split(",")
|
||||||
|
.map((part) => Number(part.trim()))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// `parseComputedStyleColor()` beacuse "--spice-sidebar" is `rgb()`
|
||||||
|
let textColor = parseComputedStyleColor(getComputedStyle(document.documentElement).getPropertyValue("--spice-text"));
|
||||||
|
let textColorBg = parseComputedStyleColor(getComputedStyle(document.documentElement).getPropertyValue("--spice-main"));
|
||||||
|
let sidebarColor = parseComputedStyleColor(getComputedStyle(document.documentElement).getPropertyValue("--spice-sidebar"));
|
||||||
|
|
||||||
function setRootColor(name, colHex) {
|
function setRootColor(name, colHex) {
|
||||||
let root = document.documentElement;
|
let root = document.documentElement;
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ class ConfigMenu {
|
||||||
* @property {onAppended} [onAppended]
|
* @property {onAppended} [onAppended]
|
||||||
* @property {onChange} [onChange]
|
* @property {onChange} [onChange]
|
||||||
* @property {DribbblishConfigItem[]} [children=[]]
|
* @property {DribbblishConfigItem[]} [children=[]]
|
||||||
|
* @property {String} [childOf=null] key of parent
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -111,6 +112,7 @@ class ConfigMenu {
|
||||||
* @param {DribbblishConfigItem} options
|
* @param {DribbblishConfigItem} options
|
||||||
*/
|
*/
|
||||||
register(options) {
|
register(options) {
|
||||||
|
/** @type {DribbblishConfigItem} */
|
||||||
const defaultOptions = {
|
const defaultOptions = {
|
||||||
hidden: false,
|
hidden: false,
|
||||||
area: "Main Settings",
|
area: "Main Settings",
|
||||||
|
|
@ -123,7 +125,8 @@ class ConfigMenu {
|
||||||
showChildren: () => true,
|
showChildren: () => true,
|
||||||
onAppended: () => {},
|
onAppended: () => {},
|
||||||
onChange: () => {},
|
onChange: () => {},
|
||||||
children: []
|
children: [],
|
||||||
|
childOf: null
|
||||||
};
|
};
|
||||||
// Set Defaults
|
// Set Defaults
|
||||||
options = { ...defaultOptions, ...options };
|
options = { ...defaultOptions, ...options };
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue