Skip to content
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
28 changes: 28 additions & 0 deletions browser_tests/fixtures/utils/workspaceInset.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import type { Locator, Page } from '@playwright/test'

import { WORKSPACE_INSET_RIGHT } from '@/composables/useWorkspaceInset'
import { comfyExpect } from '@e2e/fixtures/utils/customMatchers'

export async function expectDialogBoundsWithDockedPanel(
page: Page,
dialog: Locator,
{ panelWidth, x }: { panelWidth: number; x: number }
): Promise<void> {
await comfyExpect
.poll(() => dialog.evaluate((element) => element.getAnimations().length))
.toBe(0)
const withoutPanel = await dialog.boundingBox()
if (!withoutPanel) throw new Error('Dialog is not laid out')

await page.evaluate(
({ property, panelWidth }) => {
document.documentElement.style.setProperty(property, `${panelWidth}px`)
},
{ property: WORKSPACE_INSET_RIGHT, panelWidth }
)

await comfyExpect(dialog).toHaveBounds(
{ ...withoutPanel, x },
{ numDigits: 1 }
)
}
54 changes: 54 additions & 0 deletions browser_tests/tests/dialogs/dialogAgentPanelInset.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import {
comfyExpect as expect,
comfyPageFixture as test
} from '@e2e/fixtures/ComfyPage'
import { expectDialogBoundsWithDockedPanel } from '@e2e/fixtures/utils/workspaceInset'

