Channels and DMs in sections you fold and reorder, with unread, mention, muted and presence states.
Installation
Usage
import { ChannelSidebar, type SidebarSection } from "./ui/uicontext/components/kit/ChannelSidebar.ts"const Message = UiSchema.TaggedEnum({ ToggledSection: { section: Schema.String, collapsed: Schema.Boolean }, ToggledUnreads: { on: Schema.Boolean }, MovedRow: { row: Schema.String, section: Schema.String, index: Schema.Number }, OpenedRow: { href: Schema.String },})// the app keeps the sections and their order; each row is a link to its conversationexport const Sidebar = (h: Html.H<typeof Message.Type>, sections: ReadonlyArray<SidebarSection>, current: string, unreadsOnly: boolean) => ChannelSidebar(h, { props: { label: "Conversations", sections, current, unreadsOnly, movable: true }, onEmit: { RequestedToggleSection: ({ section, collapsed }) => Message.ToggledSection({ section, collapsed }), RequestedUnreadsOnly: ({ on }) => Message.ToggledUnreads({ on }), RequestedMove: (move) => Message.MovedRow(move), RequestedOpen: ({ href }) => Message.OpenedRow({ href }), }, })Examples
API reference
Props
| Name | Type | Description |
|---|---|---|
labelrequired | string | The list's accessible name |
sectionsrequired | SidebarSection[] | — |
current | string | The open conversation's id |
unreadsOnly | boolean | Only unread conversations show |
movable | boolean | Rows can be dragged to a new place |
agentId | string | — |
Events
| Event | Payload | Description |
|---|---|---|
RequestedToggleSection | { section: string; collapsed: boolean } | Fold or unfold a section |
RequestedUnreadsOnly | { on: boolean } | Show only unread conversations, or everything |
RequestedMove | { row: string; section: string; index: number } | Move a row to index in section (counted without the row itself) |
RequestedOpen | { row: string; href: string } | Open a conversation: Alt+Up or Alt+Down asked for the one before or after |
Agent actions
| Action | Description |
|---|---|
ClickedSection | Fold or unfold a section, by its id |
ClickedUnreadsOnly | Show only unread conversations, or everything again |
Dropped | Move a conversation (row id) to a section at an index |
Accessibility
- Each section's heading is a button that folds it (
aria-expanded); Unreads is a toggle button. - Rows are links that say what they are and what they want: “channel design-crit, 1 mention, muted”. Alt+Up and Alt+Down move between conversations from anywhere; Alt+Shift with the arrows moves a focused row.