# Commit trail

A branch's commits on one line, newest first, with a merge's own folded away and each commit, push and deploy outcome kept apart.

Live variants: https://design.arcadia.is/components/commit-trail

```tsx
import { CommitTrail } from "@arcadia/ui";
```

```tsx
import { CommitTrail } from "@arcadia/ui";

<CommitTrail commits={TRAIL} branch="main" now={NOW} receipts={[
    { stage: "commit", status: "succeeded", target: "Retry failed webhooks" },
    { stage: "push", status: "failed", error: "The remote branch moved" },
    { stage: "pr", status: "pending" },
  ]} />
```

## Accessibility

The commits are an ordered list named Commits on the branch. Each commit is one button whose name is its message, its author and co-author, and its time, with aria-expanded and aria-controls to the detail it opens or to the commits a merge folds. The list is one Tab stop: the arrows move from commit to commit, including an open merge's own, Home and End go to the first and last, Enter or Space opens a commit or folds a merge, and Escape closes or folds and gives the row its focus back. Tab inside an open commit reaches Copy hash.

A pending commit is not a button and reads who is committing and what. Every receipt says its status in words and never in colour alone, a failure keeps its error text, and the strip's name says the three stages. When a commit lands or a receipt changes, a polite live region says so once: Scout committed: Retry failed webhooks. The trail's line, nodes and dots are decoration and hidden from a reader, who has the words. Under reduced motion the check settles in one frame, and under forced colours the nodes and the line take the system's inks.

- Tab: Into the trail, then from an open commit to Copy hash.
- ↑ + ↓: From one commit to the one above or below, an open merge's own among them.
- Home + End: The newest commit and the oldest shown.
- Enter: Opens a commit, or folds and unfolds a merge.
- Esc: Closes a commit or folds a merge, and returns focus to its row.

## API reference

### CommitTrail

- `commits` (`readonly TrailCommit[]`, required): The branch's commits, newest first; a commit's own commits fold under it.
- `receipts` (`readonly TrailStageReceipt[]`): What actually happened at each stage: commit, push, pull request, merge and deploy stay separate, and a failure keeps its error.
- `refs` (`Readonly<Record<string, string>>`): What a chip in a message stands for, by its text: a pointer resting on it shows this ("feature/commit-trail").
- `kinds` (`Readonly<Record<string, TrailKindMeta>>`): Words and inks for kinds of change, on top of the kit's own (feat, fix, refactor, perf, docs, test, chore, release, merge).
- `branches` (`readonly string[]`): Every branch a commit could be on: two or more make the branch line a switcher.
- `branch` (`string`): The branch shown (controlled).
- `defaultBranch` (`string`): The branch shown at first. Default: the first of branches.
- `onBranchChange` (`(branch: string) => void`): Told the branch a person picked.
- `open` (`string | null`): The open commit's id (controlled): one is open at a time.
- `defaultOpen` (`string | null`): The open commit at first.
- `onOpenChange` (`(id: string | null) => void`): Told the commit that opened, or null when the open one closed.
- `expanded` (`readonly string[]`): The merges whose own commits are unfolded (controlled).
- `defaultExpanded` (`readonly string[]`): The merges unfolded at first.
- `onExpandedChange` (`(ids: string[]) => void`): Told every merge open after a fold or an unfold.
- `hasMore` (`boolean`, default `false`): The trail goes on past the last commit: its line fades at its end.
- `maxHeight` (`number`): The list's greatest height in pixels, past which it scrolls.
- `locale` (`string`, default `en-US`): The locale of a full date. The kit's.
- `now` (`number`): The clock a render stands at, for a render that must not drift (a prerender). Default: now, every minute.
- `labels` (`CommitTrailLabelsInput`): The words it says.
- `rootStyle` (`RootStyle<CommitTrailKnobs>`): Typed StyleX override: where the trail sits, and its --trail-rail and --trail-node.

Rest props go to `HTMLAttributes<HTMLDivElement>`.
