# Repo map

A repository as a treemap: every folder a group, every file a tile as large as its lines, edited files tinted by the agent that changed them, reads dashed, and one filter for each agent.

Live variants: https://design.arcadia.is/components/repo-map

```tsx
import { RepoMap, layoutRepoMap } from "@arcadia/ui/charts";
```

Select a file to see its changes and who worked on it.

```tsx
import { useState } from "react";
import { RepoMap } from "@arcadia/ui/charts";

function Picked() {
  const [opened, setOpened] = useState<string | null>(null);
  return (
    <div {...sx("repo-map-demo", page.board)}>
      <RepoMap title="Design system" branch="main" files={FILES} onSelectFile={(file) => setOpened(file.path)} />
      <p {...sx("repo-map-opened", page.opened)}>{opened == null ? "No file opened yet" : "Opened " + opened}</p>
    </div>
  );
}
```

## Accessibility

The map is one listbox named by its title, and every file is an option named by its full path, its lines, its diff, its editors, any read-only agents and a stated conflict. A tiny tile keeps that name even where no text is drawn.

Tab passes the agent toggle buttons, each with `aria-pressed` and its touched file count, then stops once in the map on the active file; every other file has `tabIndex=-1`. The arrows move the focus and the selection together, so a reader hears each file as it is reached. Home and End reach the first and last, and Enter or Space calls `onSelectFile`.

Escape closes the file card and then clears the agent filter. A polite status region says what a filter leaves lit, and what the map holds after its files change.

Read-only files carry a dashed edge as well as a missing diff, shared edits are named in words, and only `conflict: true` paints the conflict mark and says Conflict, so colour never carries a difference alone. An edited tile draws a short mark for each editor, taken from the start of the name and lengthened until no two agents share it. The filter and the card draw the same marks, and an Unknown edit draws a question mark. The focus and active rings draw inset inside a tile, so the map clips nothing.

## API reference

### RepoMap

- `title` (`string`, required): The map's name: the header's line and the file list's name.
- `files` (`readonly RepoMapFile[]`, required): Every file, in any order. A path given twice is read once, from its first record.
- `branch` (`string`): The branch the work stands on, beside the title.
- `depth` (`number`, default `2`): How many path segments make a folder: 2 groups src/components, 1 groups src.
- `onSelectFile` (`(file: RepoMapFile) => void`): A file pressed, or opened with Enter or Space: open its diff.
- `empty` (`ReactNode`): In place of the map when there are no files.
- `rootStyle` (`RootStyle<RepoMapKnobs>`)

Rest props go to `HTMLAttributes<HTMLDivElement>`.
