Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
863e747d
Commit
863e747d
authored
Mar 08, 2023
by
pythongosssss
Browse files
Added simple settings dialog
Updated to use css vars for colors
parent
c70f0ac6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
115 additions
and
12 deletions
+115
-12
web/scripts/ui.js
web/scripts/ui.js
+86
-3
web/style.css
web/style.css
+29
-9
No files found.
web/scripts/ui.js
View file @
863e747d
...
@@ -13,6 +13,11 @@ function $el(tag, propsOrChildren, children) {
...
@@ -13,6 +13,11 @@ function $el(tag, propsOrChildren, children) {
const
cb
=
propsOrChildren
.
$
;
const
cb
=
propsOrChildren
.
$
;
delete
propsOrChildren
.
$
;
delete
propsOrChildren
.
$
;
if
(
propsOrChildren
.
style
)
{
Object
.
assign
(
element
.
style
,
propsOrChildren
.
style
);
delete
propsOrChildren
.
style
;
}
Object
.
assign
(
element
,
propsOrChildren
);
Object
.
assign
(
element
,
propsOrChildren
);
if
(
children
)
{
if
(
children
)
{
element
.
append
(...
children
);
element
.
append
(...
children
);
...
@@ -54,6 +59,80 @@ class ComfyDialog {
...
@@ -54,6 +59,80 @@ class ComfyDialog {
}
}
}
}
class
ComfySettingsDialog
extends
ComfyDialog
{
constructor
()
{
super
();
this
.
element
.
classList
.
add
(
"
comfy-settings
"
);
this
.
settings
=
[];
}
addSetting
({
id
,
name
,
type
,
defaultValue
,
onChange
})
{
if
(
!
id
)
{
throw
new
Error
(
"
Settings must have an ID
"
);
}
if
(
this
.
settings
.
find
((
s
)
=>
s
.
id
===
id
))
{
throw
new
Error
(
"
Setting IDs must be unique
"
);
}
const
settingId
=
"
Comfy.Settings.
"
+
id
;
const
v
=
localStorage
[
settingId
];
let
value
=
v
==
null
?
defaultValue
:
JSON
.
parse
(
v
);
// Trigger initial setting of value
if
(
onChange
)
{
onChange
(
value
,
undefined
);
}
this
.
settings
.
push
({
render
:
()
=>
{
const
setter
=
(
v
)
=>
{
if
(
onChange
)
{
onChange
(
v
,
value
);
}
localStorage
[
settingId
]
=
JSON
.
stringify
(
v
);
value
=
v
;
};
if
(
typeof
type
===
"
function
"
)
{
return
type
(
name
,
setter
);
}
switch
(
type
)
{
case
"
boolean
"
:
return
$el
(
"
div
"
,
[
$el
(
"
label
"
,
{
textContent
:
name
||
id
},
[
$el
(
"
input
"
,
{
type
:
"
checkbox
"
,
checked
:
!!
value
,
oninput
:
(
e
)
=>
{
setter
(
e
.
target
.
checked
);
},
}),
]),
]);
default
:
console
.
warn
(
"
Unsupported setting type, defaulting to text
"
);
return
$el
(
"
div
"
,
[
$el
(
"
label
"
,
{
textContent
:
name
||
id
},
[
$el
(
"
input
"
,
{
value
,
oninput
:
(
e
)
=>
{
setter
(
e
.
target
.
value
);
},
}),
]),
]);
}
},
});
}
show
()
{
super
.
show
();
this
.
textElement
.
replaceChildren
(...
this
.
settings
.
map
((
s
)
=>
s
.
render
()));
}
}
class
ComfyList
{
class
ComfyList
{
#
type
;
#
type
;
#
text
;
#
text
;
...
@@ -150,6 +229,7 @@ export class ComfyUI {
...
@@ -150,6 +229,7 @@ export class ComfyUI {
constructor
(
app
)
{
constructor
(
app
)
{
this
.
app
=
app
;
this
.
app
=
app
;
this
.
dialog
=
new
ComfyDialog
();
this
.
dialog
=
new
ComfyDialog
();
this
.
settings
=
new
ComfySettingsDialog
();
this
.
queue
=
new
ComfyList
(
"
Queue
"
);
this
.
queue
=
new
ComfyList
(
"
Queue
"
);
this
.
history
=
new
ComfyList
(
"
History
"
);
this
.
history
=
new
ComfyList
(
"
History
"
);
...
@@ -162,7 +242,7 @@ export class ComfyUI {
...
@@ -162,7 +242,7 @@ export class ComfyUI {
const
fileInput
=
$el
(
"
input
"
,
{
const
fileInput
=
$el
(
"
input
"
,
{
type
:
"
file
"
,
type
:
"
file
"
,
accept
:
"
.json,image/png
"
,
accept
:
"
.json,image/png
"
,
style
:
"
display: none
"
,
style
:
{
display
:
"
none
"
}
,
parent
:
document
.
body
,
parent
:
document
.
body
,
onchange
:
()
=>
{
onchange
:
()
=>
{
app
.
handleFile
(
fileInput
.
files
[
0
]);
app
.
handleFile
(
fileInput
.
files
[
0
]);
...
@@ -170,7 +250,10 @@ export class ComfyUI {
...
@@ -170,7 +250,10 @@ export class ComfyUI {
});
});
this
.
menuContainer
=
$el
(
"
div.comfy-menu
"
,
{
parent
:
document
.
body
},
[
this
.
menuContainer
=
$el
(
"
div.comfy-menu
"
,
{
parent
:
document
.
body
},
[
$el
(
"
span
"
,
{
$
:
(
q
)
=>
(
this
.
queueSize
=
q
)
}),
$el
(
"
div
"
,
{
style
:
{
overflow
:
"
hidden
"
,
position
:
"
relative
"
,
width
:
"
100%
"
}
},
[
$el
(
"
span
"
,
{
$
:
(
q
)
=>
(
this
.
queueSize
=
q
)
}),
$el
(
"
button.comfy-settings-btn
"
,
{
textContent
:
"
⚙️
"
,
onclick
:
()
=>
this
.
settings
.
show
()
}),
]),
$el
(
"
button.comfy-queue-btn
"
,
{
textContent
:
"
Queue Prompt
"
,
onclick
:
()
=>
app
.
queuePrompt
(
0
)
}),
$el
(
"
button.comfy-queue-btn
"
,
{
textContent
:
"
Queue Prompt
"
,
onclick
:
()
=>
app
.
queuePrompt
(
0
)
}),
$el
(
"
div.comfy-menu-btns
"
,
[
$el
(
"
div.comfy-menu-btns
"
,
[
$el
(
"
button
"
,
{
textContent
:
"
Queue Front
"
,
onclick
:
()
=>
app
.
queuePrompt
(
-
1
)
}),
$el
(
"
button
"
,
{
textContent
:
"
Queue Front
"
,
onclick
:
()
=>
app
.
queuePrompt
(
-
1
)
}),
...
@@ -202,7 +285,7 @@ export class ComfyUI {
...
@@ -202,7 +285,7 @@ export class ComfyUI {
const
a
=
$el
(
"
a
"
,
{
const
a
=
$el
(
"
a
"
,
{
href
:
url
,
href
:
url
,
download
:
"
workflow.json
"
,
download
:
"
workflow.json
"
,
style
:
"
display: none
"
,
style
:
{
display
:
"
none
"
}
,
parent
:
document
.
body
,
parent
:
document
.
body
,
});
});
a
.
click
();
a
.
click
();
...
...
web/style.css
View file @
863e747d
:root
{
--fg-color
:
#000
;
--bg-color
:
#fff
;
}
@media
(
prefers-color-scheme
:
dark
)
{
:root
{
--fg-color
:
#fff
;
--bg-color
:
#202020
;
}
}
body
{
body
{
width
:
100vw
;
width
:
100vw
;
height
:
100vh
;
height
:
100vh
;
margin
:
0
;
margin
:
0
;
overflow
:
hidden
;
overflow
:
hidden
;
background-color
:
var
(
--bg-color
);
color
:
var
(
--fg-color
);
}
}
#graph-canvas
{
#graph-canvas
{
...
@@ -11,7 +25,8 @@ body {
...
@@ -11,7 +25,8 @@ body {
}
}
.comfy-multiline-input
{
.comfy-multiline-input
{
background-color
:
#ffffff
;
background-color
:
var
(
--bg-color
);
color
:
var
(
--fg-color
);
overflow
:
hidden
;
overflow
:
hidden
;
overflow-y
:
auto
;
overflow-y
:
auto
;
padding
:
2px
;
padding
:
2px
;
...
@@ -73,6 +88,7 @@ body {
...
@@ -73,6 +88,7 @@ body {
top
:
50%
;
top
:
50%
;
right
:
0%
;
right
:
0%
;
background-color
:
white
;
background-color
:
white
;
color
:
#000
;
text-align
:
center
;
text-align
:
center
;
z-index
:
100
;
z-index
:
100
;
width
:
170px
;
width
:
170px
;
...
@@ -133,14 +149,18 @@ body {
...
@@ -133,14 +149,18 @@ body {
font-size
:
12px
;
font-size
:
12px
;
}
}
@media
(
prefers-color-scheme
:
dark
)
{
button
.comfy-settings-btn
{
body
{
font-size
:
12px
;
background-color
:
#202020
;
padding
:
0
;
}
position
:
absolute
;
.comfy-multiline-input
{
right
:
0
;
background-color
:
#202020
;
border
:
none
;
color
:
white
;
}
}
.comfy-modal.comfy-settings
{
background-color
:
var
(
--bg-color
);
color
:
var
(
--fg-color
);
z-index
:
99
;
}
}
@media
only
screen
and
(
max-height
:
850px
)
{
@media
only
screen
and
(
max-height
:
850px
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment