mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 14:30:41 +00:00
Side toolbar menu UI updates ## Summary - Currently the template modal is very hidden. Many users do not find it - The current icons are quite aleatory ## Changes **What**: - Add templates shortcut button - Add item label in normal size - Use custom icon Critical design decisions or edge cases that need attention: - Sidebar tabs registered using custom icons will have their associated command registed with an undefined icon (currently only string icons are accepted, not components). I couldn't see anywhere directly using this icon, but we should consider autogenerating an icon font so we can use classes for our custom icons (or locating and updating locations to support both icon types) ## Screenshots (if applicable) Normal mode: <img width="621" height="1034" alt="image" src="https://github.com/user-attachments/assets/c1d1cee2-004e-4ff8-b3fa-197329b0d2ae" /> Small mode: <img width="176" height="325" alt="image" src="https://github.com/user-attachments/assets/3824b8f6-bc96-4e62-aece-f0265113d2e3" /> ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-4946-Update-side-toolbar-menu-24d6d73d365081c5b2bdc0ee8b61dc50) by [Unito](https://www.unito.io) --------- Co-authored-by: github-actions <github-actions@github.com>
88 lines
2.8 KiB
TypeScript
88 lines
2.8 KiB
TypeScript
import { defineStore } from 'pinia'
|
|
import { computed, ref } from 'vue'
|
|
|
|
import { useModelLibrarySidebarTab } from '@/composables/sidebarTabs/useModelLibrarySidebarTab'
|
|
import { useNodeLibrarySidebarTab } from '@/composables/sidebarTabs/useNodeLibrarySidebarTab'
|
|
import { useQueueSidebarTab } from '@/composables/sidebarTabs/useQueueSidebarTab'
|
|
import { useWorkflowsSidebarTab } from '@/composables/sidebarTabs/useWorkflowsSidebarTab'
|
|
import { t, te } from '@/i18n'
|
|
import { useCommandStore } from '@/stores/commandStore'
|
|
import { SidebarTabExtension } from '@/types/extensionTypes'
|
|
|
|
export const useSidebarTabStore = defineStore('sidebarTab', () => {
|
|
const sidebarTabs = ref<SidebarTabExtension[]>([])
|
|
const activeSidebarTabId = ref<string | null>(null)
|
|
|
|
const activeSidebarTab = computed<SidebarTabExtension | null>(() => {
|
|
return (
|
|
sidebarTabs.value.find((tab) => tab.id === activeSidebarTabId.value) ??
|
|
null
|
|
)
|
|
})
|
|
|
|
const toggleSidebarTab = (tabId: string) => {
|
|
activeSidebarTabId.value = activeSidebarTabId.value === tabId ? null : tabId
|
|
}
|
|
|
|
const registerSidebarTab = (tab: SidebarTabExtension) => {
|
|
sidebarTabs.value = [...sidebarTabs.value, tab]
|
|
|
|
// Generate label in format "Toggle X Sidebar"
|
|
const labelFunction = () => {
|
|
const tabTitle = te(tab.title) ? t(tab.title) : tab.title
|
|
return `Toggle ${tabTitle} Sidebar`
|
|
}
|
|
const tooltipFunction = tab.tooltip
|
|
? te(String(tab.tooltip))
|
|
? () => t(String(tab.tooltip))
|
|
: String(tab.tooltip)
|
|
: undefined
|
|
|
|
useCommandStore().registerCommand({
|
|
id: `Workspace.ToggleSidebarTab.${tab.id}`,
|
|
icon: typeof tab.icon === 'string' ? tab.icon : undefined,
|
|
label: labelFunction,
|
|
tooltip: tooltipFunction,
|
|
versionAdded: '1.3.9',
|
|
category: 'view-controls' as const,
|
|
function: () => {
|
|
toggleSidebarTab(tab.id)
|
|
},
|
|
source: 'System'
|
|
})
|
|
}
|
|
|
|
const unregisterSidebarTab = (id: string) => {
|
|
const index = sidebarTabs.value.findIndex((tab) => tab.id === id)
|
|
if (index !== -1) {
|
|
const tab = sidebarTabs.value[index]
|
|
if (tab.type === 'custom' && tab.destroy) {
|
|
tab.destroy()
|
|
}
|
|
const newSidebarTabs = [...sidebarTabs.value]
|
|
newSidebarTabs.splice(index, 1)
|
|
sidebarTabs.value = newSidebarTabs
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Register the core sidebar tabs.
|
|
*/
|
|
const registerCoreSidebarTabs = () => {
|
|
registerSidebarTab(useQueueSidebarTab())
|
|
registerSidebarTab(useNodeLibrarySidebarTab())
|
|
registerSidebarTab(useModelLibrarySidebarTab())
|
|
registerSidebarTab(useWorkflowsSidebarTab())
|
|
}
|
|
|
|
return {
|
|
sidebarTabs,
|
|
activeSidebarTabId,
|
|
activeSidebarTab,
|
|
toggleSidebarTab,
|
|
registerSidebarTab,
|
|
unregisterSidebarTab,
|
|
registerCoreSidebarTabs
|
|
}
|
|
})
|