Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 10 additions & 4 deletions src/composables/graph/useGraphNodeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type { NodeId } from '@/renderer/core/layout/types'
import type { InputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2'
import { isDOMWidget } from '@/scripts/domWidget'
import { useNodeDefStore } from '@/stores/nodeDefStore'
import type { WidgetValue } from '@/types/simplifiedWidget'
import type { BorderColor, WidgetValue } from '@/types/simplifiedWidget'

import type {
LGraph,
Expand All @@ -47,6 +47,7 @@ export interface SafeWidgetData {
spec?: InputSpec
slotMetadata?: WidgetSlotMetadata
isDOMWidget?: boolean
borderColor?: BorderColor
}

export interface VueNodeData {
Expand Down Expand Up @@ -104,17 +105,22 @@ export function safeWidgetMapper(
}
const spec = nodeDefStore.getInputSpecForWidget(node, widget.name)
const slotInfo = slotMetadata.get(widget.name)
const borderColor =
(widget.promoted && 'promoted') ||
(widget.advanced && 'advanced') ||
undefined
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Could this happen lower down?
Maybe in NodeWidgets?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm specifically trying to limit the runaway growth of our SimplifiedWidgets object.

I'd prefer to move in the other direction and convert things into an actual color here, but tailwind doesn't allow that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I prefer ternary chains to short-circuit logic.
It's usually safer and feels clearer in intent.

Suggested change
const borderColor =
(widget.promoted && 'promoted') ||
(widget.advanced && 'advanced') ||
undefined
const borderColor =
widget.promoted ? 'promoted' :
widget.advanced ? 'advanced' :
undefined


return {
name: widget.name,
type: widget.type,
value: value,
borderColor,
callback: widget.callback,
isDOMWidget: isDOMWidget(widget),
label: widget.label,
options: widget.options,
callback: widget.callback,
spec,
slotMetadata: slotInfo,
isDOMWidget: isDOMWidget(widget)
slotMetadata: slotInfo
}
} catch (error) {
return {
Expand Down
17 changes: 15 additions & 2 deletions src/renderer/extensions/vueNodes/components/NodeWidgets.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,14 @@
:model-value="widget.value"
:node-id="nodeData?.id != null ? String(nodeData.id) : ''"
:node-type="nodeType"
class="flex-1 col-span-2"
:class="
cn(
'flex-1 col-span-2',
widget.borderColor && 'border rounded-lg',
widget.borderColor === 'promoted' && 'border-fuchsia-600/80',
widget.borderColor === 'advanced' && 'border-azure-400/80'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should probably be theme colors.

Also, could the whole composite set of classes be joined when the widget's status is polled and just put unconditionally?

)
"
@update:model-value="widget.updateHandler"
/>
</div>
Expand Down Expand Up @@ -86,7 +93,11 @@ import {
shouldExpand,
shouldRenderAsVue
} from '@/renderer/extensions/vueNodes/widgets/registry/widgetRegistry'
import type { SimplifiedWidget, WidgetValue } from '@/types/simplifiedWidget'
import type {
BorderColor,
SimplifiedWidget,
WidgetValue
} from '@/types/simplifiedWidget'
import { cn } from '@/utils/tailwindUtil'

import InputSlot from './InputSlot.vue'
Expand Down Expand Up @@ -125,6 +136,7 @@ interface ProcessedWidget {
name: string
type: string
vueComponent: Component
borderColor?: BorderColor
simplified: SimplifiedWidget
value: WidgetValue
updateHandler: (value: WidgetValue) => void
Expand Down Expand Up @@ -184,6 +196,7 @@ const processedWidgets = computed((): ProcessedWidget[] => {
vueComponent,
simplified,
value: widget.value,
borderColor: widget.borderColor,
updateHandler,
tooltipConfig,
slotMetadata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const hideLayoutField = inject<boolean>('hideLayoutField', false)

<template>
<div
class="grid grid-cols-subgrid h-7.5 min-w-0 items-center justify-between gap-1"
class="grid grid-cols-subgrid grid-rows-[30px] min-w-0 items-center justify-between gap-1 -ml-1 pl-1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When would a widget comprise multiple rows?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They don't. Widgets were offset because the row height wasn't being properly inherited.
image
image

>
<div
v-if="!hideLayoutField"
Expand Down
2 changes: 2 additions & 0 deletions src/types/simplifiedWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export type WidgetValue =
| void
| File[]

export type BorderColor = 'advanced' | 'promoted'

export interface SimplifiedWidget<
T extends WidgetValue = WidgetValue,
O = Record<string, any>
Expand Down