Channel Sidebar

Channels and DMs in sections you fold and reorder, with unread, mention, muted and presence states.

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/channel-sidebar

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

Unreads only

API reference

Props

ChannelSidebar props
NameTypeDescription
labelrequiredstringThe list's accessible name
sectionsrequiredSidebarSection[]—
currentstringThe open conversation's id
unreadsOnlybooleanOnly unread conversations show
movablebooleanRows can be dragged to a new place
agentIdstring—

Events

ChannelSidebar events
EventPayloadDescription
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

What agents can do with ChannelSidebar
ActionDescription
ClickedSectionFold or unfold a section, by its id
ClickedUnreadsOnlyShow only unread conversations, or everything again
DroppedMove 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.

Source