Title a collapsed Variables or Properties node by what it does
Collapsed, the node reads "Set 2 variables", "Get width" or "No properties"; expanded it is always "Variables" / "Properties". The Properties node shows its object type (and behavior) as a line under the title instead. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
58f19a3451
commit
0376ae175d
11 files changed
+182
-69
No files matched your search
@@ -51,6 +51,17 @@ export function declaredOn(
|
||||
return def.declaresPorts === side ? [...ports] : [];
|
||||
}
|
||||
|
||||
/** What a collapsed Variables or Properties node does, since its ports are out of sight. */
|
||||
export function collapsedTitle(ports: readonly DeclaredPort[], noun: string): string {
|
||||
const set = ports.filter((p) => p.write);
|
||||
const get = ports.filter((p) => !p.write);
|
||||
if (set.length > 1) return `Set ${set.length} ${noun}`;
|
||||
if (get.length > 1) return `Get ${get.length} ${noun}`;
|
||||
if (set[0]) return `Set ${set[0].key}`;
|
||||
if (get[0]) return `Get ${get[0].key}`;
|
||||
return `No ${noun}`;
|
||||
}
|
||||
|
||||
/** The single start (or end) node of a graph; a second one is ignored. */
|
||||
export function terminalNode(graph: Graph, type: string): GraphNode | undefined {
|
||||
return graph.nodes.find((n) => n.type === type);
|
||||
|
||||
Reference in new issue
Block a user