# Notification list

A list of notifications as data: who did it, what happened, where and when, its light, its groups and its actions.

Live variants: https://design.arcadia.is/components/notification-list

```tsx
import {
  NotificationList, notificationCounts, notificationSummary,
} from "@arcadia/ui";
```

Find what needs an answer, then open a run to see its steps.

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

function Full() {
  const [items, setItems] = useState(ITEMS);
  const projects = [{ id: "release", name: "Release" }, { id: "platform", name: "Platform" }]
    .map((project) => ({ ...project, count: items.filter((item) => item.project === project.id).length }));
  return (
    <NotificationList
      items={items}
      projects={projects}
      now={NOW}
      onReadChange={(item, unread) => setItems((all) => all.map((x) => x.id === item.id ? { ...x, unread } : x))}
      onDone={(item) => setItems((all) => all.filter((x) => x.id !== item.id))}
    />
  );
}
```

## API reference

### NotificationList

- `items` (`readonly NotificationItem[]`, required): The notifications, in the order each group holds them.
- `labels` (`Partial<Record<NotificationWeight, string>>`): Group names by weight. Defaults: Needs you, For you, While you were away.
- `groupActions` (`Partial<Record<NotificationWeight, ReactNode>>`): One control at a group's heading, by weight (a Mark all read).
- `filters` (`boolean`): The filter row: true always, false never, left out it stands when more than one group holds something.
- `filterLabels` (`Partial<Record<NotificationFilter, string>>`): Filter names. Defaults: All, Needs you, For you, Away.
- `filter` (`NotificationFilter`): The chosen filter, controlled.
- `projects` (`readonly NotificationProject[]`, default `[]`)
- `projectFilter` (`string`)
- `onProjectFilterChange` (`(project: string) => void`)
- `defaultFilter` (`NotificationFilter`, default `"all"`): Its first value when uncontrolled.
- `onFilterChange` (`(filter: NotificationFilter) => void`): A filter pressed.
- `now` (`number`): The time the ages are read from, epoch ms. Default the shared clock, ticked each minute. A running state's clock always counts up live from its `since`.
- `loading` (`boolean`, default `false`): The first page is on its way: skeleton rows and aria-busy.
- `empty` (`ReactNode`, default `"Nothing needs you"`): What stands when there are no notifications. Default Nothing needs you.
- `onDone` (`(item: NotificationItem) => void`): The row's Done was pressed. Without it no Done control stands.
- `onReadChange` (`(item: NotificationItem, unread: boolean) => void`): Mark as read or unread was pressed. Without it the row has no menu.
- `onMute` (`(item: NotificationItem) => void`): Mute was pressed.
- `onTurnOff` (`(item: NotificationItem) => void`): Turn off was pressed.
- `group` (`"weight" | "owner"`, default `"weight"`): How the rows group. `weight`: Needs you, For you and While you were away, with filters. `owner`: the work list of Needs you, a heading that counts what is working and what is to check, then one group per actor under its picture, its rows without a read state, each with its state, progress, evidence, check and the choice made for the person, in the order given.
- `fold` (`number`, default `4`): The rows an owner's group shows before Show N more folds the rest.
- `heading` (`string`, default `"Work"`): The owner list's heading.
- `onCheck` (`(item: NotificationItem, verdict: NotificationVerdict) => void`): Looks good or Not right pressed on a row ready to check. Without it a check row draws no buttons.
- `rootStyle` (`RootStyle`): Typed StyleX override: where the list sits.

Rest props go to `<section>` props.
