From 0cadd1e0627eafde8afb7cb8c66d8930e48e7719 Mon Sep 17 00:00:00 2001 From: Z8MB1E Date: Tue, 6 Oct 2026 12:43:02 -0400 Subject: [PATCH] feat(npc-dialogue): taller flow canvas plus expand-to-screen toggle Raise the default editor height from h-96 to 60vh (min 28rem) and add an Expand/Shrink toolbar toggle that floats the whole editor over the document form, filling the viewport right of the admin sidebar via the shell's --nav-width/--app-header-height vars. Esc collapses it unless the node dialog or context menu is open. --- src/app/(payload)/custom.scss | 20 ++++++++++ .../admin/npc-dialogue/NpcDialogueEditor.tsx | 37 +++++++++++++++++-- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/src/app/(payload)/custom.scss b/src/app/(payload)/custom.scss index 7d50e487..baf9d4bd 100644 --- a/src/app/(payload)/custom.scss +++ b/src/app/(payload)/custom.scss @@ -61,6 +61,26 @@ } } +/* NPC dialogue editor: "expand" mode floats the whole editor (toolbar + + canvas) over the document form, filling the viewport to the right of the + admin sidebar. Offsets ride the admin shell's own CSS vars so the overlay + tracks the sidebar width and header height; z-index stays below the + status toasts (--z-status: 40) and Radix dialogs (z-50). */ +.npc-dialogue-editor--expanded { + position: fixed; + top: var(--app-header-height); + left: var(--nav-width); + right: 0; + bottom: 0; + z-index: calc(var(--z-modal) - 1); + + /* Small breakpoint: --nav-width becomes 100vw (off-canvas nav), which would + push the overlay off screen. */ + @media (max-width: 1024px) { + left: 0; + } +} + /* Tech Tree: dark thin scrollbars for the panel and its dropdowns. */ .tech-tree-scroll { scrollbar-width: thin; diff --git a/src/components/admin/npc-dialogue/NpcDialogueEditor.tsx b/src/components/admin/npc-dialogue/NpcDialogueEditor.tsx index 002f3ad9..91d50f1a 100644 --- a/src/components/admin/npc-dialogue/NpcDialogueEditor.tsx +++ b/src/components/admin/npc-dialogue/NpcDialogueEditor.tsx @@ -10,6 +10,7 @@ import { useNodesState, } from "@xyflow/react"; import "@xyflow/react/dist/style.css"; +import { Maximize2, Minimize2 } from "lucide-react"; import { useField } from "@payloadcms/ui"; @@ -66,6 +67,7 @@ export function NpcDialogueEditor() { const [nodes, setNodes, onNodesChange] = useNodesState(initial.nodes as Node[]); const [editingNodeId, setEditingNodeId] = useState(null); const [contextMenu, setContextMenu] = useState(null); + const [expanded, setExpanded] = useState(false); const lastSerialized = useRef(""); const menuRef = useRef(null); @@ -224,11 +226,26 @@ export function NpcDialogueEditor() { }; }, [contextMenu, closeMenu]); + // Escape collapses the expanded editor, but only when nothing is layered + // on top of it (the node dialog or the context menu claim the key first). + useEffect(() => { + if (!expanded) return; + const onKey = (e: KeyboardEvent) => { + if (e.key === "Escape" && !contextMenu && editingNodeId === null) setExpanded(false); + }; + window.addEventListener("keydown", onKey); + return () => window.removeEventListener("keydown", onKey); + }, [expanded, contextMenu, editingNodeId]); + const buttonClass = "px-2 py-1 text-[10px] font-medium rounded border transition-colors cursor-pointer"; return ( -
+
Nodes @@ -273,6 +290,16 @@ export function NpcDialogueEditor() { {nodes.length} node{nodes.length !== 1 ? "s" : ""} +
{!validation.valid && ( @@ -281,7 +308,11 @@ export function NpcDialogueEditor() {
)} -
+
Click a node to edit. Right-click to delete. Drag from a node's right handle onto another node to connect them (a choice node gains a new choice; dialogue and event nodes - re-point their continuation). + re-point their continuation). Use Expand to fill the screen (Esc to shrink).

{contextMenu && (