Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move floating menu to a Vue component #843

Merged
merged 3 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 14 additions & 0 deletions src/components/appMenu/floating/FloatingMenu.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<template>
<div class="floating-menu" ref="container"></div>
</template>

<script setup lang="ts">
import { app } from '@/scripts/app'
import { onMounted, ref } from 'vue'

const container = ref<HTMLDivElement | null>(null)

onMounted(() => {
app.ui.setup(container.value)
})
</script>
2 changes: 2 additions & 0 deletions src/components/graph/GraphCanvas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
</template>
</LiteGraphCanvasSplitterOverlay>
<TitleEditor />
<FloatingMenu />
<canvas ref="canvasRef" id="graph-canvas" tabindex="1" />
</teleport>
<NodeSearchboxPopover />
Expand All @@ -18,6 +19,7 @@ import SideToolbar from '@/components/sidebar/SideToolbar.vue'
import LiteGraphCanvasSplitterOverlay from '@/components/LiteGraphCanvasSplitterOverlay.vue'
import NodeSearchboxPopover from '@/components/searchbox/NodeSearchBoxPopover.vue'
import NodeTooltip from '@/components/graph/NodeTooltip.vue'
import FloatingMenu from '@/components/appMenu/floating/FloatingMenu.vue'
import { ref, computed, onUnmounted, onMounted, watchEffect } from 'vue'
import { app as comfyApp } from '@/scripts/app'
import { useSettingStore } from '@/stores/settingStore'
Expand Down
12 changes: 10 additions & 2 deletions src/scripts/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,13 @@ export class ComfyUI {
this.history.update()
})

// For testing. Legacy ui tests don't have vue app initialized.
if (!app.vueAppReady) {
this.setup(document.body)
}
}

setup(containerElement: HTMLElement) {
const confirmClear = this.settings.addSetting({
id: 'Comfy.ConfirmClear',
category: ['Comfy', 'Workflow', 'ConfirmClear'],
Expand Down Expand Up @@ -497,7 +504,7 @@ export class ComfyUI {
this.menuHamburger = $el(
'div.comfy-menu-hamburger',
{
parent: document.body,
parent: containerElement,
onclick: () => {
this.menuContainer.style.display = 'block'
this.menuHamburger.style.display = 'none'
Expand All @@ -506,7 +513,7 @@ export class ComfyUI {
[$el('div'), $el('div'), $el('div')]
) as HTMLDivElement

this.menuContainer = $el('div.comfy-menu', { parent: document.body }, [
this.menuContainer = $el('div.comfy-menu', { parent: containerElement }, [
$el(
'div.drag-handle.comfy-menu-header',
{
Expand Down Expand Up @@ -730,6 +737,7 @@ export class ComfyUI {
$el('button', {
id: 'comfy-clipspace-button',
textContent: 'Clipspace',
// @ts-expect-error Move to ComfyApp
onclick: () => app.openClipspace()
}),
$el('button', {
Expand Down
Loading