From b7facfdf936de688d5f1ecef40a300482ceafb3b Mon Sep 17 00:00:00 2001 From: Danila Poyarkov Date: Tue, 30 Jun 2026 19:27:38 +0300 Subject: [PATCH] refactor(app): split layer tree rows --- packages/vue/src/index.ts | 2 +- .../vue/src/primitives/LayerTree/index.ts | 6 +- src/components/LayerTree.vue | 250 ------------------ src/components/LayerTree/LayerTree.vue | 156 +++++++++++ src/components/LayerTree/LayerTreeActions.vue | 64 +++++ .../LayerTree/LayerTreeDisclosure.vue | 23 ++ .../LayerTree/LayerTreeDropIndicator.vue | 34 +++ src/components/LayerTree/LayerTreeNodeRow.vue | 68 +++++ .../LayerTree/LayerTreeRenameRow.vue | 43 +++ src/components/LayerTree/types.ts | 22 ++ src/components/LayersPanel.vue | 2 +- src/components/MobileDrawer.vue | 2 +- 12 files changed, 418 insertions(+), 254 deletions(-) delete mode 100644 src/components/LayerTree.vue create mode 100644 src/components/LayerTree/LayerTree.vue create mode 100644 src/components/LayerTree/LayerTreeActions.vue create mode 100644 src/components/LayerTree/LayerTreeDisclosure.vue create mode 100644 src/components/LayerTree/LayerTreeDropIndicator.vue create mode 100644 src/components/LayerTree/LayerTreeNodeRow.vue create mode 100644 src/components/LayerTree/LayerTreeRenameRow.vue create mode 100644 src/components/LayerTree/types.ts diff --git a/packages/vue/src/index.ts b/packages/vue/src/index.ts index b1fc96051..093acb31b 100644 --- a/packages/vue/src/index.ts +++ b/packages/vue/src/index.ts @@ -134,7 +134,7 @@ export { GradientEditorStop } from '#vue/primitives/GradientEditor' export { LayerTreeRoot, LayerTreeItem, useLayerTree } from '#vue/primitives/LayerTree' -export type { LayerTreeContext, LayerNode } from '#vue/primitives/LayerTree' +export type { LayerDragInstruction, LayerTreeContext, LayerNode } from '#vue/primitives/LayerTree' export { LayoutControlsRoot, useLayoutControlsContext } from '#vue/primitives/LayoutControls' export type { LayoutControlsContext } from '#vue/primitives/LayoutControls' export { AppearanceControlsRoot } from '#vue/primitives/AppearanceControls' diff --git a/packages/vue/src/primitives/LayerTree/index.ts b/packages/vue/src/primitives/LayerTree/index.ts index 3285bd2f5..c4d9a166e 100644 --- a/packages/vue/src/primitives/LayerTree/index.ts +++ b/packages/vue/src/primitives/LayerTree/index.ts @@ -1,4 +1,8 @@ export { default as LayerTreeRoot } from '#vue/primitives/LayerTree/LayerTreeRoot.vue' export { default as LayerTreeItem } from '#vue/primitives/LayerTree/LayerTreeItem.vue' export { useLayerTree } from '#vue/primitives/LayerTree/context' -export type { LayerTreeContext, LayerNode } from '#vue/primitives/LayerTree/context' +export type { + LayerDragInstruction, + LayerTreeContext, + LayerNode +} from '#vue/primitives/LayerTree/context' diff --git a/src/components/LayerTree.vue b/src/components/LayerTree.vue deleted file mode 100644 index 89e612f7d..000000000 --- a/src/components/LayerTree.vue +++ /dev/null @@ -1,250 +0,0 @@ - - - diff --git a/src/components/LayerTree/LayerTree.vue b/src/components/LayerTree/LayerTree.vue new file mode 100644 index 000000000..a83479754 --- /dev/null +++ b/src/components/LayerTree/LayerTree.vue @@ -0,0 +1,156 @@ + + + diff --git a/src/components/LayerTree/LayerTreeActions.vue b/src/components/LayerTree/LayerTreeActions.vue new file mode 100644 index 000000000..c7436f809 --- /dev/null +++ b/src/components/LayerTree/LayerTreeActions.vue @@ -0,0 +1,64 @@ + + + diff --git a/src/components/LayerTree/LayerTreeDisclosure.vue b/src/components/LayerTree/LayerTreeDisclosure.vue new file mode 100644 index 000000000..5cae6f01f --- /dev/null +++ b/src/components/LayerTree/LayerTreeDisclosure.vue @@ -0,0 +1,23 @@ + + + diff --git a/src/components/LayerTree/LayerTreeDropIndicator.vue b/src/components/LayerTree/LayerTreeDropIndicator.vue new file mode 100644 index 000000000..54ee38e58 --- /dev/null +++ b/src/components/LayerTree/LayerTreeDropIndicator.vue @@ -0,0 +1,34 @@ + + + diff --git a/src/components/LayerTree/LayerTreeNodeRow.vue b/src/components/LayerTree/LayerTreeNodeRow.vue new file mode 100644 index 000000000..23cfa42b1 --- /dev/null +++ b/src/components/LayerTree/LayerTreeNodeRow.vue @@ -0,0 +1,68 @@ + + + diff --git a/src/components/LayerTree/LayerTreeRenameRow.vue b/src/components/LayerTree/LayerTreeRenameRow.vue new file mode 100644 index 000000000..cdc354f35 --- /dev/null +++ b/src/components/LayerTree/LayerTreeRenameRow.vue @@ -0,0 +1,43 @@ + + + diff --git a/src/components/LayerTree/types.ts b/src/components/LayerTree/types.ts new file mode 100644 index 000000000..c4634d7ad --- /dev/null +++ b/src/components/LayerTree/types.ts @@ -0,0 +1,22 @@ +import type { LayerDragInstruction } from '@open-pencil/vue' + +export interface LayerTreeItemActions { + select: (additive: boolean) => void + toggleExpand: () => void + toggleVisibility: () => void + toggleLock: () => void + rename: (name: string) => void +} + +export interface LayerTreeChrome { + draggingId: string | null + instruction: LayerDragInstruction | null + instructionTargetId: string | null + indent: number +} + +export interface LayerRenameControls { + commit: (id: string, event: Event) => void + onKeydown: (event: KeyboardEvent) => void + focusInput: (input: HTMLInputElement) => Promise +} diff --git a/src/components/LayersPanel.vue b/src/components/LayersPanel.vue index 682fc1de4..8b6ddc6ea 100644 --- a/src/components/LayersPanel.vue +++ b/src/components/LayersPanel.vue @@ -6,7 +6,7 @@ import { useI18n } from '@open-pencil/vue' import AppMenu from './AppMenu.vue' import AssetsPanel from './AssetsPanel.vue' -import LayerTree from './LayerTree.vue' +import LayerTree from './LayerTree/LayerTree.vue' import PagesPanel from './PagesPanel.vue' const { menu, panels } = useI18n() diff --git a/src/components/MobileDrawer.vue b/src/components/MobileDrawer.vue index e894422fb..fadd1902e 100644 --- a/src/components/MobileDrawer.vue +++ b/src/components/MobileDrawer.vue @@ -8,7 +8,7 @@ import { computed, ref } from 'vue' import ChatPanel from './ChatPanel.vue' import CodePanel from './CodePanel.vue' import DesignPanel from './DesignPanel.vue' -import LayerTree from './LayerTree.vue' +import LayerTree from './LayerTree/LayerTree.vue' import PagesPanel from './PagesPanel.vue' import { DRAWER_SPRING_DAMPING,