mirror of
https://github.com/danbulant/dribbblish-dynamic-theme
synced 2026-05-24 12:35:05 +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));
|
||||
}
|
||||
|
||||
let textColor = getComputedStyle(document.documentElement).getPropertyValue("--spice-text");
|
||||
let textColorBg = getComputedStyle(document.documentElement).getPropertyValue("--spice-main");
|
||||
let sidebarColor = getComputedStyle(document.documentElement).getPropertyValue("--spice-sidebar");
|
||||
function parseComputedStyleColor(col) {
|
||||
if (col.startsWith("#")) return col;
|
||||
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) {
|
||||
let root = document.documentElement;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ class ConfigMenu {
|
|||
* @property {onAppended} [onAppended]
|
||||
* @property {onChange} [onChange]
|
||||
* @property {DribbblishConfigItem[]} [children=[]]
|
||||
* @property {String} [childOf=null] key of parent
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -111,6 +112,7 @@ class ConfigMenu {
|
|||
* @param {DribbblishConfigItem} options
|
||||
*/
|
||||
register(options) {
|
||||
/** @type {DribbblishConfigItem} */
|
||||
const defaultOptions = {
|
||||
hidden: false,
|
||||
area: "Main Settings",
|
||||
|
|
@ -123,7 +125,8 @@ class ConfigMenu {
|
|||
showChildren: () => true,
|
||||
onAppended: () => {},
|
||||
onChange: () => {},
|
||||
children: []
|
||||
children: [],
|
||||
childOf: null
|
||||
};
|
||||
// Set Defaults
|
||||
options = { ...defaultOptions, ...options };
|
||||
|
|
|
|||
Loading…
Reference in a new issue