# Relationship Map

The parts of a matter's party map: the matter at the top, a lane per role group with its badge header, party cards edged in the group's tone, kind tiles and the legend. Roles go on cards; relationship labels go on the lines between them.

- Beta: ready to use; its API can still change in a minor release.
- Category: Patterns · Relationships

```tsx
import { FocusNode, PartyLane, PartyNode, KindTile, RelationshipLegendItem } from "@leap-crm/design-system";
```

## Best practices

- Do: Head each lane with `PartyLane`. On an open canvas a header needs a shape of its own, so it is the status badge with the group's name and count, not a dot and a name.
- Do: Put a party's role on the matter on its `PartyNode`, like “Client · primary”, and relationship labels on the lines between cards.
- Do: Use `KindTile` at `size="md"` on map cards and `size="sm"` in rows. Its tint and icon both name the kind, and screen readers hear it.
- Do: Add a `RelationshipLegendItem` under the map for each group and for the relationship lines it shows, so every tone has words beside it.
- Don't: Rename a role group with a word the CRM doesn't use, like “Adverse”. Use `PartyLane`'s `label` only for a firm's own wording of the group.

## Keyboard

| Keys | What they do |
| --- | --- |
| Tab | Moves through its buttons in order. |
| Enter, Space | Presses the focused button. |

## Related

- [Record Chip](./record-chip.md)
- [Badge](./badge.md)
- [Opportunity Card](./opportunity-card.md)

## Examples

What the examples import:

```tsx
import { FocusNode, KindTile, PartyLane, PartyNode, RelationshipLegendItem, type PartyKind } from "@leap-crm/design-system";
```

Scaffolding the examples call. It lives in the docs page, not in the library:

```tsx
const kinds: PartyKind[] = [
  "person",
  "organisation",
  "group",
  "trust",
  "government",
  "matter",
];
```

### Map

The matter at the top, then a lane per role group: the badge header and its party cards. The legend sits under the map.

```tsx
<div className="flex flex-col items-center gap-6">
  <FocusNode
    open
    stage="Open · Agreement"
    title="Property & Children"
    subtitle="Family law · $48,000"
  />
  <div className="flex flex-wrap justify-center gap-4">
    <div className="flex flex-col items-center gap-2">
      <PartyLane group="client" count={1} />
      <PartyNode
        name="Yelena Cambiasso"
        matterRole="Client · primary"
        kind="person"
        group="client"
      />
    </div>
    <div className="flex flex-col items-center gap-2">
      <PartyLane group="other-side" count={1} />
      <PartyNode
        name="Marcus Feld"
        matterRole="Other side"
        kind="person"
        group="other-side"
      />
    </div>
    <div className="flex flex-col items-center gap-2">
      <PartyLane group="additional" count={1} />
      <PartyNode
        name="Cambiasso Family Trust (Superannuation Fund No. 2)"
        matterRole="Trustee"
        kind="trust"
        group="additional"
      />
    </div>
  </div>
  <div className="flex flex-wrap gap-4">
    <RelationshipLegendItem kind="client" />
    <RelationshipLegendItem kind="other-side" />
    <RelationshipLegendItem kind="relationship" />
  </div>
</div>
```

### Party cards

Edged in the group's tone, or the plain border for a contact outside a group. Long names and roles clip, with the full value on hover.

```tsx
<div className="flex flex-wrap gap-4">
  <PartyNode
    name="Yelena Cambiasso"
    matterRole="Client · primary"
    kind="person"
    group="client"
  />
  <PartyNode
    name="Harbour Lending Pty Ltd"
    matterRole="Other side"
    kind="organisation"
    group="other-side"
  />
  <PartyNode
    name="Cambiasso Family Trust"
    matterRole="Trustee"
    kind="trust"
    group="additional"
  />
  <PartyNode
    name="Tom Citizen"
    matterRole="Not in a group"
    kind="person"
  />
</div>
```

### Kind tiles

Tint and icon both name the kind, so neither carries it alone. 24 px on cards, 20 px in rows.

```tsx
<div className="flex flex-col gap-3">
  <div className="flex gap-3">
    {kinds.map(kind => (
      <KindTile key={kind} kind={kind} />
    ))}
  </div>
  <div className="flex gap-3">
    {kinds.map(kind => (
      <KindTile key={kind} kind={kind} size="sm" />
    ))}
  </div>
</div>
```

## Props

### FocusNode

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `title` (required) | `string` |  | The contact the map is about. |
| `subtitle` | `ReactNode` |  | What it is and what it's worth, like "Family law · $48,000". |
| `stage` | `ReactNode` |  | Where it stands, like "Open · Agreement". |
| `open` | `boolean` | `false` | The matter is open: the stage line takes the client's tone dot. |

### PartyLane

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `group` (required) | `"client" \| "other-side" \| "additional"` |  | The role group: client, other side or additional. |
| `count` (required) | `number` |  | How many parties the lane holds, shown in its header. |
| `label` | `string` |  | Overrides the group's own name, like a firm's own wording. |

### PartyNode

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `name` (required) | `string` |  | The person's or organisation's name. |
| `matterRole` (required) | `string` |  | The party's role on the matter, like "Client · primary". |
| `kind` (required) | `\| "person" \| "organisation" \| "group" \| "trust" \| "government" \| "matter"` |  | person, organisation or group: the tile beside the name. |
| `group` | `PartyGroup \| "none"` | `"none"` | The group whose tone edges the card; none for a contact outside a group. |

### KindTile

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `kind` (required) | `\| "person" \| "organisation" \| "group" \| "trust" \| "government" \| "matter"` |  | person, organisation or group: the icon and its colour. |
| `size` | `"sm" \| "md"` | `"md"` | sm or md. |

### RelationshipLegendItem

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `kind` (required) | `PartyGroup \| "relationship"` |  | The role group, or a relationship line, that the swatch stands for. |
| `label` | `string` |  | Words for the swatch. The group's own name when left out. |
