mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-04-20 03:13:30 +00:00
simplify setting color of root, fixes fg and bg
This commit is contained in:
parent
eae159eb4c
commit
19ce3df8c0
@ -46,8 +46,8 @@ const colorPalettes = {
|
|||||||
"CONNECTING_LINK_COLOR": "#AFA",
|
"CONNECTING_LINK_COLOR": "#AFA",
|
||||||
},
|
},
|
||||||
"comfy_base": {
|
"comfy_base": {
|
||||||
"fg-color": "#000",
|
"fg-color": "#fff",
|
||||||
"bg-color": "#fff",
|
"bg-color": "#202020",
|
||||||
"comfy-menu-bg": "#353535",
|
"comfy-menu-bg": "#353535",
|
||||||
"comfy-input-bg": "#222",
|
"comfy-input-bg": "#222",
|
||||||
"input-text": "#ddd",
|
"input-text": "#ddd",
|
||||||
@ -311,10 +311,12 @@ app.registerExtension({
|
|||||||
const loadColorPalette = async (colorPalette) => {
|
const loadColorPalette = async (colorPalette) => {
|
||||||
colorPalette = await completeColorPalette(colorPalette);
|
colorPalette = await completeColorPalette(colorPalette);
|
||||||
if (colorPalette.colors) {
|
if (colorPalette.colors) {
|
||||||
|
// Sets the colors of node slots and links
|
||||||
if (colorPalette.colors.node_slot) {
|
if (colorPalette.colors.node_slot) {
|
||||||
Object.assign(app.canvas.default_connection_color_byType, colorPalette.colors.node_slot);
|
Object.assign(app.canvas.default_connection_color_byType, colorPalette.colors.node_slot);
|
||||||
Object.assign(LGraphCanvas.link_type_colors, colorPalette.colors.node_slot);
|
Object.assign(LGraphCanvas.link_type_colors, colorPalette.colors.node_slot);
|
||||||
}
|
}
|
||||||
|
// Sets the colors of the LiteGraph objects
|
||||||
if (colorPalette.colors.litegraph_base) {
|
if (colorPalette.colors.litegraph_base) {
|
||||||
// Everything updates correctly in the loop, except the Node Title and Link Color for some reason
|
// Everything updates correctly in the loop, except the Node Title and Link Color for some reason
|
||||||
app.canvas.node_title_color = colorPalette.colors.litegraph_base.NODE_TITLE_COLOR;
|
app.canvas.node_title_color = colorPalette.colors.litegraph_base.NODE_TITLE_COLOR;
|
||||||
@ -326,20 +328,11 @@ app.registerExtension({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Sets the color of ComfyUI elements
|
||||||
if (colorPalette.colors.comfy_base) {
|
if (colorPalette.colors.comfy_base) {
|
||||||
const stylesheet = document.styleSheets[1];
|
const rootStyle = document.documentElement.style;
|
||||||
|
for (const key in colorPalette.colors.comfy_base) {
|
||||||
for (let i = 0; i < stylesheet.cssRules.length; i++) {
|
rootStyle.setProperty('--' + key, colorPalette.colors.comfy_base[key]);
|
||||||
const rule = stylesheet.cssRules[i];
|
|
||||||
const selectorText = rule.selectorText;
|
|
||||||
|
|
||||||
if (selectorText && selectorText === ":root") {
|
|
||||||
console.log("Found :root rule");
|
|
||||||
for (const key in colorPalette.colors.comfy_base) {
|
|
||||||
rule.style.setProperty('--' + key, colorPalette.colors.comfy_base[key]);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
app.canvas.draw(true, true);
|
app.canvas.draw(true, true);
|
||||||
|
Loading…
Reference in New Issue
Block a user