Button options
This commit is contained in:
@@ -42,6 +42,8 @@
|
|||||||
children = layoutState.updateChildren(container, evt.detail.items)
|
children = layoutState.updateChildren(container, evt.detail.items)
|
||||||
// Ensure dragging is stopped on drag finish
|
// Ensure dragging is stopped on drag finish
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const tt = "asd\nasdlkj"
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if container && children}
|
{#if container && children}
|
||||||
|
|||||||
@@ -93,10 +93,7 @@ export type LayoutState = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attributes for both containers and nodes, or containers only.
|
* Attributes for both containers and nodes.
|
||||||
* If the attribute can be applicable to both, then it should go here.
|
|
||||||
* If it only applies to a container it should go here too.
|
|
||||||
* If it only applies to a node it should be placed in its LGraphNode.properties (nodeProps) instead.
|
|
||||||
**/
|
**/
|
||||||
export type Attributes = {
|
export type Attributes = {
|
||||||
/*
|
/*
|
||||||
@@ -134,6 +131,11 @@ export type Attributes = {
|
|||||||
*/
|
*/
|
||||||
disabled?: boolean,
|
disabled?: boolean,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CSS height
|
||||||
|
*/
|
||||||
|
height?: string,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CSS Flex grow
|
* CSS Flex grow
|
||||||
*/
|
*/
|
||||||
@@ -145,12 +147,16 @@ export type Attributes = {
|
|||||||
*/
|
*/
|
||||||
variant?: string,
|
variant?: string,
|
||||||
|
|
||||||
/*************************************/
|
/*********************************************/
|
||||||
/* Special attributes for containers */
|
/* Special attributes for widgets/containers */
|
||||||
/*************************************/
|
/*********************************************/
|
||||||
|
|
||||||
// Accordion
|
// Accordion
|
||||||
openOnStartup?: boolean
|
openOnStartup?: boolean
|
||||||
|
|
||||||
|
// Button
|
||||||
|
buttonVariant?: "primary" | "secondary",
|
||||||
|
buttonSize?: "large" | "small"
|
||||||
}
|
}
|
||||||
|
|
||||||
export type AttributesSpec = {
|
export type AttributesSpec = {
|
||||||
@@ -330,6 +336,26 @@ const ALL_ATTRIBUTES: AttributesSpecList = [
|
|||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
canShow: (di: IDragItem) => di.type === "container" && di.attrs.variant === "accordion"
|
canShow: (di: IDragItem) => di.type === "container" && di.attrs.variant === "accordion"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Button
|
||||||
|
{
|
||||||
|
name: "buttonVariant",
|
||||||
|
type: "enum",
|
||||||
|
location: "widget",
|
||||||
|
editable: true,
|
||||||
|
validNodeTypes: ["ui/button"],
|
||||||
|
values: ["primary", "secondary"],
|
||||||
|
defaultValue: "primary"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "buttonSize",
|
||||||
|
type: "enum",
|
||||||
|
location: "widget",
|
||||||
|
editable: true,
|
||||||
|
validNodeTypes: ["ui/button"],
|
||||||
|
values: ["large", "small"],
|
||||||
|
defaultValue: "large"
|
||||||
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
import type { ComfySliderNode } from "$lib/nodes/index";
|
import type { ComfySliderNode } from "$lib/nodes/index";
|
||||||
import { type WidgetLayout } from "$lib/stores/layoutState";
|
import { type WidgetLayout } from "$lib/stores/layoutState";
|
||||||
import { Button } from "@gradio/button";
|
import { Button } from "@gradio/button";
|
||||||
import { get, type Writable } from "svelte/store";
|
import { get, type Writable, writable } from "svelte/store";
|
||||||
export let widget: WidgetLayout | null = null;
|
export let widget: WidgetLayout | null = null;
|
||||||
let node: ComfyButtonNode | null = null;
|
let node: ComfyButtonNode | null = null;
|
||||||
let nodeValue: Writable<boolean> | null = null;
|
let nodeValue: Writable<boolean> | null = null;
|
||||||
let propsChanged: Writable<number> | null = null;
|
let attrsChanged: Writable<boolean> | null = null;
|
||||||
|
|
||||||
$: widget && setNodeValue(widget);
|
$: widget && setNodeValue(widget);
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
if (widget) {
|
if (widget) {
|
||||||
node = widget.node as ComfyButtonNode
|
node = widget.node as ComfyButtonNode
|
||||||
nodeValue = node.value;
|
nodeValue = node.value;
|
||||||
propsChanged = node.propsChanged;
|
attrsChanged = widget.attrsChanged;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -24,20 +24,23 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const style = {
|
const style = {
|
||||||
full_width: "100%"
|
full_width: "100%",
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="wrapper gradio-button">
|
<div class="wrapper gradio-button">
|
||||||
|
{#key $attrsChanged}
|
||||||
{#if node !== null}
|
{#if node !== null}
|
||||||
<Button
|
<Button
|
||||||
disabled={widget.attrs.disabled}
|
disabled={widget.attrs.disabled}
|
||||||
on:click={onClick}
|
on:click={onClick}
|
||||||
variant="primary"
|
variant={widget.attrs.buttonVariant || "primary"}
|
||||||
|
size={widget.attrs.buttonSize === "small" ? "sm" : "lg"}
|
||||||
{style}>
|
{style}>
|
||||||
{widget.attrs.title}
|
{widget.attrs.title}
|
||||||
</Button>
|
</Button>
|
||||||
{/if}
|
{/if}
|
||||||
|
{/key}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|||||||
Reference in New Issue
Block a user