test.describe('Dialog layout with a docked Agent panel', () => {
for (const { viewportWidth, x, outcome } of [
{ viewportWidth: 1440, x: 8, outcome: 'covers the panel from the gutter' },
{ viewportWidth: 1920, x: 50, outcome: 'centres beside the panel' }
]) {
test.describe(`at a ${viewportWidth}px viewport`, () => {
test.use({ viewport: { width: viewportWidth, height: 800 } })

test(`Templates browser keeps its size and ${outcome}`, async ({
comfyPage
}) => {
await comfyPage.command.executeCommand('Comfy.BrowseTemplates')
await expect(comfyPage.templates.content).toBeVisible()

await expectDialogBoundsWithDockedPanel(
comfyPage.page,
comfyPage.templatesDialog.root,
{ panelWidth: 420, x }
)
})
})
}

test.describe('at the sm breakpoint', () => {
test.use({ viewport: { width: 640, height: 800 } })

test('a size-variant dialog keeps its width and stops at the gutter', async ({
comfyPage
}) => {
await comfyPage.page.evaluate(() => {
window
.app!.extensionManager.dialog.confirm({
title: 'Confirm',
type: 'default',
message: 'Does this dialog keep its width?'
})
.catch(() => {})
})
Comment thread
christian-byrne marked this conversation as resolved.
Resolved
await expect(comfyPage.confirmDialog.root).toBeVisible()

await expectDialogBoundsWithDockedPanel(
comfyPage.page,
comfyPage.confirmDialog.root,
{ panelWidth: 420, x: 8 }
)
})
})
})
17 changes: 11 additions & 6 deletions src/components/ui/dialog/dialog.variants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ export const dialogContentVariants = cva({
base: 'fixed z-1700 flex flex-col rounded-lg border border-border-subtle bg-base-background shadow-lg outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95',
variants: {
size: {
sm: 'sm:max-w-[min(24rem,calc(100vw-var(--workspace-inset-right,0px)-1rem))]',
md: 'sm:max-w-[min(36rem,calc(100vw-var(--workspace-inset-right,0px)-1rem))]',
lg: 'sm:max-w-[min(48rem,calc(100vw-var(--workspace-inset-right,0px)-1rem))]',
xl: 'sm:max-w-[min(64rem,calc(100vw-var(--workspace-inset-right,0px)-1rem))]',
full: 'sm:max-w-[calc(100vw-var(--workspace-inset-right,0px)-1rem)]'
sm: 'sm:max-w-96',
md: 'sm:max-w-xl',
lg: 'sm:max-w-3xl',
xl: 'sm:max-w-5xl',
full: 'sm:max-w-[calc(100vw-1rem)]'
Comment thread
christian-byrne marked this conversation as resolved.
Resolved
},
maximized: {
true: 'inset-2 top-2 left-2 size-auto max-h-none max-w-none sm:max-w-none',
false:
'top-1/2 left-[calc(50%-var(--workspace-inset-right,0px)/2)] max-h-[85vh] w-[calc(100vw-1rem)] -translate-1/2'
'top-1/2 left-1/2 max-h-[85vh] w-[calc(100vw-1rem)] translate-x-[max(calc(min(0.5rem,100vw-100%)-50vw),calc(-50%-var(--workspace-inset-right,0px)/2))] -translate-y-1/2'
}
},
defaultVariants: {
Expand All @@ -36,3 +36,8 @@ const sizes = [
] as const satisfies Array<DialogContentSize>

export const FOR_STORIES = { sizes } as const

export const HUG_CONTENT_CLASS =
'w-fit max-w-[calc(100vw-1rem)] sm:max-w-[calc(100vw-1rem)]'

export const SELF_STYLED_PANEL_CONTENT_CLASS = `${HUG_CONTENT_CLASS} border-none bg-transparent shadow-none`
4 changes: 2 additions & 2 deletions src/platform/assets/composables/useAssetBrowserDialog.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { SELF_STYLED_PANEL_CONTENT_CLASS } from '@/components/ui/dialog/dialog.variants'
import AssetBrowserModal from '@/platform/assets/components/AssetBrowserModal.vue'
import type { AssetItem } from '@/platform/assets/schemas/assetSchema'
import { useDialogService } from '@/services/dialogService'
Expand Down Expand Up @@ -25,8 +26,7 @@ interface BrowseOptions {

const DIALOG_KEY = 'global-asset-browser'
const ASSET_BROWSER_DIALOG_PROPS = {
contentClass:
'w-fit max-w-[calc(100vw-var(--workspace-inset-right,0px)-1rem)] sm:max-w-[calc(100vw-var(--workspace-inset-right,0px)-1rem)] border-none bg-transparent shadow-none'
contentClass: SELF_STYLED_PANEL_CONTENT_CLASS
} satisfies DialogComponentProps

export const useAssetBrowserDialog = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ export function useShareDialog() {
onClose: hide
},
dialogComponentProps: {
contentClass:
'sm:max-w-[min(36rem,calc(100vw-var(--workspace-inset-right,0px)-1rem))] rounded-2xl overflow-hidden'
contentClass: 'rounded-2xl overflow-hidden'
}
})
}
Expand Down
25 changes: 6 additions & 19 deletions src/services/dialogService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import ConfirmationDialogContent from '@/components/dialog/content/ConfirmationD
import ErrorDialogContent from '@/components/dialog/content/ErrorDialogContent.vue'
import PromptDialogContent from '@/components/dialog/content/PromptDialogContent.vue'
import TopUpCreditsDialogContentLegacy from '@/components/dialog/content/TopUpCreditsDialogContentLegacy.vue'
import {
HUG_CONTENT_CLASS,
SELF_STYLED_PANEL_CONTENT_CLASS
} from '@/components/ui/dialog/dialog.variants'
import InsufficientCreditsMemberDialog from '@/platform/workspace/components/InsufficientCreditsMemberDialog.vue'
import TopUpCreditsDialogContentWorkspace from '@/platform/workspace/components/TopUpCreditsDialogContentWorkspace.vue'
import { useBillingCapabilities } from '@/platform/workspace/composables/useBillingCapabilities'
Expand Down Expand Up @@ -47,20 +51,6 @@ const lazyCloudNotificationContent = () =>
const lazyPublishDialog = () =>
import('@/platform/workflow/sharing/components/publish/ComfyHubPublishDialog.vue')

/**
* Shrink-wrap the Reka DialogContent around the content's intrinsic width,
* like the auto-sized PrimeVue root it replaces.
*/
const HUG_CONTENT_CLASS =
'w-fit max-w-[calc(100vw-1rem)] sm:max-w-[calc(100vw-1rem)]'

/**
* Reka chrome for headless dialogs whose content draws its own panel
* (background/border/rounding) — neutralize the DialogContent box and
* shrink-wrap it around the content.
*/
const SELF_STYLED_PANEL_CONTENT_CLASS = `${HUG_CONTENT_CLASS} border-none bg-transparent shadow-none`

// A type alias, not an interface: `showDialog`'s props are index-signature
// typed, and only object literal types get an implicit index signature.
type TopUpCreditsDialogOptions = {
Expand Down Expand Up @@ -617,10 +607,7 @@ export const useDialogService = () => {
dialogComponentProps: {
renderer: 'reka',
closable: true,
// Contents bring their own width and separators — shrink-wrap the
// chrome and zero the section padding.
contentClass:
'w-fit max-w-[calc(100vw-var(--workspace-inset-right,0px)-1rem)] sm:max-w-[calc(100vw-var(--workspace-inset-right,0px)-1rem)] border-border-default',
contentClass: `${HUG_CONTENT_CLASS} border-border-default`,
headerClass: 'p-0',
bodyClass: 'p-0 overflow-y-hidden',
footerClass: 'p-0',
Expand Down Expand Up @@ -1044,7 +1031,7 @@ export const useDialogService = () => {
dialogComponentProps: {
closable: false,
contentClass:
'w-170 max-w-[calc(100vw-var(--workspace-inset-right,0px)-1rem)] sm:max-w-[min(42.5rem,calc(100vw-var(--workspace-inset-right,0px)-1rem))] rounded-2xl overflow-hidden',
'w-170 max-w-[calc(100vw-1rem)] sm:max-w-[calc(100vw-1rem)] rounded-2xl overflow-hidden',
onRemoved: () => resolve()
}
})
Expand Down
Loading