From 77ebd93bd387e94476a9e8b98eb4dfdb0b7a75ff Mon Sep 17 00:00:00 2001 From: Alex Grozav Date: Fri, 16 Aug 2024 17:01:10 +0300 Subject: [PATCH] feat(editor): Update canvas control buttons design and behaviour in new canvas (no-changelog) (#10435) Co-authored-by: Elias Meire --- .../src/components/canvas/Canvas.spec.ts | 4 +- .../src/components/canvas/Canvas.vue | 90 ++++++++++--------- .../buttons/CanvasControlButtons.spec.ts | 26 ++++++ .../elements/buttons/CanvasControlButtons.vue | 76 ++++++++++++++++ .../CanvasControlButtons.spec.ts.snap | 25 ++++++ .../src/styles/plugins/_vueflow.scss | 9 +- 6 files changed, 183 insertions(+), 47 deletions(-) create mode 100644 packages/editor-ui/src/components/canvas/elements/buttons/CanvasControlButtons.spec.ts create mode 100644 packages/editor-ui/src/components/canvas/elements/buttons/CanvasControlButtons.vue create mode 100644 packages/editor-ui/src/components/canvas/elements/buttons/__snapshots__/CanvasControlButtons.spec.ts.snap diff --git a/packages/editor-ui/src/components/canvas/Canvas.spec.ts b/packages/editor-ui/src/components/canvas/Canvas.spec.ts index 9a3293738e..86a23e4651 100644 --- a/packages/editor-ui/src/components/canvas/Canvas.spec.ts +++ b/packages/editor-ui/src/components/canvas/Canvas.spec.ts @@ -8,16 +8,16 @@ import { createCanvasConnection, createCanvasNodeElement } from '@/__tests__/dat import { NodeConnectionType } from 'n8n-workflow'; import type { useDeviceSupport } from 'n8n-design-system'; +const matchMedia = global.window.matchMedia; // @ts-expect-error Initialize window object global.window = jsdom.window as unknown as Window & typeof globalThis; +global.window.matchMedia = matchMedia; vi.mock('n8n-design-system', async (importOriginal) => { const actual = await importOriginal(); return { ...actual, useDeviceSupport: vi.fn(() => ({ isCtrlKeyPressed: vi.fn() })) }; }); -vi.mock('@/composables/useDeviceSupport'); - let renderComponent: ReturnType; beforeEach(() => { const pinia = createPinia(); diff --git a/packages/editor-ui/src/components/canvas/Canvas.vue b/packages/editor-ui/src/components/canvas/Canvas.vue index 877bdf0b64..b6440c933e 100644 --- a/packages/editor-ui/src/components/canvas/Canvas.vue +++ b/packages/editor-ui/src/components/canvas/Canvas.vue @@ -1,9 +1,14 @@ + + + diff --git a/packages/editor-ui/src/components/canvas/elements/buttons/__snapshots__/CanvasControlButtons.spec.ts.snap b/packages/editor-ui/src/components/canvas/elements/buttons/__snapshots__/CanvasControlButtons.spec.ts.snap new file mode 100644 index 0000000000..6c9b638b90 --- /dev/null +++ b/packages/editor-ui/src/components/canvas/elements/buttons/__snapshots__/CanvasControlButtons.spec.ts.snap @@ -0,0 +1,25 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`CanvasChatButton > should render correctly 1`] = ` +"
+ + + + + + + + + +
" +`; diff --git a/packages/editor-ui/src/styles/plugins/_vueflow.scss b/packages/editor-ui/src/styles/plugins/_vueflow.scss index 86133f44f3..08ba0e938d 100644 --- a/packages/editor-ui/src/styles/plugins/_vueflow.scss +++ b/packages/editor-ui/src/styles/plugins/_vueflow.scss @@ -7,14 +7,19 @@ } .vue-flow__minimap { + height: 120px; + overflow: hidden; margin-bottom: calc(48px + 2 * var(--spacing-xs)); + border: var(--border-base); + border-radius: var(--border-radius-base); + background: var(--color-background-light); .minimap-node-default { fill: var(--color-foreground-dark); } .minimap-node-n8n-nodes-base-stickyNote { - opacity: 0.05; - fill: var(--color-background-dark); + fill: var(--color-foreground-dark); + opacity: 0.2; } }