# Timeline

Rows of bars on an axis of days: a roadmap's milestones in time, what is late, what is blocked wrongly and where today is.

Live variants: https://design.arcadia.is/components/timeline

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

Use the ruler to compare milestone dates. Open a bar to see its milestone.

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

function Roadmap() {
  const [opened, setOpened] = useState<TimelineBar>();
  return (
    <div {...sx("cmp-timeline-full", TimelineS.full)}>
      <Timeline label="Compiler" today={TODAY} noun="milestone" rows={COMPILER} links={COMPILER_LINKS} unplaced={LATER}
        onOpen={(id) => setOpened(MILESTONES.find((bar) => bar.id === id))} />
      <div role="status" {...sx("cmp-timeline-opened", page.opened, opened && TimelineS.opened)}>{opened && "Opened " + opened.title}</div>
    </div>
  );
}
```

## Accessibility

For assistive technology the same content is a table, the kit's `Table`, heard only and first in the part's reading order: its caption the label and today ("Compiler, today Nov 20"), a row for each bar with Name, Start, Due, Done, State and Blocked by, an item with no due day read as Not planned, and groups as its row groups under their heads. It holds no control, so focus never lands on what is not seen.

The bars are one Tab stop, a grid. A bar's name is its words in one line, the table's: "Type checker, begun, Nov 9 to Dec 11, 2 of 9, waits on Parser". The head, the words beside a bar and the marks are hidden from readers, who have them in the names and the table, so nothing is heard twice. A bar in focus comes into view, lights its links and shows its hint, with no entrance from the keyboard. With `onOpen` a bar is a button; without it a bar has its hint and nothing else, and a row's label keeps its link. The pointer of a row with nothing in view is the drawing's too: the arrows reach that bar and bring it into view.

A handle is a slider reached by Tab from its bar, its value text the day as it moves ("Due Friday, December 4"). A refusal's reason is heard once and stays under the row's label until that bar changes again. The focus ring is the kit's neutral ring on bars, chips and handles; under forced colours the shapes, outlines, marks, links and today's line take the system's inks.

- Tab: Into the bars, then to the handles of the bar in focus.
- ← + →: Along a row by day; right to left, the arrows follow the page. On a handle, a day.
- Shift ← + Shift →: On a handle, a week.
- ↑ + ↓: To the nearest bar in the row above or below; the chips in Not planned are the last row.
- Home + End: A row's first bar and its last.
- Enter: Opens a bar where the product gives `onOpen`; on a handle, keeps the new day.
- Esc: On a handle, gives the move up; elsewhere, hides the hint. Leaving a handle without Enter gives up too.

## API reference

### Timeline

- `label` (`string`, required): Its name: the grid's, and the reader's table's caption with today ("Roadmap, today Nov 20").
- `today` (`Day`, required): The day it is, given by the product: never the machine's clock.
- `rows` (`readonly TimelineRow[]`): The rows in order, one group with no head.
- `groups` (`readonly TimelineGroup[]`): In place of `rows`: groups of rows, each under a head (several roadmaps in one view).
- `links` (`readonly TimelineLink[]`, default `NO_LINKS`): "Blocked by" links: `to` is blocked by `from`.
- `unplaced` (`readonly TimelineBar[]`, default `NO_BARS`): Items with no day, in the strip "Not planned".
- `zoom` (`"week" | "month" | "quarter"`): `"week"`, `"month"` or `"quarter"`, held by the product.
- `defaultZoom` (`"week" | "month" | "quarter"`, default `"month"`): The zoom it starts on, held by the part.
- `onZoomChange` (`(zoom: TimelineZoom) => void`): The zoom chosen.
- `editable` (`boolean`, default `false`): Due days and planned starts change by their handles, where a callback is given. Never on a reached or closed bar.
- `onDueChange` (`(id: string, day: Day) => TimelineAnswer`): A due day moved and kept: answer nothing to accept, or a reason in the product's words to refuse.
- `onStartChange` (`(id: string, day: Day) => TimelineAnswer`): A planned start moved and kept, on the same terms; only a bar not begun has one.
- `onOpen` (`(id: string) => void`): A bar pressed, by the pointer or Enter: with it a bar is a button, without it a bar has its hint and nothing else.
- `noun` (`string`, default `"item"`): The singular noun of a bar, in the product's words ("milestone").
- `legend` (`boolean`, default `true`): The legend's one line: the shapes and marks the data holds, left out where one line cannot hold it.
- `locale` (`string`): The reader's locale, for the words of days. Default: the platform's.
- `loading` (`boolean`, default `false`): Loading: the toolbar, the head with today and the labels known; after 200ms a still block where the bars go.
- `empty` (`{ title: string; action?: ReactNode }`): Nothing given: the empty state's words, in the product's terms, and its one way to add.
- `error` (`{ message: string; readout?: string }`): It failed: what happened and what to do, and the machine's own message as a readout, with Retry (`onRetry`).
- `missing` (`readonly string[]`): The groups that did not come, by name: one line names them, with Retry.
- `onRetry` (`() => void`): Retry after an error or for the groups missing.
- `rootStyle` (`RootStyle<TimelineKnobs>`): Typed StyleX override: where it sits, its height's bound and `--timeline-label`.

Rest props go to `HTMLAttributes<HTMLDivElement>`.
