Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Use svg for vue mode
  • Loading branch information
AustinMroz committed Dec 16, 2025
commit cf27bdef49987799732ff47d3432b6e2fa444964
19 changes: 19 additions & 0 deletions packages/design-system/src/icons/nodeSlot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions packages/design-system/src/icons/nodeSlot2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions packages/design-system/src/icons/nodeSlot3.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 36 additions & 27 deletions src/renderer/extensions/vueNodes/components/SlotConnectionDot.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { useTemplateRef } from 'vue'
import { computed, useTemplateRef } from 'vue'

import { getSlotColor } from '@/constants/slotColors'
import type { INodeSlot } from '@/lib/litegraph/src/litegraph'
Expand All @@ -15,29 +15,31 @@ const props = defineProps<{

const slotElRef = useTemplateRef('slot-el')

function getStyle() {
if (props.hasError) return { backgroundColor: 'var(--color-error)' }
function getTypes() {
if (props.hasError) return ['var(--color-error)']
//TODO Support connected/disconnected colors?
if (!props.slotData) return { backgroundColor: getSlotColor() }
if (!props.slotData) return [getSlotColor()]
const typesSet = new Set(
`${props.slotData.type}`.split(',').map(getSlotColor)
)
const types = [...typesSet].slice(0, 3)
if (types.length === 1) return { backgroundColor: types[0] }
const angle = 360 / types.length
const slices = types.map(
(type, idx) => `${type} ${angle * idx}deg ${angle * (idx + 1)}deg`
)
return {
background: `conic-gradient(${slices.join(',')})`,
backgroundOrigin: 'border-box'
}
return [...typesSet].slice(0, 3)
}
const style = getStyle()
const types = getTypes()

defineExpose({
slotElRef
})

const slotClass = computed(() =>
cn(
'bg-slate-300 rounded-full slot-dot',
'transition-all duration-150',
'border border-solid border-node-component-slot-dot-outline',
props.multi
? 'w-3 h-6'
: 'size-3 cursor-crosshair group-hover/slot:[--node-component-slot-dot-outline-opacity-mult:5] group-hover/slot:scale-125'
)
)
</script>

<template>
Expand All @@ -50,19 +52,26 @@ defineExpose({
"
>
<div
v-if="types.length === 1"
ref="slot-el"
class="slot-dot"
:style
:class="
cn(
'bg-slate-300 rounded-full',
'transition-all duration-150',
'border border-solid border-node-component-slot-dot-outline',
!multi &&
'cursor-crosshair group-hover/slot:[--node-component-slot-dot-outline-opacity-mult:5] group-hover/slot:scale-125',
multi ? 'w-3 h-6' : 'size-3'
)
"
:style="{ backgroundColor: types[0] }"
:class="slotClass"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this pulled out of the template?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's used twice. I wanted to avoid the extra lines and the chance that the two copies become desynced.

I'm not 100% happy with how the border outline or scaling of optional multi-type inputs work and would like to eventually separate out/re-inline the class, but the amount of extra work this would require is not something I can justify right now.

/>
<div
v-else
ref="slot-el"
:style="{
'--type1': types[0],
'--type2': types[1],
'--type3': types[2]
}"
:class="slotClass"
>
<i-comfy:node-slot2
v-if="types.length === 2"
class="size-full -translate-y-1/2"
/>
<i-comfy:node-slot3 v-else class="size-full -translate-y-1/2" />
</div>
</div>
</template>
Loading