# `LedgerUI.Components.NotificationCenter`
[🔗](https://github.com/devaction-labs/ledger_ui/blob/v0.2.0/lib/ledger_ui/components/notification_center.ex#L1)

A bell with a count when something is unread and, under it, a panel with the notifications
(`<.notification_center>`).

    <.notification_center
      id="notifications"
      items={@notifications}
      on_read="read"
      on_read_all="read_all"
    />

    <.notification_center id="inbox" variant="classic" items={@notifications}
      tabs={[%{id: "all", label: "All"}, %{id: "unread", label: "Unread"}, %{id: "orders", label: "Orders"}]}
      all_href={~p"/notifications"} />

Each item is a map: `title` (required), `body`, `at`, `group` (day heading shared by consecutive
items), `type` (`info success warning error primary`), `tone` (`lime`...), `icon`, `avatar`
(`%{initials: "FP", tint: "t2"}`), `category` (a tab id), `read`, `id`, and `navigate`, `patch` or `href`.

The panel is a popover (`LedgerUI.Float` hook, `priv/static/ledger_ui/hooks/float.js`): it closes on a click
outside and on Esc, opens with `LedgerUI.open(socket, id)` and the tabs filter in the browser. Marking as
read is up to the server: change `read` and the dot, the count and the bell follow. `on_read`
pushes `%{"id" => id, "item" => item_id}`, `on_read_all` `%{"id" => id}`, `on_change` the tab
`%{"id" => id, "tab" => tab_id}`; each takes an event name (to `target`) or a `%JS{}`.

`variant="canvas"` is the compact panel (rows only); `classic` has a title bar, tabs and footer.
`inline` renders only the panel, in the page flow (no bell, no hook).

# `notification_center`

## Attributes

* `id` (`:string`) (required)
* `items` (`:list`) - Defaults to `[]`.
* `tabs` (`:list`) - Defaults to `[%{id: "all", label: "Todas"}, %{id: "unread", label: "Não lidas"}]`.
* `unread` (`:integer`) - Defaults to `nil`.
* `title` (`:string`) - Defaults to `"Notificações"`.
* `bell_label` (`:string`) - Defaults to `"Notificações"`.
* `read_all_label` (`:string`) - Defaults to `"Marcar todas como lidas"`.
* `preferences_label` (`:string`) - Defaults to `"Preferências de notificação"`.
* `all_label` (`:string`) - Defaults to `"Ver todas as notificações"`.
* `unread_label` (`:string`) - Defaults to `"não lidas"`.
* `empty` (`:string`) - Defaults to `"Nenhuma notificação"`.
* `empty_text` (`:string`) - Defaults to `"Quando houver novidades, elas aparecem aqui."`.
* `variant` (`:string`) - Defaults to `"canvas"`. Must be one of `"canvas"`, or `"classic"`.
* `empty_icon` (`:string`) - Defaults to `nil`.
* `empty_tone` (`:string`) - Defaults to `"success"`. Must be one of `"neutral"`, `"primary"`, `"info"`, `"success"`, `"warning"`, or `"error"`.
* `all_href` (`:string`) - Defaults to `nil`.
* `preferences_href` (`:string`) - Defaults to `nil`.
* `on_read_all` (`:any`) - Defaults to `nil`.
* `on_read` (`:any`) - Defaults to `nil`.
* `on_change` (`:any`) - Defaults to `nil`.
* `target` (`:any`) - Defaults to `nil`.
* `open` (`:boolean`) - Defaults to `false`.
* `placement` (`:string`) - Defaults to `"bottom-end"`.
* `arrow` (`:boolean`) - Defaults to `false`.
* `class` (`:any`) - Merged into the panel. Defaults to `nil`.
* `inline` (`:boolean`) - Only the panel, in the page flow: no bell, no hook. Defaults to `false`.
* Global attributes are accepted.
## Slots

* `empty_action`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
