Skip to content

Commit

Permalink
Horizontal scroll workflow tabs on overflow (#2188)
Browse files Browse the repository at this point in the history
  • Loading branch information
huchenlei authored Jan 7, 2025
1 parent 07000a2 commit 1c4481c
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 29 deletions.
5 changes: 3 additions & 2 deletions src/components/topbar/TopMenubar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
<h1 class="comfyui-logo mx-2">ComfyUI</h1>
<CommandMenubar />
<Divider layout="vertical" class="mx-2" />
<div class="flex-grow">
<div class="flex-grow min-w-0">
<WorkflowTabs v-if="workflowTabsPosition === 'Topbar'" />
</div>
<div class="comfyui-menu-right" ref="menuRight"></div>
<Actionbar />
<BottomPanelToggleButton />
<BottomPanelToggleButton class="flex-shrink-0" />
<Button
class="flex-shrink-0"
icon="pi pi-bars"
severity="secondary"
text
Expand Down
74 changes: 47 additions & 27 deletions src/components/topbar/WorkflowTabs.vue
Original file line number Diff line number Diff line change
@@ -1,36 +1,47 @@
<template>
<SelectButton
class="workflow-tabs bg-transparent inline"
:class="props.class"
:modelValue="selectedWorkflow"
@update:modelValue="onWorkflowChange"
:options="options"
optionLabel="label"
dataKey="value"
>
<template #option="{ option }">
<WorkflowTab
@contextmenu="showContextMenu($event, option)"
@click.middle="onCloseWorkflow(option)"
:workflow-option="option"
/>
</template>
</SelectButton>
<Button
v-tooltip="{ value: $t('sideToolbar.newBlankWorkflow'), showDelay: 300 }"
class="new-blank-workflow-button"
icon="pi pi-plus"
text
severity="secondary"
:aria-label="$t('sideToolbar.newBlankWorkflow')"
@click="() => commandStore.execute('Comfy.NewBlankWorkflow')"
/>
<ContextMenu ref="menu" :model="contextMenuItems" />
<div class="workflow-tabs-container flex flex-row w-full">
<ScrollPanel
class="overflow-x-hidden"
:pt:content="{
class: 'p-0 w-full',
onwheel: handleWheel
}"
>
<SelectButton
class="workflow-tabs bg-transparent"
:class="props.class"
:modelValue="selectedWorkflow"
@update:modelValue="onWorkflowChange"
:options="options"
optionLabel="label"
dataKey="value"
>
<template #option="{ option }">
<WorkflowTab
@contextmenu="showContextMenu($event, option)"
@click.middle="onCloseWorkflow(option)"
:workflow-option="option"
/>
</template>
</SelectButton>
</ScrollPanel>
<Button
v-tooltip="{ value: $t('sideToolbar.newBlankWorkflow'), showDelay: 300 }"
class="new-blank-workflow-button flex-shrink-0"
icon="pi pi-plus"
text
severity="secondary"
:aria-label="$t('sideToolbar.newBlankWorkflow')"
@click="() => commandStore.execute('Comfy.NewBlankWorkflow')"
/>
<ContextMenu ref="menu" :model="contextMenuItems" />
</div>
</template>

<script setup lang="ts">
import Button from 'primevue/button'
import ContextMenu from 'primevue/contextmenu'
import ScrollPanel from 'primevue/scrollpanel'
import SelectButton from 'primevue/selectbutton'
import { computed, ref } from 'vue'
import { useI18n } from 'vue-i18n'
Expand Down Expand Up @@ -146,6 +157,15 @@ const contextMenuItems = computed(() => {
]
})
const commandStore = useCommandStore()
// Horizontal scroll on wheel
const handleWheel = (event: WheelEvent) => {
const scrollElement = event.currentTarget as HTMLElement
const scrollAmount = event.deltaX || event.deltaY
scrollElement.scroll({
left: scrollElement.scrollLeft + scrollAmount
})
}
</script>

<style scoped>
Expand Down

0 comments on commit 1c4481c

Please sign in to comment.