Skip to content

Commit 8434826

Browse files
committed
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.
1 parent 3bdef4e commit 8434826

10 files changed

Lines changed: 20 additions & 16 deletions

File tree

‎docs/architecture.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ All but the last two rows are folders of `packages/map-views/src`.
1818
| Module | Holds | May import |
1919
|---|---|---|
2020
| `core` | Definitions and parameters, annotations, and each layout's settings schema and projection, if it has one (`core/layouts/<name>/`). Runs in a browser, Node or a worker | Types from structured-context. No React, DOM or Node |
21-
| `components` | `MapView` and what it draws with: a component per layout, node cards, the connector overlay, parameter controls | core, React |
21+
| `components` | `MapView` and what it draws with: a component per layout, node components, the connector overlay, parameter controls | core, React |
2222
| `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` |
2323
| `node` | What needs a filesystem: finding definitions, snapshotting a space, filling the self-contained page | core, Node, structured-context |
2424
| `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
3535

3636
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.
3737

38-
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.
38+
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.
3939

4040
## Projections
4141

‎docs/concepts.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ The step some layouts need to decide what is shown: it turns a space graph and t
2626

2727
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.
2828

29+
## Node component
30+
31+
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.
32+
2933
## Connector
3034

3135
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.

‎packages/map-views/src/components/GraphLayout.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { LayoutConfig } from '../core/definition';
55
import { assignLanes, type Connector, edgesWithin, isHierarchyEdge, occurrenceKey } from '../core/layouts/helpers';
66
import { ConnectorOverlay } from './ConnectorOverlay';
77
import { type LayoutProps, useOccurrenceElements } from './layout';
8-
import { NodeCard } from './NodeCard';
8+
import { NodeComponent } from './NodeComponent';
99

1010
// Room each node needs. A card is a wide box; a shape is a marker with a label beside it.
1111
const CARD_ROOM = { width: 230, height: 110 };
@@ -54,7 +54,7 @@ export function GraphLayout({ graph, region, instanceId, onNodeSelect }: LayoutP
5454
style={{ left: x, top: y }}
5555
>
5656
<div ref={register(key)}>
57-
<NodeCard node={node} repeat={false} nodes={region.nodes} onSelect={onNodeSelect} />
57+
<NodeComponent node={node} repeat={false} nodes={region.nodes} onSelect={onNodeSelect} />
5858
</div>
5959
{shape && (
6060
<span className="mv:whitespace-nowrap mv:rounded mv:bg-surface/80 mv:px-0.5 mv:text-xs">{node.title}</span>

‎packages/map-views/src/components/LandscapeLayout.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { SpaceNode } from 'structured-context/api';
33
import type { LayoutConfig, Orientation } from '../core/definition';
44
import { buildLandscape, type LandscapeGroup, type LandscapeOccurrence } from '../core/layouts/landscape/projection';
55
import type { LayoutProps } from './layout';
6-
import { NodeCard } from './NodeCard';
6+
import { NodeComponent } from './NodeComponent';
77

88
type Level = LayoutConfig<'landscape'>['strips'][number]['group'][number];
99

@@ -58,7 +58,7 @@ export function LandscapeLayout({ graph, region, instanceId, onNodeSelect }: Lay
5858
if (occurrence.item.kind === 'node' && isLeaf(occurrence.level)) {
5959
return (
6060
<li key={occurrence.key} {...marker} className="mv:flex mv:flex-col mv:gap-0.5">
61-
<NodeCard node={occurrence.item.node} repeat={repeat} nodes={region.nodes} onSelect={onNodeSelect} />
61+
<NodeComponent node={occurrence.item.node} repeat={repeat} nodes={region.nodes} onSelect={onNodeSelect} />
6262
{breadcrumb(occurrence, levels)}
6363
</li>
6464
);

‎packages/map-views/src/components/NeighbourhoodLayout.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { LayoutConfig } from '../core/definition';
44
import { buildNeighbourhood, type Neighbour } from '../core/layouts/neighbourhood/projection';
55
import { ConnectorOverlay } from './ConnectorOverlay';
66
import { type LayoutProps, useOccurrenceElements } from './layout';
7-
import { NodeCard } from './NodeCard';
7+
import { NodeComponent } from './NodeComponent';
88

99
// The most nodes across in the zones above and below, and down in the zones at the sides.
1010
const ACROSS = 3;
@@ -46,7 +46,7 @@ export function NeighbourhoodLayout({
4646
className="mv:relative mv:z-10"
4747
data-occurrence={`${instanceId}${item.key}`}
4848
>
49-
<NodeCard node={item.node} repeat={false} nodes={region.nodes} onSelect={select} />
49+
<NodeComponent node={item.node} repeat={false} nodes={region.nodes} onSelect={select} />
5050
</div>
5151
);
5252
// A zone wraps into a few rows or columns, so a large one doesn't push the focus off screen.

packages/map-views/src/components/NodeCard.tsx renamed to packages/map-views/src/components/NodeComponent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type Props = {
1616
* tooltip. Deliberately a `div` with button semantics rather than a `<button>`: hosts style
1717
* native form controls globally (Obsidian fixes button height and disables wrapping).
1818
*/
19-
export function NodeCard({ node, repeat, nodes, onSelect }: Props) {
19+
export function NodeComponent({ node, repeat, nodes, onSelect }: Props) {
2020
const select = () => onSelect?.(node);
2121
const annotations = useAnnotations().get(node.id);
2222
const label = `${node.resolvedType}: ${node.title}${repeat ? ' (shown in full elsewhere)' : ''}${annotationsLabel(annotations)}`;

‎packages/map-views/src/components/TreeLayout.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { LayoutConfig, Orientation } from '../core/definition';
33
import { buildTree, type TreeOccurrence, treeConnectors } from '../core/layouts/tree/projection';
44
import { ConnectorOverlay } from './ConnectorOverlay';
55
import { type LayoutProps, useOccurrenceElements } from './layout';
6-
import { NodeCard } from './NodeCard';
6+
import { NodeComponent } from './NodeComponent';
77

88
/**
99
* Tree over the schema's hierarchy. Flexbox does the branching; the SVG overlay draws connectors.
@@ -21,7 +21,7 @@ export function TreeLayout({ graph, region, instanceId, onNodeSelect }: LayoutPr
2121
className={`mv:flex mv:items-center ${orientation === 'vertical' ? 'mv:flex-col' : 'mv:flex-row'}`}
2222
>
2323
<div ref={register(occurrence.key)} data-occurrence={`${instanceId}${occurrence.key}`}>
24-
<NodeCard
24+
<NodeComponent
2525
node={occurrence.node}
2626
repeat={occurrence.repeatOf !== undefined}
2727
nodes={region.nodes}

‎packages/map-views/src/components/XYLayout.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { LayoutConfig } from '../core/definition';
33
import { buildXYPlot } from '../core/layouts/xy/projection';
44
import { ConnectorOverlay } from './ConnectorOverlay';
55
import { type LayoutProps, useOccurrenceElements } from './layout';
6-
import { NodeCard } from './NodeCard';
6+
import { NodeComponent } from './NodeComponent';
77

88
/**
99
* Nodes positioned by two numeric fields, with straight connectors between them. Positions are
@@ -41,7 +41,7 @@ export function XYLayout({ graph, region, instanceId, onNodeSelect }: LayoutProp
4141
style={{ left: `${point.x * 100}%`, bottom: `${point.y * 100}%` }}
4242
>
4343
<div ref={register(point.key)}>
44-
<NodeCard node={point.node} repeat={false} nodes={region.nodes} onSelect={onNodeSelect} />
44+
<NodeComponent node={point.node} repeat={false} nodes={region.nodes} onSelect={onNodeSelect} />
4545
</div>
4646
{shape && (
4747
<span className="mv:whitespace-nowrap mv:rounded mv:bg-surface/80 mv:px-0.5 mv:text-xs">
@@ -62,7 +62,7 @@ export function XYLayout({ graph, region, instanceId, onNodeSelect }: LayoutProp
6262
<ul className="mv:m-0 mv:flex mv:list-none mv:flex-wrap mv:gap-3 mv:p-0">
6363
{plot.unplaced.map(({ key, node, reasons }) => (
6464
<li key={key} data-occurrence={`${instanceId}${key}`} className="mv:flex mv:items-center mv:gap-1">
65-
<NodeCard node={node} repeat={false} nodes={region.nodes} onSelect={onNodeSelect} />
65+
<NodeComponent node={node} repeat={false} nodes={region.nodes} onSelect={onNodeSelect} />
6666
<span className="mv:text-xs">
6767
{shape && `${node.title} `}
6868
<span className="mv:text-muted">({reasons.join('; ')})</span>

‎packages/map-views/src/components/annotations-context.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { AnnotationIndex } from '../core/annotations';
33

44
const NONE: AnnotationIndex = new Map();
55

6-
/** The annotations a map view shows, already narrowed by its validation settings. Read by node cards. */
6+
/** The annotations a map view shows, already narrowed by its validation settings. Read by node components. */
77
export const AnnotationsContext = createContext<AnnotationIndex>(NONE);
88

99
export const useAnnotations = () => useContext(AnnotationsContext);

packages/map-views/tests/node-card.test.tsx renamed to packages/map-views/tests/node-component.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import sample from './fixtures/launch-playbook.json';
1010
const graph = fixtureGraph(sample);
1111
const [definition] = loadMapViewDefinitions({ spaces: [] }, { configDir: '/nonexistent' });
1212

13-
describe('node cards', () => {
13+
describe('node components', () => {
1414
test('every card carries the id of a node in the graph, repeats included', () => {
1515
const html = renderToStaticMarkup(createElement(MapView, { definition: definition!, graph, values: {} }));
1616
const ids = [...html.matchAll(/data-node-id="([^"]*)"/g)].map((m) => m[1]!.replaceAll('&amp;', '&'));

0 commit comments

Comments
 (0)