From 5cab3d2101b7de711d8c26d849094ac6c30bae4e Mon Sep 17 00:00:00 2001 From: Roger Barnes Date: Wed, 18 Nov 2026 14:23:12 +1100 Subject: [PATCH 1/4] Rename NodeCard to NodeComponent It draws a node in either style, card or shape, so "card" named only one of them. The term is defined in docs/concepts.md. --- docs/architecture.md | 4 ++-- docs/concepts.md | 4 ++++ packages/map-views/src/components/GraphLayout.tsx | 4 ++-- packages/map-views/src/components/LandscapeLayout.tsx | 4 ++-- packages/map-views/src/components/NeighbourhoodLayout.tsx | 4 ++-- .../src/components/{NodeCard.tsx => NodeComponent.tsx} | 2 +- packages/map-views/src/components/TreeLayout.tsx | 4 ++-- packages/map-views/src/components/XYLayout.tsx | 6 +++--- packages/map-views/src/components/annotations-context.ts | 2 +- .../tests/{node-card.test.tsx => node-component.test.tsx} | 2 +- 10 files changed, 20 insertions(+), 16 deletions(-) rename packages/map-views/src/components/{NodeCard.tsx => NodeComponent.tsx} (98%) rename packages/map-views/tests/{node-card.test.tsx => node-component.test.tsx} (96%) diff --git a/docs/architecture.md b/docs/architecture.md index c7b5a78..c0579cd 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -18,7 +18,7 @@ All but the last two rows are folders of `packages/map-views/src`. | Module | Holds | May import | |---|---|---| | `core` | Definitions and parameters, annotations, and each layout's settings schema and projection, if it has one (`core/layouts//`). Runs in a browser, Node or a worker | Types from structured-context. No React, DOM or Node | -| `components` | `MapView` and what it draws with: a component per layout, node cards, the connector overlay, parameter controls | core, React | +| `components` | `MapView` and what it draws with: a component per layout, node components, the connector overlay, parameter controls | core, React | | `viewer` | The page-filling UI that hosts share. What is specific to a host comes in as an option | core, components, React, `structured-context/browser` | | `node` | What needs a filesystem: finding definitions, snapshotting a space, filling the self-contained page | core, Node, structured-context | | `artifact`, `page` | The two hosts the library ships. Nothing imports them | Anything above | @@ -35,7 +35,7 @@ Core is tested without a DOM, against fixtures captured from spaces (`tests/fixt Hosts pass the library structured-context's `SpaceGraph`: nodes keyed by id, the main hierarchy, and every hierarchy and relationship edge with its metadata, readable in both directions (`parentEdges`, `childEdges`). The Obsidian plugin assembles it in-process; the navigator's server sends the wire format (`exportSpaceGraph`) and its browser rebuilds the graph (`spaceGraphFrom`). The graph keeps edges to nodes outside it; the helpers in `core/layouts/helpers.ts` drop them, so a filtered space stays consistent. -Hosts can also pass validation results as an `AnnotationIndex` (`core/annotations.ts`): results by node id, built by `annotationsFrom` from structured-context's validation issues. `MapView` narrows it by the region's `nodes.validation` and `nodes.validationSources` and provides the result to node cards through React context, so layouts don't thread it through. Every layout draws nodes with `NodeCard`, which draws the badge. +Hosts can also pass validation results as an `AnnotationIndex` (`core/annotations.ts`): results by node id, built by `annotationsFrom` from structured-context's validation issues. `MapView` narrows it by the region's `nodes.validation` and `nodes.validationSources` and provides the result to node components through React context, so layouts don't thread it through. Every layout draws nodes with `NodeComponent`, which draws the badge. ## Projections diff --git a/docs/concepts.md b/docs/concepts.md index a124ada..b6808de 100644 --- a/docs/concepts.md +++ b/docs/concepts.md @@ -26,6 +26,10 @@ The step some layouts need to decide what is shown: it turns a space graph and t One rendered appearance of a space node. A node can occur more than once, for example under each of its parents in a tree; the later occurrences are repeats. Every occurrence has a key built from its path (region, then ancestors, then the node), so repeats stay distinct. +## Node component + +What every layout draws for an occurrence: a clickable node in the region's node style (a card with its title and fields, or a compact shape), with its validation badge. "Card" alone means the `card` style, not the component. + ## Connector The line drawn for an edge of the space graph, between two occurrences. "Edge" is the hierarchy or relationship reference in the data; "link" is left for structured-context's links between notes. diff --git a/packages/map-views/src/components/GraphLayout.tsx b/packages/map-views/src/components/GraphLayout.tsx index 21ea133..5073f91 100644 --- a/packages/map-views/src/components/GraphLayout.tsx +++ b/packages/map-views/src/components/GraphLayout.tsx @@ -5,7 +5,7 @@ import type { LayoutConfig } from '../core/definition'; import { assignLanes, type Connector, edgesWithin, isHierarchyEdge, occurrenceKey } from '../core/layouts/helpers'; import { ConnectorOverlay } from './ConnectorOverlay'; import { type LayoutProps, useOccurrenceElements } from './layout'; -import { NodeCard } from './NodeCard'; +import { NodeComponent } from './NodeComponent'; // Room each node needs. A card is a wide box; a shape is a marker with a label beside it. const CARD_ROOM = { width: 230, height: 110 }; @@ -54,7 +54,7 @@ export function GraphLayout({ graph, region, instanceId, onNodeSelect }: LayoutP style={{ left: x, top: y }} >
- +
{shape && ( {node.title} diff --git a/packages/map-views/src/components/LandscapeLayout.tsx b/packages/map-views/src/components/LandscapeLayout.tsx index 1567ab2..dfa9c07 100644 --- a/packages/map-views/src/components/LandscapeLayout.tsx +++ b/packages/map-views/src/components/LandscapeLayout.tsx @@ -3,7 +3,7 @@ import type { SpaceNode } from 'structured-context/api'; import type { LayoutConfig, Orientation } from '../core/definition'; import { buildLandscape, type LandscapeGroup, type LandscapeOccurrence } from '../core/layouts/landscape/projection'; import type { LayoutProps } from './layout'; -import { NodeCard } from './NodeCard'; +import { NodeComponent } from './NodeComponent'; type Level = LayoutConfig<'landscape'>['strips'][number]['group'][number]; @@ -58,7 +58,7 @@ export function LandscapeLayout({ graph, region, instanceId, onNodeSelect }: Lay if (occurrence.item.kind === 'node' && isLeaf(occurrence.level)) { return (
  • - + {breadcrumb(occurrence, levels)}
  • ); diff --git a/packages/map-views/src/components/NeighbourhoodLayout.tsx b/packages/map-views/src/components/NeighbourhoodLayout.tsx index cd2ea9f..3254129 100644 --- a/packages/map-views/src/components/NeighbourhoodLayout.tsx +++ b/packages/map-views/src/components/NeighbourhoodLayout.tsx @@ -4,7 +4,7 @@ import type { LayoutConfig } from '../core/definition'; import { buildNeighbourhood, type Neighbour } from '../core/layouts/neighbourhood/projection'; import { ConnectorOverlay } from './ConnectorOverlay'; import { type LayoutProps, useOccurrenceElements } from './layout'; -import { NodeCard } from './NodeCard'; +import { NodeComponent } from './NodeComponent'; // The most nodes across in the zones above and below, and down in the zones at the sides. const ACROSS = 3; @@ -46,7 +46,7 @@ export function NeighbourhoodLayout({ className="mv:relative mv:z-10" data-occurrence={`${instanceId}${item.key}`} > - + ); // A zone wraps into a few rows or columns, so a large one doesn't push the focus off screen. diff --git a/packages/map-views/src/components/NodeCard.tsx b/packages/map-views/src/components/NodeComponent.tsx similarity index 98% rename from packages/map-views/src/components/NodeCard.tsx rename to packages/map-views/src/components/NodeComponent.tsx index 2640f52..3f0c73f 100644 --- a/packages/map-views/src/components/NodeCard.tsx +++ b/packages/map-views/src/components/NodeComponent.tsx @@ -16,7 +16,7 @@ type Props = { * tooltip. Deliberately a `div` with button semantics rather than a `